aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/attribute_config_inspector.cpp
blob: 444b8973a9ca873508fc20f04ea146afe1fe0e64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "attribute_config_inspector.h"
#include <vespa/searchlib/attribute/configconverter.h>
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/config-attributes.h>
#include <vespa/vespalib/stllike/hash_map.hpp>

using search::attribute::ConfigConverter;
using search::attribute::Config;

namespace proton {

AttributeConfigInspector::AttributeConfigInspector(const AttributesConfig& config)
    : _hash()
{
    for (auto& attr : config.attribute) {
        auto res = _hash.insert(std::make_pair(attr.name, std::make_unique<Config>(ConfigConverter::convert(attr))));
        assert(res.second);
    }
}

AttributeConfigInspector::~AttributeConfigInspector() = default;

const Config*
AttributeConfigInspector::get_config(const vespalib::string& name) const
{
    auto itr = _hash.find(name);
    return (itr != _hash.end()) ? itr->second.get() : nullptr;
}

}