EventAnalysis  1.0.0
EventLoop.h
Go to the documentation of this file.
1 /*
2  * EventLoop.h
3  *
4  * Created on: 29 May 2017
5  * Author: Nicola Mori
6  */
7 
10 #ifndef EVENTLOOP_H_
11 #define EVENTLOOP_H_
12 
13 #include "algorithm/AlgoSequence.h"
14 #include "algorithm/Algorithm.h"
17 #include "data/DataStoreManager.h"
20 
21 namespace EA {
22 
23 class EventLoopProxy;
24 
32 class EventLoop : public Configurable {
33 public:
39  EventLoop(unsigned int firstEvent = 0, unsigned int nEvents = 0);
40 
47 
54 
61 
68 
78  bool AddAlgorithm(std::unique_ptr<Algorithm> algo);
79 
85  bool SetAlgorithms(std::unique_ptr<AlgoSequence> &&algorithms);
86 
92 
105  bool CacheEventObject(const std::string &objName, const std::string &storeName);
106 
115  bool CleanEventCache(const std::string &objName, const std::string &storeName);
116 
129  bool Initialize(unsigned int passNumber, unsigned int iterNumber);
130 
141  bool Run();
142 
147  unsigned int GetFirstEvent();
148 
154  unsigned int GetNEvents();
155 
164  unsigned int GetNProcessed();
165 
174  bool Finalize();
175 
176  enum class IterateRequest { YES, NO, ERROR };
177 
197 
198 private:
199  friend class EventLoopProxy;
201 
206  std::unique_ptr<AlgoSequence> _algorithms;
207  using CachedObjs = std::list<std::pair<std::string, std::string>>;
210 
211  unsigned int _passNumber;
212  unsigned int _currIter;
213  unsigned int _currentEvent;
214  unsigned int _firstEvent;
215  unsigned int _nEvents;
216  unsigned int _nProcessed;
219 };
220 
221 } // namespace EA
222 
223 #endif /* EVENTLOOP_H_ */
bool SetPersistenceServiceManager(observer_ptr< PersistenceServiceManager > psManager)
Set the persistence service manager.
Definition: EventLoop.cpp:56
bool CleanEventCache(const std::string &objName, const std::string &storeName)
Cleans the cache for the given object.
Definition: EventLoop.cpp:89
AlgoSequence & GetAlgorithms()
Get the algorithm sequence in the loop.
Definition: EventLoop.h:91
bool SetDataProviderManager(observer_ptr< DataProviderManager > dpManager)
Set the data provider manager.
Definition: EventLoop.cpp:29
unsigned int _nProcessed
Definition: EventLoop.h:216
observer_ptr< DataStoreManager > _dsManager
Definition: EventLoop.h:203
bool Run()
The actual event loop.
Definition: EventLoop.cpp:235
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
IterateRequest Iterate()
Signals whether the event loop has to be reiterated or not.
Definition: EventLoop.cpp:372
CachedObjs _cachedObjs
Definition: EventLoop.h:208
bool SetAlgorithms(std::unique_ptr< AlgoSequence > &&algorithms)
Replaces the loop algorithm sequence with the given one.
Definition: EventLoop.cpp:74
EventLoopProxy _loopProxy
Definition: EventLoop.h:200
observer_ptr< PersistenceServiceManager > _psManager
Definition: EventLoop.h:205
unsigned int _nEvents
Definition: EventLoop.h:215
Algorithm made by multiple basic algorithms.
Definition: AlgoSequence.h:37
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
bool CacheEventObject(const std::string &objName, const std::string &storeName)
Caches the given object.
Definition: EventLoop.cpp:82
CachedObjs _cachesToBeCleaned
Definition: EventLoop.h:209
bool _checkDataAvailability
Definition: EventLoop.h:218
bool Initialize(unsigned int passNumber, unsigned int iterNumber)
Initializes the loop.
Definition: EventLoop.cpp:96
bool Finalize()
Finalizes the loop.
Definition: EventLoop.cpp:341
bool SetDataStoreManager(observer_ptr< DataStoreManager > dsManager)
Set the data store manager.
Definition: EventLoop.cpp:38
unsigned int GetNEvents()
Returns the number of events to be processed.
Definition: EventLoop.cpp:337
EventLoop(unsigned int firstEvent=0, unsigned int nEvents=0)
Constructor.
Definition: EventLoop.cpp:21
int _printModulo
Definition: EventLoop.h:217
A proxy class for EventLoop objects.
Definition: EventLoopProxy.h:24
unsigned int _currIter
Definition: EventLoop.h:212
unsigned int GetFirstEvent()
Returns the first event to be processed.
Definition: EventLoop.cpp:335
observer_ptr< DataProviderManager > _dpManager
Definition: EventLoop.h:202
unsigned int _passNumber
Definition: EventLoop.h:211
bool AddAlgorithm(std::unique_ptr< Algorithm > algo)
Add an algorithm to the loop.
Definition: EventLoop.cpp:64
observer_ptr< EventDataCacheManager > _ecManager
Definition: EventLoop.h:204
std::list< std::pair< std::string, std::string > > CachedObjs
Definition: EventLoop.h:207
bool SetEventDataCacheManager(observer_ptr< EventDataCacheManager > ecManager)
Set the event data cache manager.
Definition: EventLoop.cpp:47
std::unique_ptr< AlgoSequence > _algorithms
Definition: EventLoop.h:206
Interface for a configurable class.
Definition: Configurable.h:25
Interface for event loop classes.
Definition: EventLoop.h:32
unsigned int GetNProcessed()
Returns the number of processed events.
Definition: EventLoop.cpp:339
IterateRequest
Definition: EventLoop.h:176
unsigned int _currentEvent
Definition: EventLoop.h:213
unsigned int _firstEvent
Definition: EventLoop.h:214