MarlinMT
0.1.0
|
ConfigSection class Holds a set of parameters and subsection. More...
#include <Configuration.h>
Public Types | |
using | ConfigSectionMap = std::map< std::string, ConfigSection > |
using | ParameterMap = std::map< std::string, std::string > |
using | Metadata = std::map< std::string, std::string > |
Public Member Functions | |
ConfigSection (const ConfigSection &)=default | |
ConfigSection & | operator= (const ConfigSection &)=default |
ConfigSection (ConfigSection &&)=default | |
ConfigSection & | operator= (ConfigSection &&)=default |
ConfigSection (const std::string &name) | |
Constructor with name. More... | |
const std::string & | name () const |
Get the section name. More... | |
bool | empty () const |
Whether the section is empty (no parameter, no subsection) More... | |
void | loadParameters (Configurable &cfg) const |
Load the parameters of the current section in the configurable object. More... | |
const ParameterMap & | parameters () const |
Get the raw parameter storage. More... | |
Sections | |
ConfigSection & | section (const std::string &n) |
Get a subsection by name. More... | |
const ConfigSection & | section (const std::string &n) const |
Get a subsection by name (const version). More... | |
ConfigSection & | addSection (const std::string &n) |
Create a new subsection. More... | |
bool | hasSection (const std::string &n) const |
Whether the subsection exists. More... | |
std::vector< std::string > | subsectionNames () const |
Get the list of subsection names. More... | |
Parameters | |
template<typename T > | |
ConfigSection & | setParameter (const std::string &n, const T &val) |
Set a parameter value. More... | |
template<typename T > | |
T | parameter (const std::string &n) const |
Get a parameter value as type T. More... | |
template<typename T > | |
T | parameter (const std::string &n, const T &defVal) const |
Get a parameter value as type T. More... | |
bool | hasParameter (const std::string &n) const |
Whether the parameter exists. More... | |
std::vector< std::string > | parameterNames () const |
Get the list of parameter names. More... | |
const Metadata & | metadata () const |
Get the section metadata. More... | |
Metadata & | metadata () |
Get the section metadata. More... | |
Private Attributes | |
ConfigSectionMap | _subsections {} |
The subsection map. More... | |
ParameterMap | _parameters {} |
The parameter map. More... | |
Metadata | _metadata {} |
The section metdata map. More... | |
const std::string | _name |
The section name. More... | |
ConfigSection class Holds a set of parameters and subsection.
Definition at line 20 of file Configuration.h.
using marlinmt::ConfigSection::ConfigSectionMap = std::map<std::string, ConfigSection> |
Definition at line 22 of file Configuration.h.
using marlinmt::ConfigSection::Metadata = std::map<std::string, std::string> |
Definition at line 24 of file Configuration.h.
using marlinmt::ConfigSection::ParameterMap = std::map<std::string, std::string> |
Definition at line 23 of file Configuration.h.
|
default |
|
default |
marlinmt::ConfigSection::ConfigSection | ( | const std::string & | name | ) |
Constructor with name.
name | the section name |
Definition at line 12 of file Configuration.cc.
ConfigSection & marlinmt::ConfigSection::addSection | ( | const std::string & | n | ) |
Create a new subsection.
Throws if already exists
n | the subsection name |
Definition at line 51 of file Configuration.cc.
References _subsections, MARLINMT_THROW, and name().
bool marlinmt::ConfigSection::empty | ( | ) | const |
Whether the section is empty (no parameter, no subsection)
Definition at line 25 of file Configuration.cc.
References _parameters, and _subsections.
bool marlinmt::ConfigSection::hasParameter | ( | const std::string & | n | ) | const |
Whether the parameter exists.
n | the parameter name |
Definition at line 75 of file Configuration.cc.
References _parameters.
Referenced by marlinmt::SuperSequence::addProcessor(), and parameter().
bool marlinmt::ConfigSection::hasSection | ( | const std::string & | n | ) | const |
Whether the subsection exists.
n | the subsection name |
Definition at line 61 of file Configuration.cc.
References _subsections.
Referenced by marlinmt::Configuration::addConstant().
void marlinmt::ConfigSection::loadParameters | ( | Configurable & | cfg | ) | const |
Load the parameters of the current section in the configurable object.
cfg | the configurable object |
Referenced by parameter().
const ConfigSection::Metadata & marlinmt::ConfigSection::metadata | ( | ) | const |
Get the section metadata.
Definition at line 95 of file Configuration.cc.
References _metadata.
Referenced by marlinmt::XMLConfigWriter::appendDescription(), marlinmt::XMLConfigWriter::createParameterSection(), marlinmt::Component::getParameters(), and parameter().
ConfigSection::Metadata & marlinmt::ConfigSection::metadata | ( | ) |
const std::string & marlinmt::ConfigSection::name | ( | ) | const |
Get the section name.
Definition at line 19 of file Configuration.cc.
References _name.
Referenced by addSection(), parameter(), marlinmt::printSection(), section(), and marlinmt::Component::setParameters().
|
default |
|
default |
|
inline |
Get a parameter value as type T.
Throw if the parameter doesn't exist
n | the parameter name |
Definition at line 109 of file Configuration.h.
References _parameters, marlinmt::details::convert< T >::from_string(), MARLINMT_THROW, and name().
Referenced by marlinmt::SuperSequence::addProcessor(), marlinmt::XMLConfigWriter::createParameterSection(), marlinmt::XMLConfigReader::getReplacementParameter(), marlinmt::printSection(), marlinmt::Component::setParameters(), and marlinmt::XMLConfigWriter::write().
|
inline |
Get a parameter value as type T.
Return the default value if the parameter doesn't exist
n | the parameter name |
defVal | the defult value |
Definition at line 125 of file Configuration.h.
References _parameters, marlinmt::details::convert< T >::from_string(), hasParameter(), loadParameters(), metadata(), parameterNames(), and parameters().
std::vector< std::string > marlinmt::ConfigSection::parameterNames | ( | ) | const |
Get the list of parameter names.
Definition at line 81 of file Configuration.cc.
References _parameters.
Referenced by marlinmt::concurrency::PEPScheduler::configureProcessors(), marlinmt::SimpleScheduler::initialize(), parameter(), marlinmt::printSection(), and marlinmt::Component::setParameters().
const ConfigSection::ParameterMap & marlinmt::ConfigSection::parameters | ( | ) | const |
Get the raw parameter storage.
Definition at line 89 of file Configuration.cc.
References _parameters.
Referenced by marlinmt::XMLConfigWriter::createParameterSection(), parameter(), and marlinmt::XMLConfigWriter::write().
ConfigSection & marlinmt::ConfigSection::section | ( | const std::string & | n | ) |
Get a subsection by name.
Throws if not found
n | the subsection name |
Definition at line 31 of file Configuration.cc.
References _subsections, MARLINMT_THROW, and name().
Referenced by marlinmt::Configuration::addConstant(), marlinmt::XMLConfigReader::getReplacementParameter(), marlinmt::SimpleScheduler::initialize(), and marlinmt::printSection().
const ConfigSection & marlinmt::ConfigSection::section | ( | const std::string & | n | ) | const |
Get a subsection by name (const version).
Throws if not found
n | the subsection name |
Definition at line 41 of file Configuration.cc.
References _subsections, MARLINMT_THROW, and name().
|
inline |
Set a parameter value.
If the parameter exists it is replaced
n | the parameter name |
val | the parameter value |
Definition at line 97 of file Configuration.h.
References _parameters.
Referenced by marlinmt::Application::dumpExampleConfig(), marlinmt::Component::getParameters(), and marlinmt::XMLConfigReader::parametersFromXMLElement().
std::vector< std::string > marlinmt::ConfigSection::subsectionNames | ( | ) | const |
Get the list of subsection names.
Definition at line 67 of file Configuration.cc.
References _subsections.
Referenced by marlinmt::printSection(), and marlinmt::XMLConfigWriter::write().
|
private |
|
private |
|
private |
The parameter map.
Definition at line 172 of file Configuration.h.
Referenced by empty(), hasParameter(), parameter(), parameterNames(), parameters(), and setParameter().
|
private |
The subsection map.
Definition at line 170 of file Configuration.h.
Referenced by addSection(), empty(), hasSection(), section(), and subsectionNames().