EventAnalysis
1.3.1
|
Interface for a configurable class. More...
#include <Configurable.h>
Classes | |
class | Representation |
Public Member Functions | |
Configurable () | |
Constructor. More... | |
template<typename T > | |
bool | SetParameter (const std::string &name, const T &value) |
Set the value of a parameter and then calls a callback function. More... | |
bool | SetParameter (const std::string &name, const char *value) |
Set the value of a string parameter using a string literal and then calls an eventual callback function. More... | |
std::vector< std::string > | GetParameters () |
Get the names of the parameters. More... | |
bool | AddSubConfigurable (EA::observer_ptr< Configurable > subConfigurable) |
Adds a sub-configurable. More... | |
Protected Member Functions | |
template<typename T > | |
bool | DefineParameter (const std::string &name, T &variable, std::function< bool()> callBack={}) |
Set a parameter. More... | |
Configurable (const std::shared_ptr< Representation > &impl) | |
std::shared_ptr< Representation > & | GetRepresentation () |
Private Attributes | |
std::shared_ptr< Representation > | _repr |
Interface for a configurable class.
This class provides the interface for defining a map between names (strings) and actual variables, and for setting values of the variables via their names. Children classes can expose their internal variables with DefineParameter, and users can set these values by calling SetParameter.
To ease the composition of configurable objects a set of sub-configurables can be defined: their parameters can be set as if they were parameter of the configurable object containing them.
EA::Configurable::Configurable | ( | ) |
Constructor.
|
inlineprotected |
bool EA::Configurable::AddSubConfigurable | ( | EA::observer_ptr< Configurable > | subConfigurable | ) |
Adds a sub-configurable.
A sub-configurable is a configurable object to which the settings of parameters not belonging to this configurable will be forwarded. Several sub-configurables can be added to a configurable.
subConfigurable | Pointer to the sub-configurable. |
|
protected |
Set a parameter.
This method associates a name with a variable, making it possible to set its value by means of SetValue. If a callback function is specified then it will be called by SetParameter after setting the parameter.
name | The name of the parameter. |
variable | The variable that will store the parameter value. |
callBack | The callback function. |
std::vector< std::string > EA::Configurable::GetParameters | ( | ) |
Get the names of the parameters.
This method returns a list of the names of the parameters of the Configurable object and all its sub-configurables.
|
inlineprotected |
bool EA::Configurable::SetParameter | ( | const std::string & | name, |
const T & | value | ||
) |
Set the value of a parameter and then calls a callback function.
The method sets the value for a parameter previously defined by DefineParameter and then calls an eventual callback function.
name | The name of the parameter. |
value | The new value for the parameter. |
bool EA::Configurable::SetParameter | ( | const std::string & | name, |
const char * | value | ||
) |
Set the value of a string parameter using a string literal and then calls an eventual callback function.
Overload of template SetValue for setting the value of an std::string parameter using a const char* string literal (needed to circumvent troubles with template substitution and type mismatch) and then calling a callback function.
name | The name of the parameter. |
value | The new value for the parameter. |
|
private |