EventAnalysis  1.3.0
Public Member Functions | Protected Attributes | List of all members
EA::PersistenceAlgo Class Reference

An algorithm that saves data objects. More...

#include <PersistenceAlgo.h>

Inheritance diagram for EA::PersistenceAlgo:
EA::Algorithm EA::Filter EA::Info EA::Configurable EA::DataStoreUser EA::ObjectProducer EA::ObjectConsumer

Public Member Functions

 PersistenceAlgo (const std::string &name)
 
bool SetPersistenceServiceManager (PersistenceServiceManager &persManager)
 Method to set the persistence manager. More...
 
bool Initialize ()
 Connects and initializes the persistence service. More...
 
bool Process ()
 Triggers the persistence for the current event. More...
 
bool Finalize ()
 Finalizes the persistence. More...
 
- Public Member Functions inherited from EA::Algorithm
 Algorithm (const std::string &name)
 
virtual bool SetEventLoopProxy (observer_ptr< EventLoopProxy > loopProxy)
 Injector for dependency on EventLoopProxy. More...
 
virtual IterateRequest Iterate ()
 Request for another iteration of the event loop. More...
 
observer_ptr< EventLoopProxyGetEventLoopProxy ()
 Accessor for the event loop proxy. More...
 
- Public Member Functions inherited from EA::Filter
 Filter ()
 Constructor. More...
 
FilterResult GetFilterResult ()
 Get the result for the filter. More...
 
FilterLogic GetFilterLogic ()
 Get the current filter logic. More...
 
void SetFilterStatus (FilterStatus status)
 Toggles on and off filtering. More...
 
FilterStatus GetFilterStatus ()
 The filter status. More...
 
void SetFilterLogic (FilterLogic filterLogic)
 Sets the filter return value logic. More...
 
- Public Member Functions inherited from EA::Info
 Info (const std::string &name)
 Constructor. More...
 
virtual ~Info ()
 Destructor. More...
 
virtual const std::string GetType () const
 
virtual const std::string GetName () const
 The type (i.e. class) of the object. More...
 
virtual const std::string GetVersion () const
 The name of the object. More...
 
- Public Member Functions inherited from EA::Configurable
 Configurable ()
 Constructor. More...
 
template<typename T >
bool SetParameter (const std::string &name, const T &value)
 Set the value of a parameter. More...
 
bool SetParameter (const std::string &name, const char *value)
 Set the value of a string parameter using a string literal. More...
 
std::vector< std::string > GetParameters ()
 Get the names of the parameters. More...
 
- Public Member Functions inherited from EA::DataStoreUser
 DataStoreUser ()
 
virtual ~DataStoreUser ()
 Destructor. More...
 
virtual bool SetDataStoreManager (observer_ptr< DataStoreManager > dsManager)
 Injector for dependency on DataStoreManager. More...
 
observer_ptr< DataStoreManagerGetDataStoreManager ()
 Getter for the Data store manager. More...
 
- Public Member Functions inherited from EA::ObjectProducer
 ObjectProducer ()
 Constructor. More...
 
virtual ~ObjectProducer ()
 Destructor. More...
 
template<typename C >
void DeclareProducedObject (std::string name, ObjectCategory category, C aliases, std::string store)
 Declare a produced objects. More...
 
const ProducedObjectsGetProducedObjects () const
 Getter method for produced objects. More...
 
bool SetDisabled (bool disabled=true)
 Disables/enables the producer. More...
 
virtual std::vector< std::string > FreeObjects (const std::vector< std::string > &objs, Memory::Status memStatus)
 Free the memory for given objects. More...
 
template<>
void DeclareProducedObject (std::string name, ObjectCategory category, const char *alias, std::string store)
 
- Public Member Functions inherited from EA::ObjectConsumer
 ObjectConsumer ()
 Constructor. More...
 
void DeclareConsumedObject (std::string name, ObjectCategory category, std::string store, bool optional=false)
 Declare a consumed objects. More...
 
void DeclareAlternative (const std::string &name, ObjectCategory category, std::string store, const std::string &alternativeName, ObjectCategory alternativeCategory, std::string alternativeStore)
 Declares two already declared objects as alternatives. More...
 
const ConsumedObjectsGetConsumedObjects () const
 Getter method for consumed objects. More...
 

Protected Attributes

std::string _persistenceName
 
std::string _output
 
observer_ptr< PersistenceServiceManager_persistenceManager
 
std::unique_ptr< PersistenceService_persistenceServ
 

Additional Inherited Members

- Public Types inherited from EA::Algorithm
enum  IterateRequest { IterateRequest::YES, IterateRequest::NO, IterateRequest::WHATEVER, IterateRequest::ERROR }
 
- Public Types inherited from EA::ObjectProducer
using ProducedObjects = std::vector< ProducedObject >
 Type for container of produced objects. More...
 
- Public Types inherited from EA::ObjectConsumer
using ConsumedObjects = std::vector< ConsumedObject >
 Type for container of produced objects. More...
 
