From f1ac8dc7a4632b786a50da089fb62d547aa92116 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 5 Jul 2017 09:12:46 -0400 Subject: [PATCH] common: hook in 'safe' flag to new config options It's a poor substitute for real a concurrency solution but for the moment carry it forward so that the options structure can replace the list of config_option in md_config_t. Signed-off-by: John Spray --- src/common/config.h | 5 +++++ src/common/options.h | 19 ++++++++++++++++++- src/convert.cc | 8 +++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/common/config.h b/src/common/config.h index 0f8f8b1a0f3..7aa9917982a 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -301,6 +301,11 @@ public: /// cluster name string cluster; +// 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) const int name; #define OPTION_OPT_LONGLONG(name) const long long name; #define OPTION_OPT_STR(name) const std::string name; diff --git a/src/common/options.h b/src/common/options.h index 1a1de197904..92af1684ecf 100644 --- a/src/common/options.h +++ b/src/common/options.h @@ -62,8 +62,10 @@ struct Option { value_t min, max; std::list enum_allowed; + bool safe; + Option(const char* name, type_t t, level_t l) - : name(name), type(t), level(l) + : name(name), type(t), level(l), safe(false) {} // bool is an integer, but we don't think so. teach it the hard way. @@ -117,6 +119,21 @@ struct Option { max = ma; return *this; } + + Option &set_safe() { + safe = true; + return *this; + } + + /** + * A crude indicator of whether the value may be + * modified safely at runtime -- should be replaced + * with proper locking! + */ + bool is_safe() const + { + return type == TYPE_INT || type == TYPE_FLOAT; + } }; extern const std::vector