MarlinMT
0.1.0
|
#include <Component.h>
Inherits marlinmt::Configurable.
Inherited by marlinmt::BookStoreManager, marlinmt::DataSourcePlugin, marlinmt::GeometryManager, marlinmt::GeometryPlugin, marlinmt::IScheduler, marlinmt::LoggerManager, and marlinmt::Processor.
Public Types | |
using | LoggerPtr = Logging::Logger |
Public Types inherited from marlinmt::Configurable | |
using | ParameterMap = std::map< std::string, std::shared_ptr< ParameterImpl > > |
using | iterator = ParameterMap::iterator |
using | const_iterator = ParameterMap::const_iterator |
Public Member Functions | |
Component ()=delete | |
No default constructor. More... | |
Component (const Component &)=delete | |
No copy or assignement. More... | |
Component & | operator= (const Component &)=delete |
virtual | ~Component ()=default |
Default destructor. More... | |
Component (const std::string &type) | |
Constructor with component type. More... | |
const std::string & | type () const |
Get the component name. More... | |
const std::string & | name () const |
Get the component name. More... | |
void | setName (const std::string &n) |
Set the component name. More... | |
const std::string & | description () const |
Get the component description. More... | |
void | setDescription (const std::string &desc) |
Set the component description. More... | |
virtual void | initialize () |
Initialize the component. More... | |
const Application & | application () const |
Get the application in which the component is registered. More... | |
Application & | application () |
Get the application in which the component is registered. More... | |
template<class T > | |
Logging::StreamType | log () const |
Log a message with specific log level. More... | |
Logging::StreamType | debug () const |
Shortcut for log<DEBUG>() More... | |
Logging::StreamType | message () const |
Shortcut for log<MESSAGE>() More... | |
Logging::StreamType | warning () const |
Shortcut for log<WARNING>() More... | |
Logging::StreamType | error () const |
Shortcut for log<ERROR>() More... | |
void | setVerbosity (const std::string &level) |
Set the verbosity level. More... | |
const std::string & | verbosity () const |
Get the verbosity level. More... | |
bool | isInitialized () const |
Whether the component has been initialized. More... | |
void | setup (Application *app) |
Setup the component. More... | |
void | printParameters () const |
Print the component parameters. More... | |
template<class T > | |
void | printParameters () const |
Print the component parameters at specific verbosity. More... | |
void | setParameters (const ConfigSection §ion, bool throwIfNotFound=false) |
Set the parameters from the configuration section. More... | |
void | getParameters (ConfigSection §ion, const std::set< std::string > &exclude={}) const |
Get the parameters from configurable object and populate the config section with. More... | |
Public Member Functions inherited from marlinmt::Configurable | |
Configurable ()=default | |
virtual | ~Configurable ()=default |
template<typename T > | |
std::shared_ptr< ParameterImpl > | addParameter (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< ParameterImpl > | addParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value, T defVal) |
Add a parameter. More... | |
template<typename T > | |
T | parameter (const std::string &name) const |
Get a parameter value. More... | |
template<typename T > | |
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 | |
std::string | _type {} |
The component type. More... | |
std::string | _name {} |
The component name. More... | |
std::string | _description {"No description"} |
The component description. More... | |
Application * | _application {nullptr} |
The application in which the component has been registered. More... | |
LoggerPtr | _logger {nullptr} |
The logger instance. More... | |
StringParameter | _verbosity { *this, "Verbosity", "The component verbosity level", "MESSAGE" } |
The verbosity level of the logger (parameter) More... | |
Protected Attributes inherited from marlinmt::Configurable | |
ParameterMap | _parameters {} |
The parameter map. More... | |
Friends | |
class | Application |
Component class.
Base class for all application components. Groups a few feature common too all application components:
Definition at line 22 of file Component.h.
Definition at line 25 of file Component.h.
|
delete |
No default constructor.
|
delete |
No copy or assignement.
|
virtualdefault |
Default destructor.
marlinmt::Component::Component | ( | const std::string & | type | ) |
Constructor with component type.
Definition at line 8 of file Component.cc.
References _logger, marlinmt::Logging::createLogger(), name(), and type().
const Application & marlinmt::Component::application | ( | ) | const |
Get the application in which the component is registered.
Definition at line 83 of file Component.cc.
References _application, and MARLINMT_THROW.
Referenced by marlinmt::BookStoreManager::bookHist(), marlinmt::ProcessorApi::Book::bookHist1D(), marlinmt::ProcessorApi::Book::bookHist1F(), marlinmt::ProcessorApi::Book::bookHist1I(), marlinmt::ProcessorApi::Book::bookHist2D(), marlinmt::ProcessorApi::Book::bookHist2F(), marlinmt::ProcessorApi::Book::bookHist2I(), marlinmt::ProcessorApi::Book::bookHist3D(), marlinmt::ProcessorApi::Book::bookHist3F(), marlinmt::ProcessorApi::Book::bookHist3I(), marlinmt::concurrency::PEPScheduler::configureProcessors(), marlinmt::ProcessorApi::Book::dontWrite(), marlinmt::ProcessorApi::geometry(), marlinmt::ProcessorApi::Book::getHist1D(), marlinmt::ProcessorApi::Book::getHist1F(), marlinmt::ProcessorApi::Book::getHist1I(), marlinmt::ProcessorApi::Book::getHist2D(), marlinmt::ProcessorApi::Book::getHist2F(), marlinmt::ProcessorApi::Book::getHist2I(), marlinmt::ProcessorApi::Book::getHist3D(), marlinmt::ProcessorApi::Book::getHist3F(), marlinmt::ProcessorApi::Book::getHist3I(), marlinmt::SimpleScheduler::initialize(), marlinmt::IScheduler::initialize(), marlinmt::LoggerManager::initialize(), marlinmt::BookStoreManager::initialize(), marlinmt::GeometryManager::initialize(), initialize(), marlinmt::GeometryPlugin::initialize(), marlinmt::DataSourcePlugin::initialize(), marlinmt::Processor::initialize(), marlinmt::concurrency::PEPScheduler::preConfigure(), marlinmt::ProcessorApi::registerForRandomSeeds(), setup(), and marlinmt::ProcessorApi::Book::write().
Application & marlinmt::Component::application | ( | ) |
Get the application in which the component is registered.
Definition at line 92 of file Component.cc.
References _application, and MARLINMT_THROW.
Logging::StreamType marlinmt::Component::debug | ( | ) | const |
const std::string & marlinmt::Component::description | ( | ) | const |
Get the component description.
Definition at line 35 of file Component.cc.
References _description.
Referenced by marlinmt::DD4hepGeometry::dumpGeometry(), getParameters(), marlinmt::GeometryPlugin::print(), and marlinmt::DD4hepGeometry::printDetectorSets().
Logging::StreamType marlinmt::Component::error | ( | ) | const |
Shortcut for log<ERROR>()
Definition at line 65 of file Component.cc.
Referenced by marlinmt::concurrency::PEPScheduler::end(), and log().
void marlinmt::Component::getParameters | ( | ConfigSection & | section, |
const std::set< std::string > & | exclude = {} |
||
) | const |
Get the parameters from configurable object and populate the config section with.
section | the config section to populate |
exclude | a list of parameter keys to exclude |
Definition at line 139 of file Component.cc.
References marlinmt::Configurable::_parameters, description(), marlinmt::ConfigSection::metadata(), name(), marlinmt::ConfigSection::setParameter(), type(), and marlinmt::book::Flags::value().
Referenced by marlinmt::Application::dumpExampleConfig(), and log().
|
inlinevirtual |
Initialize the component.
Reimplemented in marlinmt::Processor, marlinmt::DataSourcePlugin, marlinmt::GeometryPlugin, marlinmt::concurrency::PEPScheduler, marlinmt::GeometryManager, marlinmt::LCIOFileSource, marlinmt::BookStoreManager, marlinmt::LoggerManager, marlinmt::StdHepFileSource, marlinmt::IScheduler, and marlinmt::SimpleScheduler.
Definition at line 72 of file Component.h.
References application().
Referenced by setup().
bool marlinmt::Component::isInitialized | ( | ) | const |
Whether the component has been initialized.
Definition at line 112 of file Component.cc.
References _application.
Referenced by log().
|
inline |
Log a message with specific log level.
Returns a stream object in which you can log. Usage:
Definition at line 93 of file Component.h.
References _logger, debug(), error(), getParameters(), isInitialized(), message(), printParameters(), setParameters(), setup(), setVerbosity(), verbosity(), and warning().
Referenced by marlinmt::ProcessorApi::abort(), and marlinmt::ProcessorApi::skipCurrentEvent().
Logging::StreamType marlinmt::Component::message | ( | ) | const |
Shortcut for log<MESSAGE>()
Definition at line 53 of file Component.cc.
Referenced by marlinmt::concurrency::PEPScheduler::end(), marlinmt::GeometryManager::initialize(), log(), marlinmt::concurrency::PEPScheduler::popFinishedEvents(), and marlinmt::GeometryPlugin::print().
const std::string & marlinmt::Component::name | ( | ) | const |
Get the component name.
Definition at line 23 of file Component.cc.
References _name.
Referenced by Component(), marlinmt::constructPath(), marlinmt::Statusmonitor::end(), marlinmt::LCIOOutputProcessor::end(), getParameters(), marlinmt::TestProcessor::init(), marlinmt::Processor::initialize(), marlinmt::GeometryPlugin::print(), marlinmt::DD4hepGeometry::printDetectorSets(), printParameters(), marlinmt::RandomSeedExtension::randomSeed(), and marlinmt::ProcessorConditionsExtension::set().
void marlinmt::Component::printParameters | ( | ) | const |
Print the component parameters.
Definition at line 118 of file Component.cc.
Referenced by marlinmt::CPUCrunchingProcessor::init(), marlinmt::DumpEventProcessor::init(), marlinmt::Statusmonitor::init(), marlinmt::TestProcessor::init(), marlinmt::EventSelectorProcessor::init(), marlinmt::MemoryMonitorProcessor::init(), marlinmt::LCIOOutputProcessor::init(), and log().
void marlinmt::Component::printParameters | ( | ) | const |
Print the component parameters at specific verbosity.
Definition at line 182 of file Component.h.
References marlinmt::Configurable::_parameters, name(), and type().
void marlinmt::Component::setDescription | ( | const std::string & | desc | ) |
Set the component description.
desc | the component description |
Definition at line 41 of file Component.cc.
References _description.
Referenced by marlinmt::CPUCrunchingProcessor::CPUCrunchingProcessor(), marlinmt::DD4hepGeometry::DD4hepGeometry(), marlinmt::DumpEventProcessor::DumpEventProcessor(), marlinmt::EventSelectorProcessor::EventSelectorProcessor(), marlinmt::GearGeometry::GearGeometry(), marlinmt::LCIOEventUnpackingProcessor::LCIOEventUnpackingProcessor(), marlinmt::LCIOFileSource::LCIOFileSource(), marlinmt::LCIOOutputProcessor::LCIOOutputProcessor(), marlinmt::LoggerManager::LoggerManager(), marlinmt::MemoryMonitorProcessor::MemoryMonitorProcessor(), marlinmt::Statusmonitor::Statusmonitor(), marlinmt::StdHepFileSource::StdHepFileSource(), and marlinmt::TestProcessor::TestProcessor().
void marlinmt::Component::setName | ( | const std::string & | n | ) |
Set the component name.
n | the component name |
Definition at line 29 of file Component.cc.
References _name.
Referenced by marlinmt::SuperSequence::addProcessor(), marlinmt::BookStoreManager::BookStoreManager(), marlinmt::Application::dumpExampleConfig(), marlinmt::GeometryManager::GeometryManager(), marlinmt::GeometryPlugin::GeometryPlugin(), marlinmt::BookStoreManager::getKey(), marlinmt::concurrency::PEPScheduler::PEPScheduler(), and marlinmt::SimpleScheduler::SimpleScheduler().
void marlinmt::Component::setParameters | ( | const ConfigSection & | section, |
bool | throwIfNotFound = false |
||
) |
Set the parameters from the configuration section.
section | the input parameter section |
throwIfNotFound | whether to throw if a parameter of the input section can not be mapped to a parameters of this component |
Definition at line 124 of file Component.cc.
References marlinmt::Configurable::_parameters, MARLINMT_THROW, marlinmt::ConfigSection::name(), marlinmt::ConfigSection::parameter(), and marlinmt::ConfigSection::parameterNames().
Referenced by marlinmt::IScheduler::initialize(), marlinmt::BookStoreManager::initialize(), marlinmt::LoggerManager::initialize(), marlinmt::GeometryManager::initialize(), marlinmt::GeometryPlugin::initialize(), marlinmt::DataSourcePlugin::initialize(), marlinmt::Processor::initialize(), and log().
void marlinmt::Component::setup | ( | Application * | app | ) |
Setup the component.
Called by the application before initialization
app | the application owning the component |
Definition at line 101 of file Component.cc.
References _application, _logger, _name, _verbosity, application(), marlinmt::Application::createLogger(), marlinmt::ParameterBase< T >::get(), initialize(), and marlinmt::ParameterBase< T >::isSet().
Referenced by log().
void marlinmt::Component::setVerbosity | ( | const std::string & | level | ) |
Set the verbosity level.
level | the verbosity level to set |
Definition at line 71 of file Component.cc.
References _logger.
Referenced by log().
const std::string & marlinmt::Component::type | ( | ) | const |
Get the component name.
Definition at line 17 of file Component.cc.
References _type.
Referenced by Component(), marlinmt::DD4hepGeometry::dumpGeometry(), getParameters(), and printParameters().
const std::string & marlinmt::Component::verbosity | ( | ) | const |
Get the verbosity level.
Definition at line 77 of file Component.cc.
References _logger.
Referenced by log(), and marlinmt::TestProcessor::processEvent().
Logging::StreamType marlinmt::Component::warning | ( | ) | const |
|
friend |
Definition at line 24 of file Component.h.
|
protected |
The application in which the component has been registered.
Definition at line 171 of file Component.h.
Referenced by application(), isInitialized(), and setup().
|
protected |
The component description.
Definition at line 169 of file Component.h.
Referenced by description(), and setDescription().
|
protected |
The logger instance.
Definition at line 173 of file Component.h.
Referenced by marlinmt::BookStoreManager::bookHist(), Component(), marlinmt::GearGeometry::dumpGeometry(), marlinmt::DD4hepGeometry::dumpGeometry(), marlinmt::SimpleScheduler::end(), marlinmt::concurrency::PEPScheduler::end(), log(), marlinmt::LoggerManager::mainLogger(), marlinmt::DD4hepGeometry::printDetectorData(), marlinmt::DD4hepGeometry::printDetectorSets(), setup(), setVerbosity(), and verbosity().
|
protected |
The component name.
Definition at line 167 of file Component.h.
|
protected |
|
protected |
The verbosity level of the logger (parameter)
Definition at line 175 of file Component.h.
Referenced by setup().