1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2
3 #pragma once
4
5 #include <cstdint>
6 #include <map>
7 #include <set>
8 #include <string>
9 #include <utility>
10
11 #include "common/entity_name.h"
12 #include "common/options.h"
13 #include "log/SubsystemMap.h"
14 #include "msg/msg_types.h"
15
16 // @c ConfigValues keeps track of mappings from the config names to their values,
17 // debug logging settings, and some other "unnamed" settings, like entity name of
18 // the daemon.
19 class ConfigValues {
20 using values_t = std::map<std::string_view, std::map<int32_t,Option::value_t>>;
21 values_t values;
22 // for populating md_config_impl::legacy_values in ctor
23 friend struct md_config_t;
24
25 public:
26 EntityName name;
27 /// cluster name
28 std::string cluster;
29 ceph::logging::SubsystemMap subsys;
30 bool no_mon_config = false;
31 bool log_early = false;
32 // Set of configuration options that have changed since the last
33 // apply_changes
34 using changed_set_t = std::set<std::string>;
35 changed_set_t changed;
36
37 // This macro block defines C members of the md_config_t struct
38 // corresponding to the definitions in legacy_config_opts.h.
39 // These C members are consumed by code that was written before
40 // the new options.cc infrastructure: all newer code should
41 // be consume options via explicit get() rather than C members.
42 #define OPTION_OPT_INT(name) int64_t name;
43 #define OPTION_OPT_LONGLONG(name) int64_t name;
44 #define OPTION_OPT_STR(name) std::string name;
45 #define OPTION_OPT_DOUBLE(name) double name;
46 #define OPTION_OPT_FLOAT(name) double name;
47 #define OPTION_OPT_BOOL(name) bool name;
48 #define OPTION_OPT_ADDR(name) entity_addr_t name;
49 #define OPTION_OPT_ADDRVEC(name) entity_addrvec_t name;
50 #define OPTION_OPT_U32(name) uint64_t name;
51 #define OPTION_OPT_U64(name) uint64_t name;
52 #define OPTION_OPT_UUID(name) uuid_d name;
53 #define OPTION_OPT_SIZE(name) uint64_t name;
54 #define OPTION(name, ty) \
55 public: \
56 OPTION_##ty(name)
57 #define SAFE_OPTION(name, ty) \
58 protected: \
59 OPTION_##ty(name)
60 #include "common/legacy_config_opts.h"
61 #undef OPTION_OPT_INT
62 #undef OPTION_OPT_LONGLONG
63 #undef OPTION_OPT_STR
64 #undef OPTION_OPT_DOUBLE
65 #undef OPTION_OPT_FLOAT
66 #undef OPTION_OPT_BOOL
67 #undef OPTION_OPT_ADDR
68 #undef OPTION_OPT_ADDRVEC
69 #undef OPTION_OPT_U32
70 #undef OPTION_OPT_U64
71 #undef OPTION_OPT_UUID
72 #undef OPTION
73 #undef SAFE_OPTION
74
75 public:
76 enum set_value_result_t {
77 SET_NO_CHANGE,
78 SET_NO_EFFECT,
79 SET_HAVE_EFFECT,
80 };
81 /**
82 * @return true if changed, false otherwise
83 */
84 set_value_result_t set_value(std::string_view key,
85 Option::value_t&& value,
86 int level);
87 int rm_val(const std::string_view key, int level);
88 void set_logging(int which, const char* val);
89 /**
90 * @param level the level of the setting, -1 for the one with the
91 * highest-priority
92 */
93 std::pair<Option::value_t, bool> get_value(const std::string_view name,
94 int level) const;
95 template<typename Func> void for_each(Func&& func) const {
(1) Event no_user_defined_conversion: |
no suitable user-defined conversion from "const std::string_view" to "const std::__tuple_element_t<1UL, std::pair<const std::string_view, std::map<int32_t, Option::value_t, std::less<int>, std::allocator<std::pair<const int32_t, Option::value_t>>>>>" exists |
(2) Event caretline: |
^ |
Also see events: |
[det_during_template_instantiation_context] |
96 for (const auto& [name,configs] : values) {
97 func(name, configs);
98 }
99 }
100 bool contains(const std::string_view key) const;
101 };
102