fire v0.19.0
Framework for sImulation and Reconstruction of Events
|
Base class for all providers of conditions objects. More...
#include <ConditionsProvider.h>
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 *, ConditionsIntervalOfValidity > | getCondition (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::string & | getConditionObjectName () const |
Get the condition object available from this provider. | |
const std::string & | getTagName () 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 *, ConditionsIntervalOfValidity > | requestParentCondition (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 | |
Conditions * | conditions_ {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. | |
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.
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.
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.
One could also image a light condition which may still change with the context, but that can be implemented from this example.
using fire::ConditionsProvider::Factory = factory::Factory<ConditionsProvider, std::shared_ptr<ConditionsProvider>, const config::Parameters&> |
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.
fire::ConditionsProvider::ConditionsProvider | ( | const fire::config::Parameters & | ps | ) |
Configure the registered provider.
[in] | ps | Parameters to configure the provider |
|
pure virtual |
Pure virtual getCondition function.
Must be implemented by any Conditions providers.
[in] | context | EventHeader for the condition |
Implemented in fire::RandomNumberSeedService.
|
inlinevirtual |
Callback for the ConditionsProvider to take any necessary action when the processing of events starts for a given run.
Reimplemented in fire::RandomNumberSeedService.
|
inlinevirtual |
Called by conditions system when done with a conditions object, appropriate point for cleanup.
[in] | co | condition to cleanup |
Reimplemented in fire::RandomNumberSeedService.
|
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.
[in] | name | condition name that is needed |
[in] | context | EventHeader for which to get condition |