10 #ifndef CONFIGURABLE_H_ 11 #define CONFIGURABLE_H_ 47 template <
typename T>
bool SetParameter(
const std::string &name,
const T &value);
59 bool SetParameter(
const std::string &name,
const char *value);
93 template <
typename T>
bool DefineParameter(
const std::string &name, T &variable, std::function<
bool()> callBack = {});
98 std::unordered_map<std::string, std::function<bool()>>
callBackMap;
106 std::shared_ptr<Representation>
_repr;
114 for (
auto &subConf :
_repr->subConfigurables) {
117 auto callBackIter =
_repr->callBackMap.find(name);
118 if (callBackIter !=
_repr->callBackMap.end()) {
119 return (callBackIter->second)();
127 auto callBackIter =
_repr->callBackMap.find(name);
128 if (callBackIter !=
_repr->callBackMap.end()) {
129 return (callBackIter->second)();
138 template <
typename T>
141 static_assert(!(std::is_array<T>::value),
"Can't use array as parameter");
142 static_assert(!(std::is_same<T, const char *>::value),
"Can't use const char * as parameter; use std::string");
144 for (
auto &subConf :
_repr->subConfigurables) {
151 _repr->callBackMap.emplace(name, callBack);
Configurable(const std::shared_ptr< Representation > &impl)
Definition: Configurable.h:102
Class describing a pointer to an object retrieved from an ObjectMap.
Definition: ObjPtr.h:31
bool SetParameter(const std::string &name, const T &value)
Set the value of a parameter and then calls a callback function.
Definition: Configurable.h:111
std::shared_ptr< Representation > _repr
Definition: Configurable.h:106
bool DefineParameter(const std::string &name, T &variable, std::function< bool()> callBack={})
Set a parameter.
Definition: Configurable.h:139
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
std::unordered_map< std::string, std::function< bool()> > callBackMap
Definition: Configurable.h:98
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
Definition: Configurable.h:95
A map between strings and objects of ObjectWrapper kind.
Definition: ObjectMap.h:32
Configurable()
Constructor.
Definition: Configurable.cpp:14
std::vector< observer_ptr< Configurable > > subConfigurables
Definition: Configurable.h:99
bool AddSubConfigurable(EA::observer_ptr< Configurable > subConfigurable)
Adds a sub-configurable.
Definition: Configurable.cpp:57
std::vector< std::string > GetParameters()
Get the names of the parameters.
Definition: Configurable.cpp:44
ObjectMap paramsMap
Definition: Configurable.h:97
Interface for a configurable class.
Definition: Configurable.h:33
std::shared_ptr< Representation > & GetRepresentation()
Definition: Configurable.h:103