MarlinMT  0.1.0
marlinmt::Processor Class Reference

Processor class. More...

#include <Processor.h>

Inherits marlinmt::Component.

Inherited by marlinmt::CPUCrunchingProcessor, marlinmt::DumpEventProcessor, marlinmt::EventSelectorProcessor, marlinmt::LCIOEventUnpackingProcessor, marlinmt::LCIOOutputProcessor, marlinmt::MemoryMonitorProcessor, marlinmt::Statusmonitor, and marlinmt::TestProcessor.

Public Types

enum  ERuntimeOption { ERuntimeOption::eCritical, ERuntimeOption::eClone }
 ERuntimeOption enumerator. More...
 
using RuntimeOptions = std::map< ERuntimeOption, bool >
 
- Public Types inherited from marlinmt::Component
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

virtual ~Processor ()=default
 
 Processor (const std::string &t)
 Constructor. More...
 
virtual void init ()
 Initialize the processor. More...
 
virtual void processRunHeader (RunHeader *)
 Call at start of run. More...
 
virtual void processEvent (EventStore *)
 Process an input event. More...
 
virtual void end ()
 Terminate the processor. More...
 
std::optional< bool > runtimeOption (ERuntimeOption option) const
 Get the forced runtime option settings. More...
 
- Public Member Functions inherited from marlinmt::Component
 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...
 
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 Member Functions

void setRuntimeOption (ERuntimeOption option, bool value)
 Force the runtime option to a given boolean value. More...
 

Private Member Functions

 Processor ()=delete
 
 Processor (const Processor &)=delete
 
Processoroperator= (const Processor &)=delete
 
void initialize () override
 From Component class. More...
 

Private Attributes

RuntimeOptions _forcedRuntimeOptions {}
 The user forced runtime options for parallel processing. More...
 

Friends

class ProcessorApi
 

Additional Inherited Members

- Protected Attributes inherited from marlinmt::Component
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...
 

Detailed Description

Processor class.

Base class for Marlin processors. Users can optionaly overwrite the following methods:
init, processRun, processEvent and end.
Use registerProcessorParameter to define all parameters that the module uses. Registered parameters are filled automatically before init() is called. With MyAplication -l you can print a list of available processors including the steering parameters they use/need.
With MyAplication -x you can print an example XML steering file for all known processors.

See also
init
processRun
processEvent
end
Author
F. Gaede, DESY
Version
Id
Processor.h,v 1.38 2008-06-26 10:25:36 gaede Exp

Definition at line 43 of file Processor.h.

Member Typedef Documentation

◆ RuntimeOptions

Definition at line 63 of file Processor.h.

Member Enumeration Documentation

◆ ERuntimeOption

ERuntimeOption enumerator.

Enumerator
eCritical 
eClone 

Whether the processor has to be executed in a critical section.

Whether the processor must be cloned in each thread worker

Definition at line 58 of file Processor.h.

Constructor & Destructor Documentation

◆ Processor() [1/3]

marlinmt::Processor::Processor ( )
privatedelete

◆ Processor() [2/3]

marlinmt::Processor::Processor ( const Processor )
privatedelete

◆ ~Processor()

virtual marlinmt::Processor::~Processor ( )
virtualdefault

◆ Processor() [3/3]

marlinmt::Processor::Processor ( const std::string &  t)

Constructor.

Subclasses need to call this in their default constructor.

Parameters
tthe processor type

Definition at line 8 of file Processor.cc.

Member Function Documentation

◆ end()

virtual void marlinmt::Processor::end ( )
inlinevirtual

Terminate the processor.

Called after data processing for clean up in the inverse order of the init() method so that resources allocated in the first processor also will be available for all following processors.

Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::TestProcessor, and marlinmt::Statusmonitor.

Definition at line 97 of file Processor.h.

References initialize(), runtimeOption(), setRuntimeOption(), and marlinmt::book::Flags::value().

◆ init()

virtual void marlinmt::Processor::init ( )
inlinevirtual

Initialize the processor.

Called at the begin of the job before anything is read. Use to initialize the processor, e.g. book histograms.

Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::MemoryMonitorProcessor, marlinmt::EventSelectorProcessor, marlinmt::TestProcessor, marlinmt::Statusmonitor, marlinmt::DumpEventProcessor, marlinmt::CPUCrunchingProcessor, and marlinmt::LCIOEventUnpackingProcessor.

Definition at line 78 of file Processor.h.

Referenced by initialize().

◆ initialize()

void marlinmt::Processor::initialize ( )
overrideprivatevirtual

◆ operator=()

Processor& marlinmt::Processor::operator= ( const Processor )
privatedelete

◆ processEvent()

virtual void marlinmt::Processor::processEvent ( EventStore )
inlinevirtual

◆ processRunHeader()

virtual void marlinmt::Processor::processRunHeader ( RunHeader )
inlinevirtual

Call at start of run.

Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::TestProcessor, and marlinmt::Statusmonitor.

Definition at line 83 of file Processor.h.

◆ runtimeOption()

std::optional< bool > marlinmt::Processor::runtimeOption ( ERuntimeOption  option) const

Get the forced runtime option settings.

The return value is set if the forced option was specified by the user.

Parameters
optionthe runtime option to get

Definition at line 26 of file Processor.cc.

References _forcedRuntimeOptions.

Referenced by end().

◆ setRuntimeOption()

void marlinmt::Processor::setRuntimeOption ( ERuntimeOption  option,
bool  value 
)
protected

Force the runtime option to a given boolean value.

Depending on the implementation of your processor, setting one of the runtime option might be a necessity. For example, you handle a lot of data in your processor members that you don't want to duplicate. In this case you should call in the constructor

forceRuntimeOption( Processor::RuntimeOption::Clone, false ) ;

The code contained in processEvent() might also not be thread safe. In this case you can ask the Marlin framework to call the processEvent() method in a critical section (using std::mutex). Do to so, call:

forceRuntimeOption( RuntimeOption::Critical, true ) ;

If a runtime option is forced in the code and the steering file tries to overwrite it, an exception will be raised.

Note that this method must be called in user processor constructor to ensure it is correctly handled by the framework at configuration time.

Parameters
optionthe runtime option to force
valuethe boolean value to set

Definition at line 37 of file Processor.cc.

References _forcedRuntimeOptions, and marlinmt::book::Flags::value().

Referenced by marlinmt::DumpEventProcessor::DumpEventProcessor(), end(), marlinmt::LCIOOutputProcessor::LCIOOutputProcessor(), marlinmt::MemoryMonitorProcessor::MemoryMonitorProcessor(), and marlinmt::Statusmonitor::Statusmonitor().

Friends And Related Function Documentation

◆ ProcessorApi

friend class ProcessorApi
friend

Definition at line 44 of file Processor.h.

Member Data Documentation

◆ _forcedRuntimeOptions

RuntimeOptions marlinmt::Processor::_forcedRuntimeOptions {}
private

The user forced runtime options for parallel processing.

Definition at line 142 of file Processor.h.

Referenced by runtimeOption(), and setRuntimeOption().


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