aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/common/config_hash.h
blob: 581621f88f7ec80d6acbc02abfbf77d3c29fd601 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <vector>

namespace proton {

/*
 * Utility class to access a config vector based on name instead of index.
 * The vector must remain valid during the lifetime of the config hash.
 */
template <class Elem>
class ConfigHash {
    vespalib::hash_map<vespalib::string, const Elem *> _hash;
public:
    ConfigHash(const std::vector<Elem> &config);
    ~ConfigHash();
    const Elem *lookup(const vespalib::string &name) const;
};

} // namespace proton