EventAnalysis  1.3.0
Public Types | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
EA::EventLoop Class Reference

Interface for event loop classes. More...

#include <EventLoop.h>

Inheritance diagram for EA::EventLoop:
EA::Configurable

Public Types

enum  IterateRequest { IterateRequest::YES, IterateRequest::NO, IterateRequest::ERROR }
 

Public Member Functions

 EventLoop (unsigned int firstEvent=0, unsigned int nEvents=0)
 Constructor. More...
 
bool SetDataProviderManager (observer_ptr< DataProviderManager > dpManager)
 Set the data provider manager. More...
 
bool SetDataStoreManager (observer_ptr< DataStoreManager > dsManager)
 Set the data store manager. More...
 
bool SetEventDataCacheManager (observer_ptr< EventDataCacheManager > ecManager)
 Set the event data cache manager. More...
 
bool SetPersistenceServiceManager (observer_ptr< PersistenceServiceManager > psManager)
 Set the persistence service manager. More...
 
bool AddAlgorithm (std::unique_ptr< Algorithm > algo)
 Add an algorithm to the loop. More...
 
bool SetAlgorithms (std::unique_ptr< AlgoSequence > &&algorithms)
 Replaces the loop algorithm sequence with the given one. More...
 
AlgoSequenceGetAlgorithms ()
 Get the algorithm sequence in the loop. More...
 
bool CacheEventObject (const std::string &objName, const std::string &storeName)
 Caches the given object. More...
 
bool CleanEventCache (const std::string &objName, const std::string &storeName)
 Cleans the cache for the given object. More...
 
bool Initialize (unsigned int passNumber, unsigned int iterNumber)
 Initializes the loop. More...
 
bool Run ()
 The actual event loop. More...
 
unsigned int GetFirstEvent ()
 Returns the first event to be processed. More...
 
unsigned int GetNEvents ()
 Returns the number of events to be processed. More...
 
unsigned int GetNProcessed ()
 Returns the number of processed events. More...
 
bool Finalize ()
 Finalizes the loop. More...
 
IterateRequest Iterate ()
 Signals whether the event loop has to be reiterated or not. 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...
 

Private Types

using CachedObjs = std::list< std::pair< std::string, std::string > >
 

Private Attributes

EventLoopProxy _loopProxy
 
observer_ptr< DataProviderManager_dpManager
 
observer_ptr< DataStoreManager_dsManager
 
observer_ptr< EventDataCacheManager_ecManager
 
observer_ptr< PersistenceServiceManager_psManager
 
std::unique_ptr< AlgoSequence_algorithms
 
CachedObjs _cachedObjs
 
CachedObjs _cachesToBeCleaned
 
unsigned int _passNumber
 
unsigned int _currIter
 
unsigned int _currentEvent
 
unsigned int _firstEvent
 
unsigned int _nEvents
 
unsigned int _nProcessed
 
int _printModulo
 
bool _checkDataAvailability
 
std::vector< std::string > _disabledProviders
 

Friends

class EventLoopProxy
 

Additional Inherited Members

- 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 ()
 

Detailed Description

Interface for event loop classes.

An EventLoop takes care of executing algorithms on a set of events provided by data providers.

The EventLoop owns the algorithms assigned to it.

Member Typedef Documentation

◆ CachedObjs

using EA::EventLoop::CachedObjs = std::list<std::pair<std::string, std::string> >
private

Member Enumeration Documentation

◆ IterateRequest

Enumerator
YES 
NO 
ERROR 

Constructor & Destructor Documentation

◆ EventLoop()

EA::EventLoop::EventLoop ( unsigned int  firstEvent = 0,
unsigned int  nEvents = 0 
)

Constructor.

Parameters
firstEventThe first event to be processed.
nEventsNumber of events to be processed.

Member Function Documentation

◆ AddAlgorithm()

bool EA::EventLoop::AddAlgorithm ( std::unique_ptr< Algorithm algo)

Add an algorithm to the loop.

Each algorithm is evaluated separately on every event in the #DoLoop method. To conditionally evaluate a sequence of algorithms, put them inside an #AlgoSequence and add the sequence to the EventLoop.

Parameters
algoThe algorithm to add.
Returns
true if the algorithm has been successfully added.

◆ CacheEventObject()

bool EA::EventLoop::CacheEventObject ( const std::string &  objName,
const std::string &  storeName 
)

Caches the given object.

This method will make the object values created during the event loop to be cached. The given object from the given store will be booked for being cached during loop initialization. In case of multiple iterations of the loop the cached values will be updated in subsequent iterations. The booked objects will be unbooked at the end of the loop, so that they won't be automatically cached again by subsequent loops.

Parameters
objNameThe name of the object to be cached.
storeNameThe event store containing the object to be cached.
Returns
true if the object has been correctly booked for being cached.

◆ CleanEventCache()

bool EA::EventLoop::CleanEventCache ( const std::string &  objName,
const std::string &  storeName 
)

Cleans the cache for the given object.

All the cached values for the given object are deleted.

Parameters
objNameThe name of the object.
storeNameThe event store containing the object.
Returns
true if the object cache has been correctly cleaned, false if the event or store do not exist.

◆ Finalize()

bool EA::EventLoop::Finalize ( )

Finalizes the loop.

This routine must be called after Run. It:

  • finalizes all the algorithms
  • finalizes pass-level persistence

If any exception is thrown by an algorithm during finalization it is caught and a false value is returned.

Returns
true if all the finalizations have been successful.

◆ GetAlgorithms()

AlgoSequence& EA::EventLoop::GetAlgorithms ( )
inline

Get the algorithm sequence in the loop.

Returns
The algorithm sequence.

◆ GetFirstEvent()

