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

A garbage collector decorator for an algorithm sequence. More...

#include <GarbageCollectorDecorator.h>

Inheritance diagram for EA::GarbageCollectorDecorator:
EA::AlgoSequenceDecorator EA::AlgoSequence EA::Algorithm EA::Filter EA::Info EA::Configurable EA::DataStoreUser EA::ObjectProducer EA::ObjectConsumer

Public Member Functions

 GarbageCollectorDecorator (std::unique_ptr< AlgoSequence > &&sequence, observer_ptr< PersistenceServiceManager > psManager=nullptr)
 Constructor. More...
 
bool Initialize () override
 Initializes the object deletion. More...
 
bool FreesUnused ()
 Gets the free unused flag. More...
 
- Public Member Functions inherited from EA::AlgoSequenceDecorator
 AlgoSequenceDecorator (std::unique_ptr< AlgoSequence > &&sequence)
 Constructor. More...
 
bool Finalize () override
 Finalizes the algorithms of the decorated sequence. More...
 
- Public Member Functions inherited from EA::AlgoSequence
 AlgoSequence (const std::string &name)
 Constructor. More...
 
bool AddAlgorithm (std::unique_ptr< Algorithm > &&algo)
 Adds a new algorithm to the sequence. More...
 
observer_ptr< AlgorithmGetAlgorithm (const std::string name)
 Get an algorithm. More...
 
const AlgorithmsGetAlgorithms () const
 Get the algorithms. More...
 
AlgorithmsGetAlgorithms ()
 Get the algorithms. More...
 
bool Process ()
 Processes all the algorithms. More...
 
IterateRequest Iterate ()
 Forward the iteration request to the contained algorithms. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size ()
 
bool SetDataStoreManager (observer_ptr< DataStoreManager > dsManager)
 Set the data store manager for the sequence and all the contained algorithms. More...
 
bool SetEventLoopProxy (observer_ptr< EventLoopProxy > loopProxy)
 Set the event loop proxy for the sequence and all the contained algorithms. More...
 
- Public Member Functions inherited from EA::Algorithm
 Algorithm (const std::string &name)
 
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...
 
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 Member Functions

bool ProcessAlgo (size_t iAlgo) override
 Process the given algorithm and eliminates the unneeded objects. More...
 
- Protected Member Functions inherited from EA::AlgoSequenceDecorator
observer_ptr< AlgoSequenceGetSequence ()
 Getter for the decorated sequence. More...
 
- Protected Member Functions inherited from EA::AlgoSequence
 AlgoSequence (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::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 ()
 

Private Attributes

observer_ptr< PersistenceServiceManager_psManager
 
std::vector< observer_ptr< ObjectConsumer > > _consumers
 
bool _freeUnused
 

Additional Inherited Members

- Public Types inherited from EA::AlgoSequence
using Algorithms = std::vector< std::unique_ptr< Algorithm > >
 Type of underlying algorithm container. More...
 
using iterator = Algorithms::iterator
 
using const_iterator = Algorithms::const_iterator
 
- 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...
 

Detailed Description

A garbage collector decorator for an algorithm sequence.

This decorator adds garbage collection capability to an AlgoSequence. The garbage collector will remove from data stores all those event objects that, after the execution of an algorithm, are not needed for any subsequent algorithm or persistence service. If the memory status is not NORMAL (see #Memory::Status) then the garbage collector will trigger a memory free for all the unused objects. This behavior can be turned off by setting the "freeUnused" parameter to false.

Constructor & Destructor Documentation

◆ GarbageCollectorDecorator()

EA::GarbageCollectorDecorator::GarbageCollectorDecorator ( std::unique_ptr< AlgoSequence > &&  sequence,
observer_ptr< PersistenceServiceManager psManager = nullptr 
)
inline

Constructor.

Parameters
sequenceThe sequence to decorate
psManagerThe persistence service manager (must be non-null only for the top-level sequence)

Member Function Documentation

◆ FreesUnused()

bool EA::GarbageCollectorDecorator::FreesUnused ( )
inline

Gets the free unused flag.

Returns
true if the garbage collector is configured to trigger a free of the memory of unused objects.

◆ Initialize()

bool EA::GarbageCollectorDecorator::Initialize ( )
overridevirtual

Initializes the object deletion.

This method prepares a list of objects that are needed after each step.

Returns
true if the list has been correctly prepared.

Reimplemented from EA::AlgoSequenceDecorator.

◆ ProcessAlgo()

bool EA::GarbageCollectorDecorator::ProcessAlgo ( size_t  iAlgo)
overrideprotectedvirtual

Process the given algorithm and eliminates the unneeded objects.

This method calls the ProcessAlgo method of the parent class and then removes the event objects that are no longer needed from the data stores. If the freeUnused parameter is set to true, and if the current memory status is not NORMAL then a call to #DataStoreManager::FreeRemoved will be triggered.

Returns
The result of Process for the processed algorithm.
See also
Memory::Status
DataStoreManager::FreeRemoved

Reimplemented from EA::AlgoSequenceDecorator.

Member Data Documentation

◆ _consumers

std::vector<observer_ptr<ObjectConsumer> > EA::GarbageCollectorDecorator::_consumers
private

◆ _freeUnused

bool EA::GarbageCollectorDecorator::_freeUnused
private

◆ _psManager

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

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