MarlinMT  0.1.0
marlinmt::Configurable Class Reference

Configurable class Interface for configuring components in the framework. More...

#include <Parameter.h>

Inherited by marlinmt::Component.

Public Types

using ParameterMap = std::map< std::string, std::shared_ptr< ParameterImpl > >
 
using iterator = ParameterMap::iterator
 
using const_iterator = ParameterMap::const_iterator
 

Public Member Functions

 Configurable ()=default
 
virtual ~Configurable ()=default
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value)
 Add a parameter. More...
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value, T defVal)
 Add a parameter. More...
 
template<typename T >
parameter (const std::string &name) const
 Get a parameter value. More...
 
template<typename T >
parameter (const std::string &name, const T &fallback) const
 Get a parameter value. More...
 
void checkParameter (const std::string &name) const
 Check if the parameter has been registered. More...
 
bool exists (const std::string &name) const
 Return true if the parameter has been registered. More...
 
bool isSet (const std::string &name) const
 Returns true if the parameter exists and is set, false otherwise. More...
 
void clear ()
 Remove all parameters. More...
 
void unset ()
 Unset all registered parameters. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Protected Attributes

ParameterMap _parameters {}
 The parameter map. More...
 

Detailed Description

Configurable class Interface for configuring components in the framework.

Definition at line 312 of file Parameter.h.

Member Typedef Documentation

◆ const_iterator

using marlinmt::Configurable::const_iterator = ParameterMap::const_iterator

Definition at line 319 of file Parameter.h.

◆ iterator

using marlinmt::Configurable::iterator = ParameterMap::iterator

Definition at line 318 of file Parameter.h.

◆ ParameterMap

using marlinmt::Configurable::ParameterMap = std::map<std::string, std::shared_ptr<ParameterImpl> >

Definition at line 317 of file Parameter.h.

Constructor & Destructor Documentation

◆ Configurable()

marlinmt::Configurable::Configurable ( )
default

◆ ~Configurable()

virtual marlinmt::Configurable::~Configurable ( )
virtualdefault

Member Function Documentation

◆ addParameter() [1/2]

template<typename T >
std::shared_ptr<ParameterImpl> marlinmt::Configurable::addParameter ( EParameterType  paramType,
const std::string &  name,
const std::string &  desc,
std::shared_ptr< T >  value 
)
inline

Add a parameter.

Throw if already exists.

Parameters
paramTypethe parameter type
namethe parameter name
descthe parameter description
valuethe address to the parameter value

Definition at line 330 of file Parameter.h.

References marlinmt::book::Flags::value().

Referenced by marlinmt::ParameterBase< bool >::ParameterBase().

◆ addParameter() [2/2]

template<typename T >
std::shared_ptr<ParameterImpl> marlinmt::Configurable::addParameter ( EParameterType  paramType,
const std::string &  name,
const std::string &  desc,
std::shared_ptr< T >  value,
defVal 
)
inline

Add a parameter.

Throw if already exists.

Parameters
paramTypethe parameter type
namethe parameter name
descthe parameter description
valuethe address to the parameter value
defValthe default parameter value

Definition at line 347 of file Parameter.h.

References marlinmt::book::Flags::value().

◆ begin() [1/2]

Configurable::iterator marlinmt::Configurable::begin ( )

Definition at line 113 of file Parameter.cc.

◆ begin() [2/2]

Configurable::const_iterator marlinmt::Configurable::begin ( ) const

Definition at line 119 of file Parameter.cc.

◆ checkParameter()

void marlinmt::Configurable::checkParameter ( const std::string &  name) const

Check if the parameter has been registered.

Parameters
namethe parameter name to check

Definition at line 77 of file Parameter.cc.

References MARLINMT_THROW.

◆ clear()

void marlinmt::Configurable::clear ( )

Remove all parameters.

Definition at line 101 of file Parameter.cc.

◆ end() [1/2]

Configurable::iterator marlinmt::Configurable::end ( )

Definition at line 125 of file Parameter.cc.

◆ end() [2/2]

Configurable::const_iterator marlinmt::Configurable::end ( ) const

Definition at line 131 of file Parameter.cc.

◆ exists()

bool marlinmt::Configurable::exists ( const std::string &  name) const

Return true if the parameter has been registered.

Parameters
namethe parameter name to check

Definition at line 85 of file Parameter.cc.

◆ isSet()

bool marlinmt::Configurable::isSet ( const std::string &  name) const

Returns true if the parameter exists and is set, false otherwise.

Parameters
namethe parameter name to check

Definition at line 91 of file Parameter.cc.

◆ parameter() [1/2]

template<typename T >
T marlinmt::Configurable::parameter ( const std::string &  name) const
inline

Get a parameter value.

Parameters
namethe parameter name to get

Definition at line 360 of file Parameter.h.

◆ parameter() [2/2]

template<typename T >
T marlinmt::Configurable::parameter ( const std::string &  name,
const T &  fallback 
) const
inline

Get a parameter value.

Returns the fallback value if the parameter is not set. Throw an exception if the parameter is not registered

Parameters
namethe parameter name
fallbackthe fallback value if the parameter is not set

Definition at line 373 of file Parameter.h.

◆ unset()

void marlinmt::Configurable::unset ( )

Unset all registered parameters.

Definition at line 107 of file Parameter.cc.

Member Data Documentation

◆ _parameters

ParameterMap marlinmt::Configurable::_parameters {}
protected

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