Class strategy::GDParameters
Methods
load()
Declaration
void strategy::GDParameters::load(const utils::Structure¶ms)
configure()
configure the object from input
Initialize the object's state from the input utils::Config
. This is done by declaring which required and optional parameters are associated with the fields of this object. During initialization, they are checked for their presence, type and any matchers.
Example:
MyClass : public Component {
public:
void configure(const utils::Json& json) override {
this->param(json, "number", my_number)
.description("some description")
.matches(GreaterEquals(0))
.required();
this->param(json, "name", my_name)
.description("some description")
.matches(SizeIs(GreaterThan(0)))
.default_value("no_name");
}
private:
int my_number;
std::string my_name;
}
MyClass my_object;
my_object.configure(utils::json_from_string(R"(
{
"number": 42,
"name": "hello"
}
)"));
Note
By default, nothing is configured from input. You need to overload this method if you want to use this functionality. Don't forget to call the configure method of the parent class if it also needs to be configured (this is not the case for utils::Component
itself).
HINT: Parameters are not limited to scalars and strings; Any component can be a parameter; in which case it is initialized using its own configure method.
utils::Json
Declaration
void strategy::GDParameters::configure(const utils::Json¶ms) override
to_string()
Declaration
std::string strategy::GDParameters::to_string() const