EventAnalysis
1.0.0
|
Interface for a class which consumes data objects. More...
#include <ObjectConsumer.h>
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 ConsumedObjects & | GetConsumedObjects () 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 |
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.
using EA::ObjectConsumer::ConsumedObjects = std::vector<ConsumedObject> |
Type for container of produced objects.
|
inline |
Constructor.
|
inlineprotected |
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:
The above code states that consumer
will consume at least one among obj1
and obj2
. Other objects can be added as alternatives:
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.
name | The name of the object. |
category | The category of the object. |
store | The store where the object will be fetched. |
alternativeName | The name of the alternative object. |
alternativeCategory | The category of the alternative object. |
alternativeStore | The store where the alternative object will be fetched. |
UndeclaredObject | if either the object or the alternative have not been declared yet. |
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.
name | The name of the object. Can also be an alias. |
category | The category of the object. |
store | The store where the object is placed (can be ""). |
optional | if true the the declared object will be flagged as optional. |
EA::Exception | if the declaration fails. |
|
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.
|
inlineprotected |
|
private |