fire v0.19.0
Framework for sImulation and Reconstruction of Events
fire::ConditionsProvider Class Referenceabstract

Base class for all providers of conditions objects. More...

#include <ConditionsProvider.h>

Inheritance diagram for fire::ConditionsProvider:
[legend]
Collaboration diagram for fire::ConditionsProvider:
[legend]

Public Types

using Factory = factory::Factory< ConditionsProvider, std::shared_ptr< ConditionsProvider >, const config::Parameters & >
 The factory type that can create this class. More...
 

Public Member Functions

 ConditionsProvider (const fire::config::Parameters &ps)
 Configure the registered provider. More...
 
virtual ~ConditionsProvider ()=default
 default destructor, virtual so derived types can be destructed
 
virtual std::pair< const ConditionsObject *, ConditionsIntervalOfValiditygetCondition (const EventHeader &context)=0
 Pure virtual getCondition function. More...
 
virtual void release (const ConditionsObject *co)
 Called by conditions system when done with a conditions object, appropriate point for cleanup. More...
 
virtual void onProcessStart ()
 Callback for the ConditionsProvider to take any necessary action when the processing of events starts.
 
virtual void onProcessEnd ()
 Callback for the ConditionsProvider to take any necessary action when the processing of events finishes, such as closing database connections.
 
virtual void onNewRun (RunHeader &)
 Callback for the ConditionsProvider to take any necessary action when the processing of events starts for a given run. More...
 
const std::stringgetConditionObjectName () const
 Get the condition object available from this provider.
 
const std::stringgetTagName () const
 Access the tag name.
 
virtual void attach (Conditions *c) final
 Attach the central conditions system to this provider.
 

Protected Member Functions

std::pair< const ConditionsObject *, ConditionsIntervalOfValidityrequestParentCondition (const std::string &name, const EventHeader &context)
 Request another condition needed to construct this condition. More...
 

Protected Attributes

logging::logger theLog_
 The logger for this ConditionsProvider.
 

Private Attributes

Conditionsconditions_ {nullptr}
 Handle to the central conditions system.
 
std::string objectName_
 The name of the object provided by this provider.
 
std::string tagname_
 The tag name for the ConditionsProvider.
 

Detailed Description

Base class for all providers of conditions objects.

Besides defining the necessary virtual callbacks, we also provide the factory infrastructure for dynamically creating providers from loaded libraries and we define a requestParentCondition function that can be used by other providers to obtain conditions other conditions depend on.

Usage

Defining a conditions provider is done similarly to a Processor. Since ConditionsProviders are generally only used after some experience with Processors is obtained, I will not go into as much detail. Perhaps the best way is to provide an example from which you can learn.

// MyConditionsProvider.cpp
#include <fire/ConditionsProvider.h>
class MyConditionsProvider : public fire::ConditionsProvider {
public:
MyConditionsProvider(const fire::config::Parameters& p)
: fire::ConditionsProvider(p) {
// deduce configuration of provider from parameter set p
}
~MyConditionsProvider() = default;
getCondition(const EventHeader& context) final override {
// use context to determine correct configuration of conditions object
// as well as the range of run numbers and type of data that the
// condition is valid for
}
};
DECLARE_CONDITIONS_PROVIDER(MyConditionsProvider);
Base class for all providers of conditions objects.
Definition: ConditionsProvider.h:83
virtual std::pair< const ConditionsObject *, ConditionsIntervalOfValidity > getCondition(const EventHeader &context)=0
Pure virtual getCondition function.
ConditionsProvider(const fire::config::Parameters &ps)
Configure the registered provider.
Definition: ConditionsProvider.cxx:6
Class encapsulating parameters for configuring a processor.
Definition: Parameters.h:28

One special (but somewhat common) use case is a global condition that is light in memory. These criteria are satisifed by the RandomNumberSeedService and allow the conditions provider and the conditions object to be the same object.

// LightAndGlobalCondition.cpp
#include <fire/ConditionsProvider.h>
class LightAndGlobalCondition : public fire::ConditionsProvider,
public:
LightAndGlobalCondition(const fire::config::Parameters& p)
: fire::ConditionsProvider(p) {
// deduce configuration of both provider and object from parameter set p
}
~LightAndGlobalCondition() = default;
// return ourselves and infinite validity
getCondition(const EventHeader& context) final override {
return std::make_pair(this, ConditionsIntervalOfValidity(true,true));
}
// don't allow conditions system to delete us
virtual void release(const ConditionsObject* co) final override {}
};
DECLARE_CONDITIONS_PROVIDER(LightAndGlobalCondition);
Base class for all conditions objects, very simple.
Definition: ConditionsObject.h:11
virtual void release(const ConditionsObject *co)
Called by conditions system when done with a conditions object, appropriate point for cleanup.
Definition: ConditionsProvider.h:124
T make_pair(T... args)

One could also image a light condition which may still change with the context, but that can be implemented from this example.

Member Typedef Documentation

◆ Factory

The factory type that can create this class.

We provide the class type, the type of pointer for this class, and the arguments to the constructor.

Constructor & Destructor Documentation

◆ ConditionsProvider()

fire::ConditionsProvider::ConditionsProvider ( const fire::config::Parameters ps)

Configure the registered provider.

Parameters
[in]psParameters to configure the provider

Member Function Documentation

◆ getCondition()

virtual std::pair< const ConditionsObject *, ConditionsIntervalOfValidity > fire::ConditionsProvider::getCondition ( const EventHeader context)
pure virtual

Pure virtual getCondition function.

Must be implemented by any Conditions providers.

Parameters
[in]contextEventHeader for the condition
Returns
pair of condition and its interval of validity

Implemented in fire::RandomNumberSeedService.

◆ onNewRun()

virtual void fire::ConditionsProvider::onNewRun ( RunHeader )
inlinevirtual

Callback for the ConditionsProvider to take any necessary action when the processing of events starts for a given run.

Reimplemented in fire::RandomNumberSeedService.

◆ release()

virtual void fire::ConditionsProvider::release ( const ConditionsObject co)
inlinevirtual

Called by conditions system when done with a conditions object, appropriate point for cleanup.

Note
Default behavior is to delete the object!
Parameters
[in]cocondition to cleanup

Reimplemented in fire::RandomNumberSeedService.

◆ requestParentCondition()

std::pair< const ConditionsObject *, ConditionsIntervalOfValidity > fire::ConditionsProvider::requestParentCondition ( const std::string name,
const EventHeader context 
)
protected

Request another condition needed to construct this condition.

This is where we use the handle to the central conditions system and this allows us to recursively depend on other instances ConditionsProvider.

Parameters
[in]namecondition name that is needed
[in]contextEventHeader for which to get condition
Returns
pair of parent condition and its interval of validity

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