Skip to content
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

Add utilities to map from parameter type to the type label #152

Closed
domire8 opened this issue Jan 10, 2024 · 1 comment · Fixed by #154
Closed

Add utilities to map from parameter type to the type label #152

domire8 opened this issue Jan 10, 2024 · 1 comment · Fixed by #154
Assignees
Labels
good first issue Good for newcomers

Comments

@domire8
Copy link
Member

domire8 commented Jan 10, 2024

state_representation has the Parameter object that can have different types, see the available types here. It would be great if we could have a human readable string associated with each parameter type such that we can be more precise when logging errors. For that, I propose to add under the parameters namespace some utilities:

/**
 * @brief Get a map of parameter type labels with the corresponding type
 * @return a map of parameter type labels with the corresponding type
 */
const std::map<std::string, ParameterType>& map();

/**
 * @brief Get the parameter type from the label
 * @param label The parameter type label (lowercase)
 * @throws std::out_of_range exception if the label has no corresponding type
 * @return the parameter type
 */
ParameterType parameter_type(const std::string& label);

/**
 * @brief Get the parameter type label from the type
 * @param id The parameter type
 * @return the parameter type label
 */
std::string label(ParameterType parameter_type);
@bpapaspyros
Copy link
Member

@domire8 I am not quite confident with the naming convention I followed (which is altered from the example), so let me know if this needs adjustments. There is also different conventions followed between DSE and the StateType for example.

bpapaspyros added a commit that referenced this issue Jan 10, 2024
(#152)

This will move the functions introduced in the previous commit to the
ParameterType.hpp header instead of the Parameter.hpp/.cpp. This makes
for a cleaner and context-specific organization.
bpapaspyros added a commit that referenced this issue Jan 11, 2024
(#152)

This will move the functions introduced in the previous commit to the
ParameterType.hpp header instead of the Parameter.hpp/.cpp. This makes
for a cleaner and context-specific organization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
2 participants