34#define TheBESKeys_h_ 1
44#define DYNAMIC_CONFIG_KEY "DynamicConfig"
45#define DC_REGEX_KEY "regex"
46#define DC_CONFIG_KEY "config"
47#define DYNAMIC_CONFIG_ENABLED 0
96 std::string d_keys_file_name;
97 std::map<std::string, std::vector<std::string> > *d_the_keys;
98 std::map<std::string, std::vector<std::string> > *d_the_original_keys;
99 bool d_dynamic_config_in_use;
102 static std::set<std::string> d_ingested_key_files;
104 static bool LoadedKeys(
const std::string &key_file);
108 void initialize_keys();
109 static void initialize_instance();
110 static void delete_instance();
122 TheBESKeys() : d_keys_file_name(
""), d_the_keys(0), d_dynamic_config_in_use(
false), d_own_keys(
false) {
126 TheBESKeys(
const std::string &keys_file_name, std::map<std::string, std::vector<std::string> > *keys);
130 TheBESKeys(
const std::string &keys_file_name);
137 std::string keys_file_name()
const {
138 return d_keys_file_name;
141 void set_key(
const std::string &key,
const std::string &val,
bool addto =
false);
143 void set_key(
const std::string &pair);
145 void set_keys(
const std::string &key,
const std::vector<std::string> &values,
bool addto);
147 void set_keys(
const std::string &key,
const std::map<std::string, std::string> &values,
148 const bool case_insensitive_map_keys,
bool addto);
150 void get_value(
const std::string &s, std::string &val,
bool &found);
152 void get_values(
const std::string &s, std::vector<std::string> &vals,
bool &found);
154 void get_values(
const std::string &, std::map<std::string, std::string> &map_values,
155 const bool &case_insensitive_map_keys,
bool &found);
157 void get_values(
const std::string &, std::map<std::string, std::map<std::string, std::vector<std::string> > > &map,
158 const bool &case_insensitive_map_keys,
bool &found);
161 bool read_bool_key(
const std::string &key,
bool default_value);
163 std::string
read_string_key(
const std::string &key,
const std::string &default_value);
165 int read_int_key(
const std::string &key,
int default_value);
167 typedef std::map<std::string, std::vector<std::string> >::const_iterator Keys_citer;
169 Keys_citer keys_begin() {
170 return d_the_keys->begin();
173 Keys_citer keys_end() {
174 return d_the_keys->end();
177 virtual void dump(std::ostream &strm)
const;
178 virtual std::string
dump()
const;
180 std::string get_as_config()
const;
193 bool using_dynamic_config();
top level BES object to house generic methods
mapping of key/value pairs defining different behaviors of an application.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()
void set_key(const std::string &key, const std::string &val, bool addto=false)
allows the user to set key/value pairs from within the application.
int read_int_key(const std::string &key, int default_value)
Read an integer-valued key from the bes.conf file.
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.
void load_dynamic_config(std::string name)
Loads the the applicable dynamic configuration or nothing if no configuration is applicable.
virtual std::string dump() const
dumps information about this object
static std::string ConfigFile
bool read_bool_key(const std::string &key, bool default_value)
Read a boolean-valued key from the bes.conf file.
std::string read_string_key(const std::string &key, const std::string &default_value)
Read a string-valued key from the bes.conf file.
void set_keys(const std::string &key, const std::vector< std::string > &values, bool addto)
allows the user to set key/value pairs from within the application.
virtual ~TheBESKeys()
cleans up the key/value pair mapping