Commands are allowing to expand the entities. It has no real interest in C++, and is mostly targeted to scripting languages used to manipulate the control graph. dynamic-graph-python provides a mecanism which is automatically binding command to python. The main interest for a programmer is that there is no additional lines to add. It is realized through CMake rules provided by the submodule jrl-cmakemodules.
To modify a quantity with a special method of your class, it is recommanded to use Setter.
For instance to specify the size of the state in one entity and calls the method setStateSize it is possible to write:
Getting the information of the member of the class can be realized with the following snippet:
Templates are provided to create commands returning no value, but with up to 4 arguments.
In order to call the following method:
It is sufficient to add in the constructor:
The arguments are limited to the types provided by the class Value.
The templates with the prefix makeCommandReturnType are allowing to return a type.
For instance to add a command returning a type with two arguments:
In the constructor, the following snippet shows to create the command:
Of course calling in C++ a command amounts to call directly the method. However in the context of writing a wrapper for another language, one may wants to find a command and build the call.
All the commands of an entity are store in a map. The strings storing the commands name are the map keys.
Therefore calling the previous command can be done with the following snippet:
when returning a value the line with the call to execute is :