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

Base class for sequence decorators. More...

#include <AlgoSequenceDecorator.h>

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

Public Member Functions

 AlgoSequenceDecorator (std::unique_ptr< AlgoSequence > &&sequence)
 Constructor. More...
 
bool Initialize () override
 Initializes the algorithms of the decorated sequence. 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
 Hook for calling ProcessAlgo for the contained sequence. More...
 
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

std::unique_ptr< AlgoSequence_sequence
 

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

Base class for sequence decorators.

This class serves as the base for decorator classes for AlgoSequence. It is possible to decorate the methods Initialize, Finalize and ProcessAlgo (protected). The overrides in the derived decorator classes should call the corresponding methods of the base decorator class by means of the scope resolution operator, e.g.:

bool MyDecorator::Initialize(){ AlgoSequenceDecorator::Initialize(); // Decorator-specific code here }

and similarly for other overridden methods.

Technical note

it is not possible to decorate Process, since it calls ProcessAlgo. Indeed, implementing the forwarding method in the classical way:

bool Process() override { return _sequence->Process(); }

when the wrapped sequence is an AlgoSequence (and not another decorator) it will call AlgoSequence::Process passing this as an AlgoSequence*. Thus inside Process the polymorphic call to this->ProcessAlgo will call AlgoSequence::ProcessAlgo and not AlgoSequenceDecorator::ProcessAlgo. An alternative implementation would be:

bool Process() { if (typeid(AlgoSequence) == typeid(*_sequence)) { return this->AlgoSequence::Process(); } else { return _sequence->Process(); } }

This would call AlgoSequence::Process passing this as an AlgoSequenceDecorator*, and so inside Process all the polymorphic calls would be correctly redirected to AlgoSequenceDecorator methods. However, if more decorators are stacked up then only the ProcessAlgo method of the bottom one (i.e. of the one that wraps the AlgoSequence) will be called.

For this reason Process is considered a template method, thus it cannot be decorated.

Constructor & Destructor Documentation

◆ AlgoSequenceDecorator()

EA::AlgoSequenceDecorator::AlgoSequenceDecorator ( std::unique_ptr< AlgoSequence > &&  sequence)
inline

Constructor.

Parameters
sequenceThe decorated sequence.

Member Function Documentation

◆ Finalize()

bool EA::AlgoSequenceDecorator::Finalize ( )
inlineoverridevirtual

Finalizes the algorithms of the decorated sequence.

Returns
true if the finalization succeeds

Reimplemented from EA::AlgoSequence.

◆ GetSequence()

observer_ptr<AlgoSequence> EA::AlgoSequenceDecorator::GetSequence ( )
inlineprotected

Getter for the decorated sequence.

Returns
Pointer to the decorated sequence.

◆ Initialize()

bool EA::AlgoSequenceDecorator::Initialize ( )
inlineoverridevirtual

Initializes the algorithms of the decorated sequence.

Returns
true if the initialization succeeds

Reimplemented from EA::AlgoSequence.

Reimplemented in EA::GarbageCollectorDecorator.

◆ ProcessAlgo()

bool EA::AlgoSequenceDecorator::ProcessAlgo ( size_t  iAlgo)
inlineoverrideprotectedvirtual

Hook for calling ProcessAlgo for the contained sequence.

AlgoSequence::ProcessAlgo is protected; AlgoSequenceDecorator can call it since it is a friend of AlgoSequence, but classes derived from algoSequence cannot. Instead, they should call this method in their override of ProcessAlgo.

Returns
The result of Process for the processed algorithm.
See also
AlgoSequence::ProcessAlgo

Reimplemented from EA::AlgoSequence.

Reimplemented in EA::GarbageCollectorDecorator.

Member Data Documentation

◆ _sequence

std::unique_ptr<AlgoSequence> EA::AlgoSequenceDecorator::_sequence
private

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