EventAnalysis  1.0.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
EA::ObjectConsumer Class Reference

Interface for a class which consumes data objects. More...

#include <ObjectConsumer.h>

Inheritance diagram for EA::ObjectConsumer:
EA::Algorithm EA::PersistenceService EA::AlgoSequence EA::PersistenceAlgo EA::RootPersistenceService EA::AlgoSequenceDecorator EA::GarbageCollectorDecorator

Classes

struct  ConsumedObject
 Descriptor structure for a consumed object. More...
 
class  Representation
 
class  UndeclaredObject
 Exception class for using undeclared objects as parameters of DeclareAlternative. More...
 

Public Types

using ConsumedObjects = std::vector< ConsumedObject >
 Type for container of produced objects. More...
 

Public Member Functions

 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

 ObjectConsumer (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 

Private Attributes

std::shared_ptr< Representation_repr
 

Detailed Description

Interface for a class which consumes data objects.

This class provides the interface for declaring and retrieving the data objects consumed by a derived class.

Member Typedef Documentation

◆ ConsumedObjects

Type for container of produced objects.

Constructor & Destructor Documentation

◆ ObjectConsumer() [1/2]

EA::ObjectConsumer::ObjectConsumer ( )
inline

Constructor.

◆ ObjectConsumer() [2/2]

EA::ObjectConsumer::ObjectConsumer ( const std::shared_ptr< Representation > &  impl)
inlineprotected

Member Function Documentation

◆ DeclareAlternative()

void EA::ObjectConsumer::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.

Alternative objects are sets of objects among which at least one should be available for the consumer. Before declaring two objects as alternative they must have been previously declared:

consumer.DeclareConsumedObject("obj1", ObjectCategory::Event, "evStore");
consumer.DeclareConsumedObject("obj2", ObjectCategory::Event, "evStore");
consumer.DeclareAlternative("obj1", ObjectCategory::Event, "evStore", "obj2", ObjectCategory::Event, "evStore");

The above code states that consumer will consume at least one among obj1 and obj2. Other objects can be added as alternatives:

consumer.DeclareConsumedObject("obj3", ObjectCategory::Event, "evStore");
consumer.DeclareAlternative("obj1", ObjectCategory::Event, "evStore", "obj3", ObjectCategory::Event, "evStore");

obj3 will be an alternative to obj1, and also to obj2 since obj1 was already an alternative to obj2.

If either one between the object and the alternative object given as parameters is missing then a #UndeclaredObject exception is thrown.

Parameters
nameThe name of the object.
categoryThe category of the object.
storeThe store where the object will be fetched.
alternativeNameThe name of the alternative object.
alternativeCategoryThe category of the alternative object.
alternativeStoreThe store where the alternative object will be fetched.
Exceptions
UndeclaredObjectif either the object or the alternative have not been declared yet.

◆ DeclareConsumedObject()

void EA::ObjectConsumer::DeclareConsumedObject ( std::string  name,
ObjectCategory  category,
std::string  store,
bool  optional = false 
)

Declare a consumed objects.

This method adds an object to the list of the ones consumed by the consumer. The declaration fails if an object with the same name and store has already been declared or if one argument has a bad value (e.g. "" for name or NONE for category). In this case an exception is thrown.

Parameters
nameThe name of the object. Can also be an alias.
categoryThe category of the object.
storeThe store where the object is placed (can be "").
optionalif true the the declared object will be flagged as optional.
Exceptions
EA::Exceptionif the declaration fails.

◆ GetConsumedObjects()

const ConsumedObjects& EA::ObjectConsumer::GetConsumedObjects ( ) const
inline

Getter method for consumed objects.

This method returns a container with descriptors for the objects that the class produces. The default implementation returns an empty container.

Returns
The descriptors for the consumed objects.

◆ GetRepresentation()

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

Member Data Documentation

◆ _repr

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

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