Gromacs
2025.0-dev-20241011-013a99c
|
#include <gromacs/selection/selectionoption.h>
Wrapper class for accessing and modifying selection option information.
Allows changes to a selection option after creation.
This class provides the necessary interface for changing, e.g., the number of allowed selections for a selection option after the option has been created with Options::addOption(). This is needed if the number or other flags are only known after other options have been parsed. The main advantage of this class over custom checks is that if used before interactive selection prompt, the interactive prompt is updated accordingly.
When using this class, the option should be initially created with the most permissive flags, and this class should be used to place restrictions where appropriate. Otherwise, values that are provided before adjustments will need to follow the more strict checks. In most cases in trajectory analysis (which is the main use case for selection options), the adjustments should be done in TrajectoryAnalysisModule::optionsFinished() for them to take place before interactive selection prompts.
An instance of this class for a selection option can be obtained with SelectionOption::getAdjuster() when the option is created.
Example use:
Public Member Functions | |
SelectionOptionInfo (SelectionOptionStorage *option) | |
Creates option info object for given storage object. More... | |
void | setValueCount (int count) |
Sets the number of selections allowed for the option. More... | |
void | setEvaluateVelocities (bool bEnabled) |
Sets whether this option evaluates velocities for positions. More... | |
void | setEvaluateForces (bool bEnabled) |
Sets whether this option evaluates forces for positions. More... | |
void | setOnlyAtoms (bool bEnabled) |
Sets whether this option accepts positions that come from multiple atoms. More... | |
void | setOnlyStatic (bool bEnabled) |
Sets whether this option accepts dynamic selections. More... | |
void | setDynamicMask (bool bEnabled) |
Sets whether this option uses position masks for dynamic selections. More... | |
Public Member Functions inherited from gmx::OptionInfo | |
template<class InfoType > | |
bool | isType () const |
Test whether the option is of a particular type. More... | |
template<class InfoType > | |
InfoType * | toType () |
Convert the info object to a particular type if the type is correct. More... | |
template<class InfoType > | |
const InfoType * | toType () const |
Convert the info object to a particular type if the type is correct. More... | |
bool | isSet () const |
Returns true if the option has been set. | |
bool | isHidden () const |
Returns true if the option is a hidden option. | |
bool | isRequired () const |
Returns true if the option is required. | |
int | minValueCount () const |
Returns the minimum number of values that this option accepts. | |
int | maxValueCount () const |
Returns the maximum number of values that this option accepts. | |
const std::string & | name () const |
Returns the name of the option. | |
std::string | type () const |
Returns the type of the option as a string. | |
std::string | formatDescription () const |
Returns the description of the option. | |
std::vector< Any > | defaultValues () const |
Returns the default value(s) of the option. More... | |
std::vector< std::string > | defaultValuesAsStrings () const |
Returns the default value(s) of the option as strings. More... | |
std::vector< Any > | normalizeValues (const std::vector< Any > &values) const |
Converts given values to native representation for this option. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from gmx::OptionInfo | |
OptionInfo (AbstractOptionStorage *option) | |
Wraps a given option object. More... | |
AbstractOptionStorage & | option () |
Returns the wrapped option storage object. | |
const AbstractOptionStorage & | option () const |
Returns the wrapped option storage object. | |
|
explicit |
Creates option info object for given storage object.
Does not throw.
void gmx::SelectionOptionInfo::setDynamicMask | ( | bool | bEnabled | ) |
Sets whether this option uses position masks for dynamic selections.
[in] | bEnabled | If true, the position masks are used. |
Does not throw.
void gmx::SelectionOptionInfo::setEvaluateForces | ( | bool | bEnabled | ) |
Sets whether this option evaluates forces for positions.
[in] | bEnabled | If true, forces are evaluated. |
Does not throw.
void gmx::SelectionOptionInfo::setEvaluateVelocities | ( | bool | bEnabled | ) |
Sets whether this option evaluates velocities for positions.
[in] | bEnabled | If true, velocities are evaluated. |
Does not throw.
void gmx::SelectionOptionInfo::setOnlyAtoms | ( | bool | bEnabled | ) |
Sets whether this option accepts positions that come from multiple atoms.
[in] | bEnabled | If true, the option accepts only positions that evaluate to atom positions. |
void gmx::SelectionOptionInfo::setOnlyStatic | ( | bool | bEnabled | ) |
Sets whether this option accepts dynamic selections.
[in] | bEnabled | If true, the option accepts only static selections. |
std::bad_alloc | if out of memory. |
InvalidInputError | if dynamic selections have already been provided. |
Strong exception safety guarantee.
void gmx::SelectionOptionInfo::setValueCount | ( | int | count | ) |
Sets the number of selections allowed for the option.
[in] | count | Number of allowed selections. |
std::bad_alloc | if out of memory. |
InvalidInputError | if values have already been provided and their count does not match. |