1 #ifndef MHO_ParameterStore_HH__
2 #define MHO_ParameterStore_HH__
66 void Dump() { std::cout << fStore.dump(2) << std::endl; }
102 template<
typename XValueType >
bool Set(
const std::string& value_path,
const XValueType&
value);
113 template<
typename XValueType >
bool Get(
const std::string& value_path, XValueType&
value)
const;
130 template<
typename XValueType > XValueType
GetAs(
const std::string& value_path)
const;
134 std::string path = SanitizePath(value_path);
140 for(
auto it = fPath.begin(); it != fPath.end(); it++)
142 auto jit = p->find(*it);
147 else if(*it == *(fPath.rbegin()))
168 std::string SanitizePath(
const std::string& value_path)
const
171 if(vpath.size() > 0 && vpath.back() ==
'/')
179 mutable MHO_Tokenizer fTokenizer;
180 mutable std::vector< std::string > fPath;
196 std::string path = SanitizePath(value_path);
206 for(
auto it = fPath.begin(); it != fPath.end(); it++)
208 if(*it != *(fPath.rbegin()))
242 std::string path = SanitizePath(value_path);
247 bool present =
false;
249 for(
auto it = fPath.begin(); it != fPath.end(); it++)
251 auto jit = p->find(*it);
256 else if(*it == *(fPath.rbegin()))
258 value = jit->get< XValueType >();
277 XValueType v = XValueType();
278 bool ok =
Get(value_path, v);
281 msg_error(
"utility",
"failed to retrieve value: " << value_path <<
" returning a default value." << eom);
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
Class MHO_ParameterStore.
Definition: MHO_ParameterStore.hh:52
~MHO_ParameterStore()
Definition: MHO_ParameterStore.hh:61
bool Set(const std::string &value_path, const XValueType &value)
Setter for value at specified path in the parameter store.
Definition: MHO_ParameterStore.hh:193
void Dump()
Dumps the store JSON data to std:cout (for debugging)
Definition: MHO_ParameterStore.hh:66
void ClearData()
Clears all data from fStore.
Definition: MHO_ParameterStore.hh:92
void FillData(const mho_json &data)
Stores input json data for later use.
Definition: MHO_ParameterStore.hh:87
MHO_ParameterStore()
Definition: MHO_ParameterStore.hh:54
void DumpData(mho_json &data)
Copies data from internal storage to provided json object.
Definition: MHO_ParameterStore.hh:80
XValueType GetAs(const std::string &value_path) const
Function IsPresent.
Definition: MHO_ParameterStore.hh:275
bool Get(const std::string &value_path, XValueType &value) const
Retrieves a value by path and returns it as XValueType, using default constructor if not found.
Definition: MHO_ParameterStore.hh:238
bool IsPresent(const std::string &value_path) const
Definition: MHO_ParameterStore.hh:132
void CopyFrom(const MHO_ParameterStore ©)
Copies the parameter store from a given source.
Definition: MHO_ParameterStore.hh:73
void SetIncludeEmptyTokensFalse()
Definition: MHO_Tokenizer.cc:30
void SetString(const std::string *aString)
Definition: MHO_Tokenizer.cc:65
void GetTokens(std::vector< std::string > *tokens)
Definition: MHO_Tokenizer.cc:75
static std::string TrimLeadingAndTrailingWhitespace(const std::string &value)
Definition: MHO_Tokenizer.cc:278
void SetRemoveLeadingTrailingWhitespaceTrue()
Setter for remove leading trailing whitespace true.
Definition: MHO_Tokenizer.cc:55
void SetDelimiter(const std::string &aDelim)
Definition: MHO_Tokenizer.cc:70
Definition: MHO_ChannelLabeler.hh:17