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

Algorithm made by multiple basic algorithms. More...

#include <AlgoSequence.h>

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

Classes

class  Representation
 

Public Types

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...
 

Public Member Functions

 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 Initialize ()
 Initializes all algorithms. More...
 
bool Process ()
 Processes all the algorithms. More...
 
bool Finalize ()
 Finalizes all algorithms and branches. 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

virtual bool ProcessAlgo (size_t iAlgo)
 Process the given algorithm. More...
 
 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::shared_ptr< Representation_repr
 

Friends

class AlgoSequenceDecorator
 

Detailed Description

Algorithm made by multiple basic algorithms.

An AlgoSequence is an algorithm made of a sequence of algorithms. The class has methods to add algorithms to the sequence and to apply them sequentially to each event.

AlgoSequence::Process is implemented following the template method pattern. Customization can be added by overriding the ProcessAlgo protected virtual method, to customize the processing of an algorithm.

Support for augmenting behavior with the decorator pattern is provided by the AlgoSequenceDecorator class that serves as the base class for decorators.

Technical note: see

https://www.codeproject.com/Articles/42163/Please-Don-t-Fail-Me-Decorator-Cries-Out-to-Templ

for details about how to tie together the template method pattern and the decorator pattern.

Member Typedef Documentation

◆ Algorithms

using EA::AlgoSequence::Algorithms = std::vector<std::unique_ptr<Algorithm> >

Type of underlying algorithm container.

◆ const_iterator

using EA::AlgoSequence::const_iterator = Algorithms::const_iterator

◆ iterator

using EA::AlgoSequence::iterator = Algorithms::iterator

Constructor & Destructor Documentation

◆ AlgoSequence() [1/2]

EA::AlgoSequence::AlgoSequence ( const std::string &  name)

Constructor.

Parameters
nameThe name of the sequence.

◆ AlgoSequence() [2/2]

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

Member Function Documentation

◆ AddAlgorithm()

bool EA::AlgoSequence::AddAlgorithm ( std::unique_ptr< Algorithm > &&  algo)

Adds a new algorithm to the sequence.

Algorithms will be processed in the same order they are added to the sequence. The AlgoSequence will own the algorithms (the user must not delete them, even if they are created with a "new" statement).

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

◆ begin() [1/2]

iterator EA::AlgoSequence::begin ( )
inline

◆ begin() [2/2]

const_iterator EA::AlgoSequence::begin ( ) const
inline

◆ end() [1/2]

iterator EA::AlgoSequence::end ( )
inline

◆ end() [2/2]

const_iterator EA::AlgoSequence::end ( ) const
inline

◆ Finalize()

bool EA::AlgoSequence::Finalize ( )
virtual

Finalizes all algorithms and branches.

Reimplemented from EA::Algorithm.

Reimplemented in EA::AlgoSequenceDecorator.

◆ GetAlgorithm()

observer_ptr< Algorithm > EA::AlgoSequence::GetAlgorithm ( const std::string  name)

Get an algorithm.

Retrieves an algorithm previously added to the loop with AddAlgorithm.

Parameters
nameThe name of the desired algorithm.
Returns
a pointer to the desired algorithm (points to NULL if the algorithm does not exist).

◆ GetAlgorithms() [1/2]

const std::vector< std::unique_ptr< Algorithm > > & EA::AlgoSequence::GetAlgorithms ( ) const

Get the algorithms.

Retrieves the algorithms in the sequence.

Returns
a reference to the vector of pointers to the algorithms.

◆ GetAlgorithms() [2/2]

std::vector< std::unique_ptr< Algorithm > > & EA::AlgoSequence::GetAlgorithms ( )

Get the algorithms.

Retrieves the algorithms in the sequence.

Returns
a reference to the vector of pointers to the algorithms.

◆ GetRepresentation()

std::shared_ptr<Representation>& EA::AlgoSequence::GetRepresentation ( )
inlineprotected

◆ Initialize()

bool EA::AlgoSequence::Initialize ( )
virtual

Initializes all algorithms.

After calling this method all the produced and consumed objects declared by the contained algorithms are declared also by the sequence.

Reimplemented from EA::Algorithm.

Reimplemented in EA::AlgoSequenceDecorator, and EA::GarbageCollectorDecorator.

◆ Iterate()

Algorithm::IterateRequest EA::AlgoSequence::Iterate ( )
virtual

Forward the iteration request to the contained algorithms.

This implementation asks for another iteration to all the contained algorithms. If at least one algorithm requires for another iteration by returning #IterateRequest::YES, and all the others return the same value or #IterateRequest::WHATEVER, then this method returns #IterateRequest::YES. If at least one algorithm forbids another iteration by returning #IterateRequest::NO, and all the others return the same value or #IterateRequest::WHATEVER, then this method returns #IterateRequest::NO. In case two algorithms have conflicting iteration requests (e.g. one returns #IterateRequest::YES and another #IterateRequest::NO) then the IterateRequest::ERROR value is returned.

Returns

Reimplemented from EA::Algorithm.

◆ Process()

bool EA::AlgoSequence::Process ( )
virtual

Processes all the algorithms.

The processing logic is the following. For each event, the algorithms are applied in the same order as they have been added to the sequence. When the filtering result of an algorithm (ie., the return of its GetFilterResult() method) is false, the processing stops. Note that this depends on the filter logic of the algorithm and on its filter status. If at least one algorithm returns a false filter result, then the filter flag of the sequence will be set to false (the actual value returned by AlgoSequence::GetFilterResult() is however dependent on filter logic set for the sequence object and its filter status, as it happens for VAlgorithm objects).

Returns
true if all processed algorithms return without errors, false otherwise.

Reimplemented from EA::Algorithm.

◆ ProcessAlgo()

bool EA::AlgoSequence::ProcessAlgo ( size_t  iAlgo)
protectedvirtual

Process the given algorithm.

This method can be called to execute the given algorithm in the sequence, to process algorithms one by one. It also sets the filter result for the sequence if the filter algorithm rejects the event.

Returns
The result of Process for the processed algorithm.

Reimplemented in EA::AlgoSequenceDecorator, and EA::GarbageCollectorDecorator.

◆ SetDataStoreManager()

bool EA::AlgoSequence::SetDataStoreManager ( observer_ptr< DataStoreManager dsManager)
virtual

Set the data store manager for the sequence and all the contained algorithms.

Parameters
dsManagerThe data store manager.
Returns
true if the data store manager has been correctly set for all the contained algorithms.

Reimplemented from EA::DataStoreUser.

◆ SetEventLoopProxy()

bool EA::AlgoSequence::SetEventLoopProxy ( observer_ptr< EventLoopProxy loopProxy)
virtual

Set the event loop proxy for the sequence and all the contained algorithms.

Parameters
loopProxyThe event loop proxy.
Returns
true if the event loop proxy has been correctly set for all the contained algorithms.

Reimplemented from EA::Algorithm.

◆ size()

size_t EA::AlgoSequence::size ( )
inline

Friends And Related Function Documentation

◆ AlgoSequenceDecorator

friend class AlgoSequenceDecorator
friend

Member Data Documentation

◆ _repr

std::shared_ptr<Representation> EA::AlgoSequence::_repr
private

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