From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/common/config_values.h | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/common/config_values.h (limited to 'src/common/config_values.h') diff --git a/src/common/config_values.h b/src/common/config_values.h new file mode 100644 index 000000000..5cf79eee6 --- /dev/null +++ b/src/common/config_values.h @@ -0,0 +1,100 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- + +#pragma once + +#include +#include +#include +#include +#include + +#include "common/entity_name.h" +#include "common/options.h" +#include "log/SubsystemMap.h" +#include "msg/msg_types.h" + +// @c ConfigValues keeps track of mappings from the config names to their values, +// debug logging settings, and some other "unnamed" settings, like entity name of +// the daemon. +class ConfigValues { + using values_t = std::map>; + values_t values; + // for populating md_config_impl::legacy_values in ctor + friend struct md_config_t; + +public: + EntityName name; + /// cluster name + std::string cluster; + ceph::logging::SubsystemMap subsys; + bool no_mon_config = false; + // Set of configuration options that have changed since the last + // apply_changes + using changed_set_t = std::set; + changed_set_t changed; + +// This macro block defines C members of the md_config_t struct +// corresponding to the definitions in legacy_config_opts.h. +// These C members are consumed by code that was written before +// the new options.cc infrastructure: all newer code should +// be consume options via explicit get() rather than C members. +#define OPTION_OPT_INT(name) int64_t name; +#define OPTION_OPT_LONGLONG(name) int64_t name; +#define OPTION_OPT_STR(name) std::string name; +#define OPTION_OPT_DOUBLE(name) double name; +#define OPTION_OPT_FLOAT(name) double name; +#define OPTION_OPT_BOOL(name) bool name; +#define OPTION_OPT_ADDR(name) entity_addr_t name; +#define OPTION_OPT_ADDRVEC(name) entity_addrvec_t name; +#define OPTION_OPT_U32(name) uint64_t name; +#define OPTION_OPT_U64(name) uint64_t name; +#define OPTION_OPT_UUID(name) uuid_d name; +#define OPTION_OPT_SIZE(name) uint64_t name; +#define OPTION(name, ty) \ + public: \ + OPTION_##ty(name) +#define SAFE_OPTION(name, ty) \ + protected: \ + OPTION_##ty(name) +#include "common/legacy_config_opts.h" +#undef OPTION_OPT_INT +#undef OPTION_OPT_LONGLONG +#undef OPTION_OPT_STR +#undef OPTION_OPT_DOUBLE +#undef OPTION_OPT_FLOAT +#undef OPTION_OPT_BOOL +#undef OPTION_OPT_ADDR +#undef OPTION_OPT_ADDRVEC +#undef OPTION_OPT_U32 +#undef OPTION_OPT_U64 +#undef OPTION_OPT_UUID +#undef OPTION +#undef SAFE_OPTION + +public: + enum set_value_result_t { + SET_NO_CHANGE, + SET_NO_EFFECT, + SET_HAVE_EFFECT, + }; + /** + * @return true if changed, false otherwise + */ + set_value_result_t set_value(std::string_view key, + Option::value_t&& value, + int level); + int rm_val(const std::string_view key, int level); + void set_logging(int which, const char* val); + /** + * @param level the level of the setting, -1 for the one with the + * highest-priority + */ + std::pair get_value(const std::string_view name, + int level) const; + template void for_each(Func&& func) const { + for (const auto& [name,configs] : values) { + func(name, configs); + } + } + bool contains(const std::string_view key) const; +}; -- cgit v1.2.3