aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/common/configkey.h
blob: 2b8d2fc70b3585ca39e6d15432c2d06a2d6ee1d4 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "types.h"

namespace config {

class ConfigKey {
public:
    ConfigKey(vespalib::stringref configId,
              vespalib::stringref defName,
              vespalib::stringref defNamespace,
              vespalib::stringref defMd5);

    ConfigKey(vespalib::stringref configId,
              vespalib::stringref defName,
              vespalib::stringref defNamespace,
              vespalib::stringref defMd5,
              const StringVector & defSchema);

    ConfigKey(const ConfigKey &);
    ConfigKey & operator = (const ConfigKey &);
    ConfigKey(ConfigKey &&) noexcept;
    ConfigKey & operator = (ConfigKey &&) noexcept;
    ConfigKey();
    ~ConfigKey();

    bool operator<(const ConfigKey & rhs) const;
    bool operator>(const ConfigKey & rhs) const;
    bool operator==(const ConfigKey & rhs) const;

    const vespalib::string & getDefName() const;
    const vespalib::string & getConfigId() const;
    const vespalib::string & getDefNamespace() const;
    const vespalib::string & getDefMd5() const;
    const StringVector & getDefSchema() const;

    template <typename ConfigType>
    static const ConfigKey create(vespalib::stringref configId)
    {
        return ConfigKey(configId, ConfigType::CONFIG_DEF_NAME,
                                   ConfigType::CONFIG_DEF_NAMESPACE,
                                   ConfigType::CONFIG_DEF_MD5,
                                   ConfigType::CONFIG_DEF_SCHEMA);
    }

    const vespalib::string toString() const;
private:
    vespalib::string _configId;
    vespalib::string _defName;
    vespalib::string _defNamespace;
    vespalib::string _defMd5;
    StringVector     _defSchema;
    vespalib::string _key;
};

} //namespace config