-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decide how to proceed with the IParameterHandler interface #27
Comments
As discussed F2F, it is important to define the purpose of the class, in my opinion.
The On the other side, the implementation using
Depending on the application, the limitation on the number of supported types can apply or not. Clearly, when parsing a configuration file, given the limited set of things that can be written in a plain text file, it makes sense to support only a set of types. I don't think the same for the second category. To be honest, I prefer those solutions which fit better in the second category as they ease the definition of interfaces, basically mimicking the role of What remains open is then the parsing of the configuration files. In this regard, the Edit: |
Another way is to use parameters handler only for passing the parameters from a configuration file and having another class for storing the state and parameters in a class. By the way, I don't know if storing a variable inside an
|
That's true, also I don't like the fact that you would need to search the variable every time. It would be interesting to have a reference to a parameter, but
Sorry wrong link, I was referring to the method |
Ok, in this case, let's split the problem of having a parameter container inside the class from having a parameter handler for loading the parameter from a configuration file. |
According to this comment #27 (comment), we will have bool getParameter(const std::string& key, int& value);
bool getParameter(const std::string& key, double& value);
bool getParameter(const std::string& key, bool& value);
bool getParameter(const std::string& key, std::string& value);
bool getParameter(const std::string& key, std::span<int>& value);
bool getParameter(const std::string& key, std::span<double>& value);
bool getParameter(const std::string& key, std::span<bool>& value);
bool getParameter(const std::string& key, std::span<std::string>& value);
|
Using For this reason, I would drop the |
Otherwise, the user has to add the size of the parameter (i.e. the size of the vector) |
You can get the |
Btw, I didn't get this passage:
I believed that to remove |
Is the
For setting it shouldn't be a problem. bool setParameter(const std::string& key, std::span<int>& value); I hope it is easy to implement (I have to check) because the parameter is copied inside the handler
If bool foo::initialize(const iParameterHandler & handler); Notice here the template is no more required! Consequentially we can use pimpl again! |
At least for the yarp implementation, it should be simple. The Basi implementation has to be rewritten (probably we should drop std::unordered_map<std::string, bool> m_boolContainer;
std::unordered_map<std::string, std::vector<double>> m_doubleVectorContainer;
... |
That implementation has been strongly "inspired" by https://github.com/Microsoft/GSL/blob/master/include/gsl/span (the same from which https://github.com/tcbrindle/span was born, according to its README). I am pretty sure it works with an
Not so fast. If you set a
Sorry, you're right. I keep forgetting 😅 |
The
IParameterHandler
interface library is really useful to set and get the parameters however it has an enormous drawback.Given the implementation of the interface, a function that has as input the interface has to be template i.e.
or
https://github.com/dic-iit/bipedal-locomotion-controllers/blob/53b27be78e62fc8e3d5638043f014162fd5b3bee/src/Simulator/include/BipedalLocomotionControllers/Simulator/Simulator.tpp#L18-L26
The
IParametersHandler
is a template class because it is implemented using the CRTP pattern. The pattern is required to implement static polymorphism and consequentially to make the follwing line of codes compilingIndeed class member function template cannot be virtual., and in our case
getParameter()
is template to be compatible with different types (i.e.iDynTree::VectorDynSize
,int
,bool
,double
, ...).As discussed with @S-Dafarra having template consumer functions may over-complexify the code.
For this reason, I would like to find a solution to the problem.
Discussing with @traversaro and @S-Dafarra we found two possible solutions:
yarp
one and pass the parameter with that implementation.getParameter()
method may remain template and in theory, we guarantee the support to the different datatypes. On the other hand, all the libraries will depend on yarp and this is very sad given the effort to make the libraries yarp free.getParameter()
i.e.This issue is to discuss the actions that we should take for solving the presented problem.
Related discussions: #26 #7 (comment) #13 (comment)
The text was updated successfully, but these errors were encountered: