MarlinMT  0.1.0
marlinmt::Component Class Reference

Component class. More...

#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...
 
Componentoperator= (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 Applicationapplication () const
 Get the application in which the component is registered. More...
 
Applicationapplication ()
 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 &section, bool throwIfNotFound=false)
 Set the parameters from the configuration section. More...
 
void getParameters (ConfigSection &section, 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< 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

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
 

Detailed Description

Component class.

Base class for all application components. Groups a few feature common too all application components:

  • configuration via parameters
  • logger access
  • access to application

Definition at line 22 of file Component.h.

Member Typedef Documentation

◆ LoggerPtr

Definition at line 25 of file Component.h.

Constructor & Destructor Documentation

◆ Component() [1/3]

marlinmt::Component::Component ( )
delete

No default constructor.

◆ Component() [2/3]

marlinmt::Component::Component ( const Component )
delete

No copy or assignement.

◆ ~Component()

virtual marlinmt::Component::~Component ( )
virtualdefault

Default destructor.

◆ Component() [3/3]

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

Member Function Documentation

◆ application() [1/2]

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() [2/2]

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.

◆ debug()

Logging::StreamType marlinmt::Component::debug ( ) const

Shortcut for log<DEBUG>()

Definition at line 47 of file Component.cc.

Referenced by log().

◆ description()

const std::string & marlinmt::Component::description ( ) const

◆ error()

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

◆ getParameters()

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.

Parameters
sectionthe config section to populate
excludea 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().

◆ initialize()

◆ isInitialized()

bool marlinmt::Component::isInitialized ( ) const

Whether the component has been initialized.

Definition at line 112 of file Component.cc.

References _application.

Referenced by log().

◆ log()

template<class T >
Logging::StreamType marlinmt::Component::log ( ) const
inline

Log a message with specific log level.

Returns a stream object in which you can log. Usage:

log<MESSAGE>() << "This is a message" << std::endl ;

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

◆ message()

◆ name()

◆ operator=()

Component& marlinmt::Component::operator= ( const Component )
delete

◆ printParameters() [1/2]

◆ printParameters() [2/2]

template<class T >
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().

◆ setDescription()

◆ setName()

◆ setParameters()

void marlinmt::Component::setParameters ( const ConfigSection section,
bool  throwIfNotFound = false 
)

Set the parameters from the configuration section.

Parameters
sectionthe input parameter section
throwIfNotFoundwhether 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().

◆ setup()

void marlinmt::Component::setup ( Application app)

Setup the component.

Called by the application before initialization

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

◆ setVerbosity()

void marlinmt::Component::setVerbosity ( const std::string &  level)

Set the verbosity level.

Parameters
levelthe verbosity level to set

Definition at line 71 of file Component.cc.

References _logger.

Referenced by log().

◆ type()

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

◆ verbosity()

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

◆ warning()

Logging::StreamType marlinmt::Component::warning ( ) const

Shortcut for log<WARNING>()

Definition at line 59 of file Component.cc.

Referenced by log().

Friends And Related Function Documentation

◆ Application

friend class Application
friend

Definition at line 24 of file Component.h.

Member Data Documentation

◆ _application

Application* marlinmt::Component::_application {nullptr}
protected

The application in which the component has been registered.

Definition at line 171 of file Component.h.

Referenced by application(), isInitialized(), and setup().

◆ _description

std::string marlinmt::Component::_description {"No description"}
protected

The component description.

Definition at line 169 of file Component.h.

Referenced by description(), and setDescription().

◆ _logger

◆ _name

std::string marlinmt::Component::_name {}
protected

The component name.

Definition at line 167 of file Component.h.

Referenced by name(), setName(), and setup().

◆ _type

std::string marlinmt::Component::_type {}
protected

The component type.

Definition at line 165 of file Component.h.

Referenced by type().

◆ _verbosity

StringParameter marlinmt::Component::_verbosity { *this, "Verbosity", "The component verbosity level", "MESSAGE" }
protected

The verbosity level of the logger (parameter)

Definition at line 175 of file Component.h.

Referenced by setup().


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