Parent class for all the modules. More...

#include <Module.h>

Detailed Description

Parent class for all the modules.

Definition at line 37 of file Module.h.

Inheritance diagram for Module:

Classes

class  invalid_configuration
 

Public Types

enum  Status : std::int8_t { OK, NEXT, ABORT }
 

Public Member Functions

 Module (PoolPtr pool, const std::string &name)
 Constructor. More...
 
virtual void configure ()
 Called once at the beginning of the job.
 
virtual void beginIntegration ()
 Called once at the beginning of the integration.
 
virtual void beginPoint ()
 Called once when a new PS point is started. More...
 
virtual void beginLoop ()
 Called once at the beginning of a loop. More...
 
virtual Status work ()
 Main function. More...
 
virtual void endLoop ()
 Called once at the end of a loop. More...
 
virtual void endPoint ()
 Called once when a PS point is finished. More...
 
virtual void endIntegration ()
 Called once at the end of the integration.
 
virtual void finish ()
 Called once at the end of the job.
 
virtual std::string name () const final
 

Static Public Member Functions

static std::string statusToString (const Status &status)
 
static bool is_virtual_module (const std::string &name)
 Test if a given name correspond to a virtual module. More...
 

Protected Member Functions

template<typename T , typename... Args>
std::shared_ptr< T > produce (const std::string &name, Args... args)
 Add a new output to the module. More...
 
template<typename T >
Value< T > get (const std::string &module, const std::string &name)
 
template<typename T >
Value< T > get (const InputTag &tag)
 

Protected Attributes

PoolPtr m_pool
 

Constructor & Destructor Documentation

◆ Module()

Module::Module ( PoolPtr  pool,
const std::string &  name 
)
inline

Constructor.

This constructor is called when the module is instanciate. It's the only place where you can access the memory pool, so you must declare here all your module's inputs and outputs

Parameters
poolThe memory pool. Use this to grab the input you needs from other modules, and to declare your outputs
nameThe name of this module.

Definition at line 61 of file Module.h.

Member Function Documentation

◆ beginLoop()

virtual void Module::beginLoop ( )
inlinevirtual

Called once at the beginning of a loop.

Only relevant if the module is inside a loop

Reimplemented in SimpleCounter, and Counter< T >.

Definition at line 88 of file Module.h.

◆ beginPoint()

virtual void Module::beginPoint ( )
inlinevirtual

Called once when a new PS point is started.

Only relevant if the module is inside a loop, since otherwise the module is called only once anyway

Reimplemented in Looper, LooperSummer< T >, and LooperSummer< T >.

Definition at line 81 of file Module.h.

◆ endLoop()

virtual void Module::endLoop ( )
inlinevirtual

Called once at the end of a loop.

Only relevant if the module is inside a loop

Definition at line 104 of file Module.h.

◆ endPoint()

virtual void Module::endPoint ( )
inlinevirtual

Called once when a PS point is finished.

Only relevant if the module is inside a loop, since otherwise the module is called only once anyway

Reimplemented in Looper.

Definition at line 111 of file Module.h.

◆ is_virtual_module()

static bool Module::is_virtual_module ( const std::string &  name)
inlinestatic

Test if a given name correspond to a virtual module.

Some names are reserved for internal usage and are mapped to virtual modules.

Parameters
nameThe name to test
Returns
True if name is the name of a virtual module, false otherwise.

Definition at line 135 of file Module.h.

◆ produce()

template<typename T , typename... Args>
std::shared_ptr<T> Module::produce ( const std::string &  name,
Args...  args 
)
inlineprotected

Add a new output to the module.

Call this function to add a new output to the module. This output will then be available to all the modules.

Example:

// In constructor
std::shared_ptr<double> my_output = produce<double>("output");
std::shared_ptr<TH1D> my_hist = produce<TH1D>("output_hist", "name", "title", 5, 0, 5); // Use constructor call
// In work()
*my_output = 10;
Template Parameters
TThe type of the output.
Parameters
nameThe name of the output. Must be unique to this module.
argsVariable list of optional arguments. Will be passed to the constructor of T.
Returns
A std::shared_ptr<T> pointing to newly allocated memory in the memory pool. Change the content of this pointer to change the output.

Definition at line 161 of file Module.h.

◆ work()


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