MarlinMT  0.1.0
marlinmt::ConfigSection Class Reference

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
 
ConfigSectionoperator= (const ConfigSection &)=default
 
 ConfigSection (ConfigSection &&)=default
 
ConfigSectionoperator= (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 ParameterMapparameters () const
 Get the raw parameter storage. More...
 
Sections
ConfigSectionsection (const std::string &n)
 Get a subsection by name. More...
 
const ConfigSectionsection (const std::string &n) const
 Get a subsection by name (const version). More...
 
ConfigSectionaddSection (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 >
ConfigSectionsetParameter (const std::string &n, const T &val)
 Set a parameter value. More...
 
template<typename T >
parameter (const std::string &n) const
 Get a parameter value as type T. More...
 
template<typename 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 Metadatametadata () const
 Get the section metadata. More...
 
Metadatametadata ()
 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...
 

Detailed Description

ConfigSection class Holds a set of parameters and subsection.

Definition at line 20 of file Configuration.h.

Member Typedef Documentation

◆ ConfigSectionMap

Definition at line 22 of file Configuration.h.

◆ Metadata

using marlinmt::ConfigSection::Metadata = std::map<std::string, std::string>

Definition at line 24 of file Configuration.h.

◆ ParameterMap

using marlinmt::ConfigSection::ParameterMap = std::map<std::string, std::string>

Definition at line 23 of file Configuration.h.

Constructor & Destructor Documentation

◆ ConfigSection() [1/3]

marlinmt::ConfigSection::ConfigSection ( const ConfigSection )
default

◆ ConfigSection() [2/3]

marlinmt::ConfigSection::ConfigSection ( ConfigSection &&  )
default

◆ ConfigSection() [3/3]

marlinmt::ConfigSection::ConfigSection ( const std::string &  name)

Constructor with name.

Parameters
namethe section name

Definition at line 12 of file Configuration.cc.

Member Function Documentation

◆ addSection()

ConfigSection & marlinmt::ConfigSection::addSection ( const std::string &  n)

Create a new subsection.

Throws if already exists

Parameters
nthe subsection name

Definition at line 51 of file Configuration.cc.

References _subsections, MARLINMT_THROW, and name().

◆ empty()

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.

◆ hasParameter()

bool marlinmt::ConfigSection::hasParameter ( const std::string &  n) const

Whether the parameter exists.

Parameters
nthe parameter name

Definition at line 75 of file Configuration.cc.

References _parameters.

Referenced by marlinmt::SuperSequence::addProcessor(), and parameter().

◆ hasSection()

bool marlinmt::ConfigSection::hasSection ( const std::string &  n) const

Whether the subsection exists.

Parameters
nthe subsection name

Definition at line 61 of file Configuration.cc.

References _subsections.

Referenced by marlinmt::Configuration::addConstant().

◆ loadParameters()

void marlinmt::ConfigSection::loadParameters ( Configurable cfg) const

Load the parameters of the current section in the configurable object.

Parameters
cfgthe configurable object

Referenced by parameter().

◆ metadata() [1/2]

const ConfigSection::Metadata & marlinmt::ConfigSection::metadata ( ) const

◆ metadata() [2/2]

ConfigSection::Metadata & marlinmt::ConfigSection::metadata ( )

Get the section metadata.

Definition at line 101 of file Configuration.cc.

References _metadata.

◆ name()

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().

◆ operator=() [1/2]

ConfigSection& marlinmt::ConfigSection::operator= ( const ConfigSection )
default

◆ operator=() [2/2]

ConfigSection& marlinmt::ConfigSection::operator= ( ConfigSection &&  )
default

◆ parameter() [1/2]

template<typename T >
T marlinmt::ConfigSection::parameter ( const std::string &  n) const
inline

◆ parameter() [2/2]

template<typename T >
T marlinmt::ConfigSection::parameter ( const std::string &  n,
const T &  defVal 
) const
inline

Get a parameter value as type T.

Return the default value if the parameter doesn't exist

Parameters
nthe parameter name
defValthe defult value

Definition at line 125 of file Configuration.h.

References _parameters, marlinmt::details::convert< T >::from_string(), hasParameter(), loadParameters(), metadata(), parameterNames(), and parameters().

◆ parameterNames()

std::vector< std::string > marlinmt::ConfigSection::parameterNames ( ) const

◆ parameters()

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().

◆ section() [1/2]

ConfigSection & marlinmt::ConfigSection::section ( const std::string &  n)

Get a subsection by name.

Throws if not found

Parameters
nthe 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().

◆ section() [2/2]

const ConfigSection & marlinmt::ConfigSection::section ( const std::string &  n) const

Get a subsection by name (const version).

Throws if not found

Parameters
nthe subsection name

Definition at line 41 of file Configuration.cc.

References _subsections, MARLINMT_THROW, and name().

◆ setParameter()

template<typename T >
ConfigSection& marlinmt::ConfigSection::setParameter ( const std::string &  n,
const T &  val 
)
inline

Set a parameter value.

If the parameter exists it is replaced

Parameters
nthe parameter name
valthe parameter value

Definition at line 97 of file Configuration.h.

References _parameters.

Referenced by marlinmt::Application::dumpExampleConfig(), marlinmt::Component::getParameters(), and marlinmt::XMLConfigReader::parametersFromXMLElement().

◆ subsectionNames()

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().

Member Data Documentation

◆ _metadata

Metadata marlinmt::ConfigSection::_metadata {}
private

The section metdata map.

Definition at line 174 of file Configuration.h.

Referenced by metadata().

◆ _name

const std::string marlinmt::ConfigSection::_name
private

The section name.

Definition at line 176 of file Configuration.h.

Referenced by name().

◆ _parameters

ParameterMap marlinmt::ConfigSection::_parameters {}
private

The parameter map.

Definition at line 172 of file Configuration.h.

Referenced by empty(), hasParameter(), parameter(), parameterNames(), parameters(), and setParameter().

◆ _subsections

ConfigSectionMap marlinmt::ConfigSection::_subsections {}
private

The subsection map.

Definition at line 170 of file Configuration.h.

Referenced by addSection(), empty(), hasSection(), section(), and subsectionNames().


The documentation for this class was generated from the following files: