A cache for event data object.
More...
#include <EventDataCache.h>
A cache for event data object.
This class caches the values of event objects taken from a given event data store in memory. Objects can be booked for caching, and the object values are retrieved from store and cached by the CacheValues method event by event. Cached values can then provided on a per-event basis on subsequent analysis passes.
◆ Cache
◆ ObjCacheMap
◆ EventDataCache()
Constructor.
Constructs the cache and attaches it to the given data store. If the data store already has a cache then an exception is thrown.
- Parameters
-
evStore | The event store containing data objects to be cached. |
- Exceptions
-
std::runtime_error | if the given data store already has a cache. |
◆ BookObject()
bool EA::EventDataCache::BookObject |
( |
const std::string & |
objName, |
|
|
unsigned int |
sizeHint = 1000 |
|
) |
| |
Books an object for caching.
Books an object for being cached. This method must be called before the beginning of the event loop. The given object must not have already been booked or cached in a previous analysis pass, otherwise the false value is returned.
- Parameters
-
objName | The object to be cached. |
sizeHint | Hint about the total number of values to be cached. |
- Returns
- true if no other object with the same name has been booked for caching and if the object has not been cached in a previous pass.
◆ CacheValues()
bool EA::EventDataCache::CacheValues |
( |
| ) |
|
Caches the value of the booked objects for the current event.
This method retrieves the booked objects from the event store and saves their value in the cache. It must be called at the end of event processing in order to save the object value after all the processing done by the algorithms. Calling this method for an already-booked object will generate an error, and the false value will be returned.
- Returns
- true if all the booked objects have been cached, false in case of errors.
◆ Clean()
bool EA::EventDataCache::Clean |
( |
const std::string & |
objName = "" | ) |
|
Cleans the cache of the given object.
This method unbooks the given object and deletes all its cached values. In case no object name is given then all the booked objects and cached values are removed.
- Returns
- false if the given object is not cached or if an error occurs, true otherwise.
◆ GetCachedValue()
Retrieves the cached value for the given object.
This method retrieves the cached value of the given object for the current event. If the retrieval operation is successful then the #wrapper argument is set to wrap the object value and RetrievalResult::SUCCESS is returned. The #wrapper argument will wrap nothing in case the retrieval operation is not successful. In this case, possible return values are:
RetrievalResult::NOTFOUND if the object is not present in the cache RetrievalResult::NOTAVAILABLE if the object is present in the cache but no cached value for the current event is available RetrievalResult::ERROR if any error occurs
- Parameters
-
objName | The name of the desired cached object. |
wrapper | Reference to a wrapper for the return value. |
- Returns
- a RetrievalResult code with the result of the retrieval operation.
◆ GetStoreName()
std::string EA::EventDataCache::GetStoreName |
( |
| ) |
|
Returns the name of the event store to which the cache is attached.
- Returns
- The name of the event store.
◆ SetCurrentEvent()
bool EA::EventDataCache::SetCurrentEvent |
( |
unsigned int |
event | ) |
|
Sets the current event.
To be called before #EndOfEvent.
- Parameters
-
event | The number of the current event. |
- Returns
- true if the current event has been correctly set.
◆ Unbook()
bool EA::EventDataCache::Unbook |
( |
const std::string & |
objName = "" | ) |
|
Unbooks the given object.
At the end of the processing pass the data caching is complete, so on subsequent passes the caching must be disabled for the already-cached objects. This method disables the caching for the given booked object (for all the objects if no object name is given), but preserves the cached values that can be accessed in subsequent analysis passes. If this method is called twice for the same event (e.g. in two iterations of a loop) then the cached values are updated.
- Parameters
-
objName | The name of the object to unbook. |
- Returns
- true if the unbooking is successful.
◆ _cacheMap
◆ _currEv
unsigned int EA::EventDataCache::_currEv |
|
private |
◆ _evStore
The documentation for this class was generated from the following files: