5 #ifndef IWF_CTD_FILE_PARAMETER_SET_HPP_
6 #define IWF_CTD_FILE_PARAMETER_SET_HPP_
8 #include "ctd/defines/defines.hpp"
9 #include "ctd/file/Parameter.hpp"
31 virtual void Load(
const std::string& filename,
32 const bool merge =
false);
42 virtual void LoadUser(
const std::string& filename,
43 const bool merge =
false);
46 void Store(
const std::string& par_name,
47 const std::string&
value,
48 const std::string& comment =
"");
52 const bool exception =
false)
const;
57 const bool exception =
false)
const {
61 if (
HasPar(name, tmpPar)) {
65 throw rad::Exception(
"Undefined parameter name: %s", name.c_str());
77 bool HasPar(
const std::string& par_name)
const;
80 bool HasPar(
const std::string& par_name,
84 template <
class TYPE>
bool HasPar(
const std::string& par_name,
89 if (
HasPar(par_name, tmpPar)) {
98 uint32_t
Scan(
const std::string& filter_reg_exp,
102 std::string
Print(
const std::string& filter_reg_exp =
"")
const;
108 const std::map<std::string, ctd::file::Parameter>&
GetParameterMap()
const;
118 std::map<std::string, ctd::file::Parameter>
m_par_map;
136 #endif // !IWF_CTD_FILE_PARAMETER_SET_HPP_
bool GetValue(const std::string &name, TYPE &value, const bool exception=false) const
Return value for the referenced parameter as its native data type.
Definition: ParameterSet.hpp:55
double value
Definition: easylogging++.h:814
void Store(const std::string &par_name, const std::string &value, const std::string &comment="")
Store a parameter name, value and possibly comment in the object.
Definition: ParameterSet.cpp:135
std::string GetValueAsString(const std::string &par_name, const bool exception=false) const
Return value for the referenced parameter as a string.
Definition: ParameterSet.cpp:182
const std::string & GetProcFile() const
Return reference to file being processed (loaded).
Definition: ParameterSet.cpp:253
std::map< std::string, ctd::file::Parameter > m_par_map
Definition: ParameterSet.hpp:118
ctd::defines::List< std::string > m_loaded_files
Definition: ParameterSet.hpp:124
Class to handle information for one parameter.
Definition: Parameter.hpp:19
std::string m_proc_file
Definition: ParameterSet.hpp:121
const std::map< std::string, ctd::file::Parameter > & GetParameterMap() const
Return reference to the internal map with the names/parameter objects.
Definition: ParameterSet.cpp:260
bool HasPar(const std::string &par_name, TYPE &value) const
Return trie if parameter defined, sets the value as the native value.
Definition: ParameterSet.hpp:84
void _Copy(const ParameterSet &source)
Definition: ParameterSet.cpp:246
@ brief STL like list that can be indexed with []'s.
Definition: defines.hpp:262
uint32_t Scan(const std::string &filter_reg_exp, ctd::defines::List< ctd::file::Parameter > &matches) const
Scans through the parameter object namespace and creates list of matching parameters.
Definition: ParameterSet.cpp:196
bool HasPar(const std::string &par_name) const
Returns true if parameter is defined.
Definition: ParameterSet.cpp:147
ParameterSet()
Definition: ParameterSet.cpp:16
Definition: Exceptions.hpp:44
virtual void LoadUser(const std::string &filename, const bool merge=false)
Definition: ParameterSet.cpp:39
#define RAD_LOG_TRACE()
Definition: Logger.hpp:319
void GetValue(TYPE &value) const
Get parameter value as its native data type.
Definition: Parameter.hpp:55
const ctd::file::Parameter & GetPar(const std::string &par_name) const
Get reference to parameter object, referenced by its name.
Definition: ParameterSet.cpp:169
~ParameterSet()
Definition: ParameterSet.cpp:26
optional string name
Definition: topics.proto:50
Class to handle a set of parameters.
Definition: ParameterSet.hpp:17
ParameterSet & operator=(const ParameterSet &source)
Assignment operator.
Definition: ParameterSet.cpp:31
virtual void Load(const std::string &filename, const bool merge=false)
Load a file containing parameters.
Definition: ParameterSet.cpp:109
ctd::defines::List< std::string > ParNames() const
Returns list of parameter names.
Definition: ParameterSet.cpp:124
static std::string Print(ctd::defines::List< ctd::file::Parameter > &par_list)
Create an ASCII print out of the parameters in the list.
Definition: ParameterSet.cpp:210