unsigned int EA::EventLoop::GetFirstEvent ( )

Returns the first event to be processed.

Returns
the first event to be processed.

◆ GetNEvents()

unsigned int EA::EventLoop::GetNEvents ( )

Returns the number of events to be processed.

Returns
the number of events to be processed.

◆ GetNProcessed()

unsigned int EA::EventLoop::GetNProcessed ( )

Returns the number of processed events.

This may actually be different from GetNEvents, e.g. when processing has not been started (in this case the returned value will be 0) or when there are less events than desired.

Returns
the number of processed events.

◆ Initialize()

bool EA::EventLoop::Initialize ( unsigned int  passNumber,
unsigned int  iterNumber 
)

Initializes the loop.

This routine must be called before Run. It:

  • sets the number of current pass and iteration for the data provider manager
  • initializes pass-level persistence
  • initializes all the algorithms

If any exception is thrown by an algorithm during initialization it is caught and a false value is returned.

Parameters
passNumberthe number of current pass.
iterNumberthe number of current iteration of current pass.
Returns
true if all the initializations have been successful.

◆ Iterate()

EventLoop::IterateRequest EA::EventLoop::Iterate ( )

Signals whether the event loop has to be reiterated or not.

Some algorithms may require to loop over all the events for an unspecified number of times, e.g. an algorithm based on a convergent procedure. Each algorithm is queried by this method for another iteration by calling Algorithm::Iterate(). If at least one algorithm requires for another iteration by returning #Algorithm::IterateRequest::YES, and all the others return the same value or #Algorithm::IterateRequest::WHATEVER, then this method returns #IterateRequest::YES. If at least one algorithm forbids another iteration by returning #Algorithm::IterateRequest::NO, and all the others return the same value or #Algorithm::IterateRequest::WHATEVER, then this method returns #IterateRequest::NO. In case two algorithms have conflicting iteration requests (e.g. one returns #Algorithm::IterateRequest::YES and another #Algorithm::IterateRequest::NO) then the IterateRequest::ERROR value is returned.

If no algorithm makes a definite iteration request (i.e. if all the algorithms return #Algorithm::IterateRequest::WHATEVER) then #IterateRequest::NO is returned.

Returns
an IterateRequest value summarizing the iteration requests of algorithms.

◆ Run()

bool EA::EventLoop::Run ( )

The actual event loop.

Runs all the algorithms added by AddAlgorithm. For each event it:

  • sets the number of current event in all the data providers
  • initializes event-level persistence
  • runs all the algorithms
  • finalizes event-level persistence

If any exception is thrown by an algorithm during processing it is caught and a false value is returned.

Returns
true if no processing error occurred.

◆ SetAlgorithms()

bool EA::EventLoop::SetAlgorithms ( std::unique_ptr< AlgoSequence > &&  algorithms)

Replaces the loop algorithm sequence with the given one.

Parameters
algorithmsThe new algorithm sequence.
Returns
false if the given pointer is null.

◆ SetDataProviderManager()

bool EA::EventLoop::SetDataProviderManager ( observer_ptr< DataProviderManager dpManager)

Set the data provider manager.

Parameters
dpManagerThe data provider manager
Returns
true if the data provider manager has been correctly set

◆ SetDataStoreManager()

bool EA::EventLoop::SetDataStoreManager ( observer_ptr< DataStoreManager dsManager)

Set the data store manager.

Parameters
dsManagerThe data store manager
Returns
true if the data store manager has been correctly set

◆ SetEventDataCacheManager()

bool EA::EventLoop::SetEventDataCacheManager ( observer_ptr< EventDataCacheManager ecManager)

Set the event data cache manager.

Parameters
ecManagerThe event data cache manager
Returns
true if event data cache manager has been correctly set

◆ SetPersistenceServiceManager()

bool EA::EventLoop::SetPersistenceServiceManager ( observer_ptr< PersistenceServiceManager psManager)

Set the persistence service manager.

Parameters
psManagerThe persistence service
Returns
true if the persistence service manager has been successfully set.

Friends And Related Function Documentation

◆ EventLoopProxy

friend class EventLoopProxy
friend

Member Data Documentation

◆ _algorithms

std::unique_ptr<AlgoSequence> EA::EventLoop::_algorithms
private

◆ _cachedObjs

CachedObjs EA::EventLoop::_cachedObjs
private

◆ _cachesToBeCleaned

CachedObjs EA::EventLoop::_cachesToBeCleaned
private

◆ _checkDataAvailability

bool EA::EventLoop::_checkDataAvailability
private

◆ _currentEvent

unsigned int EA::EventLoop::_currentEvent
private

◆ _currIter

unsigned int EA::EventLoop::_currIter
private

◆ _disabledProviders

std::vector<std::string> EA::EventLoop::_disabledProviders
private

◆ _dpManager

observer_ptr<DataProviderManager> EA::EventLoop::_dpManager
private

◆ _dsManager

observer_ptr<DataStoreManager> EA::EventLoop::_dsManager
private

◆ _ecManager

observer_ptr<EventDataCacheManager> EA::EventLoop::_ecManager
private

◆ _firstEvent

unsigned int EA::EventLoop::_firstEvent
private

◆ _loopProxy

EventLoopProxy EA::EventLoop::_loopProxy
private

◆ _nEvents

unsigned int EA::EventLoop::_nEvents
private

◆ _nProcessed

unsigned int EA::EventLoop::_nProcessed
private

◆ _passNumber

unsigned int EA::EventLoop::_passNumber
private

◆ _printModulo

int EA::EventLoop::_printModulo
private

◆ _psManager

observer_ptr<PersistenceServiceManager> EA::EventLoop::_psManager
private

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