- Protected Member Functions inherited from EA::Algorithm
 Algorithm (const std::shared_ptr< Filter::Representation > &filterRepr, const std::shared_ptr< Info::Representation > &infoRepr, const std::shared_ptr< Configurable::Representation > &confRepr, const std::shared_ptr< DataStoreUser::Representation > &dsuRepr, const std::shared_ptr< ObjectProducer::Representation > &opRepr, const std::shared_ptr< ObjectConsumer::Representation > &ocRepr, const std::shared_ptr< Algorithm::Representation > &algoRepr)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::Filter
void SetFilterResult (FilterResult result)
 Sets the result. More...
 
 Filter (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::Info
 Info (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::Configurable
template<typename T >
bool DefineParameter (const std::string &name, T &variable)
 Set a parameter. More...
 
 Configurable (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::DataStoreUser
 DataStoreUser (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::ObjectProducer
 ObjectProducer (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::ObjectConsumer
 ObjectConsumer (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 

Detailed Description

An algorithm that saves data objects.

This algorithm allows to execute the tasks of a #PersistenceService during the execution of the algorithm sequence, rather than at the end as it is usually done by persistence services. It allows for saving event objects as they are at the moment when the algorithm is executed. The main usage of this class is for saving only those events surviving some given selection criteria: it is sufficient to insert in the sequence the cut algorithms followed by the persistence algorithm; for example:

EventLoop
Sequence seq
Algo CutAlgo1 cut1
Algo CutAlgo2 cut2
Algo PersistenceAlgo pers
EndSequence

Only the data objects of the events surviving cut1 and cut2 will be saved in the output tree.

The PersistenceAlgo is configured by creating and configuring a #PersistenceService, and then assigning it to the algorithm. The same persistence service can be assigned to different instances of PersistenceAlgo, for easily performing the same type of persistence operation at different points in the algorithm sequence. Each PersistenceAlgo must be configured with a different output name, to avoid clashes. For example, suppose to have a persistence service that writes output data on a file:

Persistence MyPersistence myPersistence outputFile
Book globObj global globStore
Book evObj event evStore
EventLoop
Sequence seq1
Algo CutAlgo1 cut1
Algo CutAlgo2 cut2
Algo PersistenceAlgo pers1
Set persistence myPersistence
Set output file1
Algo CutAlgo3 cut3
Algo PersistenceAlgo pers2
Set persistence myPersistence
Set output file2
EndSequence

The output file file1 will contain the object evObj for each event surviving the cuts cut1 and cut2, while in file2 there will be the same objects for events also surviving cut3. In both files the global object globObj will be present. Please note that global objects are always written at the end of the event loop, so globObj will be the same in file1 and file2. This also means that if there is another loop then the eventual modifications it makes to the global objects will not be reflected in the persistent objects; in other words, the global objects are saved as they are at the end of the event loop to which the PersistenceAlgo belongs.

Constructor & Destructor Documentation

◆ PersistenceAlgo()

EA::PersistenceAlgo::PersistenceAlgo ( const std::string &  name)

Member Function Documentation

◆ Finalize()

bool EA::PersistenceAlgo::Finalize ( )
virtual

Finalizes the persistence.

Writes global objects and then disconnects the persistence. Note that since this method is called at the end of the event loop the persistent global objects will be unaffected by any eventual modification made by eventual other event loops.

Returns
true if the persistence is correctly finalized and disconnected from output.

Reimplemented from EA::Algorithm.

◆ Initialize()

bool EA::PersistenceAlgo::Initialize ( )
virtual

Connects and initializes the persistence service.

Returns
true if the persistence has been connected and initialized properly.

Reimplemented from EA::Algorithm.

◆ Process()

bool EA::PersistenceAlgo::Process ( )
virtual

Triggers the persistence for the current event.

Returns
true if the persistence has been correctly executed.

Reimplemented from EA::Algorithm.

◆ SetPersistenceServiceManager()

bool EA::PersistenceAlgo::SetPersistenceServiceManager ( PersistenceServiceManager persManager)

Method to set the persistence manager.

The PersistenceAlgo needs to retrieve the PersistenceService object whose name correspond to the one set for the persistence parameter. The Algorithm interface however does not allow for access to the persistence service manager. This method allows for injecting a reference to the persistence service manager into PersistenceAlgo.

Parameters
persManagerReference to the PersistenceServiceManager.
Returns
true if the manager reference has been correctly set.

Member Data Documentation

◆ _output

std::string EA::PersistenceAlgo::_output
protected

◆ _persistenceManager

observer_ptr<PersistenceServiceManager> EA::PersistenceAlgo::_persistenceManager
protected

◆ _persistenceName

std::string EA::PersistenceAlgo::_persistenceName
protected

◆ _persistenceServ

std::unique_ptr<PersistenceService> EA::PersistenceAlgo::_persistenceServ
protected

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