24 using Metadata = std::map<std::string, std::string> ;
43 const std::string &
name()
const ;
79 bool hasSection(
const std::string &n )
const ;
108 template <
typename T>
124 template <
typename T>
125 inline T
parameter(
const std::string &n,
const T &defVal )
const {
209 template <
typename T>
211 auto iter = _constants.find( cn ) ;
212 if( iter == _constants.end() ) {
225 template <
typename T>
226 T
constantAs(
const std::string &cn,
const T &defVal )
const {
227 auto iter = _constants.find( cn ) ;
228 if( iter == _constants.end() ) {
241 template <
typename T>
243 auto iter = _constants.find( cn ) ;
244 if( iter != _constants.end() ) {
245 MARLINMT_THROW(
"Constant '" + cn +
"' already present in configuration" ) ;
254 bool hasConstant(
const std::string &cn )
const ;
289 std::vector<std::string> sections()
const ;
296 bool hasSection(
const std::string &n )
const ;
308 void replaceConstants( std::string& str )
const ;
340 virtual void init(
const std::string &desc ) = 0 ;
369 virtual void init(
const std::string &desc ) = 0 ;
401 static std::pair<std::string, std::string> splitPluginInput(
const std::string &str ) ;
409 static void readConfig(
const std::string &str,
Configuration &cfg ) ;
417 static void writeConfig(
const std::string &str,
Configuration &cfg ) ;
const Metadata & metadata() const
Get the section metadata.
ConfigSection(const ConfigSection &)=default
ConfigSection & section(const std::string &n)
Get a subsection by name.
T parameter(const std::string &n) const
Get a parameter value as type T.
Configurable class Interface for configuring components in the framework.
ConfigSection::ConfigSectionMap ConfigSectionMap
const std::string & name() const
Get the section name.
std::vector< std::string > parameterNames() const
Get the list of parameter names.
std::ostream & operator<<(std::ostream &stream, const Configuration &cfg)
Stream operator.
std::map< std::string, std::string > ParameterMap
bool hasSection(const std::string &n) const
Whether the subsection exists.
std::map< std::string, std::string > ConstantsMap
std::map< std::string, ConfigSection > ConfigSectionMap
Metadata _metadata
The section metdata map.
T constantAs(const std::string &cn) const
Get a constant value as type T.
std::map< std::string, std::string > Metadata
Configuration & addConstant(const std::string &cn, const T &val)
Add a constant.
T constantAs(const std::string &cn, const T &defVal) const
Get a constant value as type T.
ConfigReader base class Interface for reading configuration.
const std::string _name
The section name.
bool empty() const
Whether the section is empty (no parameter, no subsection)
bool hasParameter(const std::string &n) const
Whether the parameter exists.
#define MARLINMT_THROW(message)
static T from_string(const std::string &str)
ConfigSection & addSection(const std::string &n)
Create a new subsection.
T parameter(const std::string &n, const T &defVal) const
Get a parameter value as type T.
ParameterMap _parameters
The parameter map.
ConfigWriter base class Interface for writing configuration.
std::vector< std::string > subsectionNames() const
Get the list of subsection names.
ConfigSectionMap _subsections
The subsection map.
ConfigSection & setParameter(const std::string &n, const T &val)
Set a parameter value.
ConfigSection & operator=(const ConfigSection &)=default
const ParameterMap & parameters() const
Get the raw parameter storage.
ConfigSection class Holds a set of parameters and subsection.
ConfigHelper class A simple class with helper methods for configuration.
void loadParameters(Configurable &cfg) const
Load the parameters of the current section in the configurable object.