Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions

#include <gromacs/selection/selectionoption.h>

+ Inheritance diagram for gmx::SelectionOptionInfo:
+ Collaboration diagram for gmx::SelectionOptionInfo:

Description

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:

Options options("example", "Example options");
info = options.addOption(SelectionOption("sel").storeVector(&sel)
.multiValue());
// < ... assign values to options ...>
if ( condition )
{
// Put limitations on the selections based on the condition,
// which can depend on other option values.
// Throws if input given so far violates the limitations.
info->setValueCount(2);
info->setOnlyStatic(true);
}
*

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< AnydefaultValues () 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< AnynormalizeValues (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...
 
AbstractOptionStorageoption ()
 Returns the wrapped option storage object.
 
const AbstractOptionStorageoption () const
 Returns the wrapped option storage object.
 

Constructor & Destructor Documentation

gmx::SelectionOptionInfo::SelectionOptionInfo ( SelectionOptionStorage option)
explicit

Creates option info object for given storage object.

Does not throw.

Member Function Documentation

void gmx::SelectionOptionInfo::setDynamicMask ( bool  bEnabled)

Sets whether this option uses position masks for dynamic selections.

Parameters
[in]bEnabledIf true, the position masks are used.

Does not throw.

See Also
SelectionOption::dynamicMask()
void gmx::SelectionOptionInfo::setEvaluateForces ( bool  bEnabled)

Sets whether this option evaluates forces for positions.

Parameters
[in]bEnabledIf true, forces are evaluated.

Does not throw.

See Also
Selection::setEvaluateForces()
void gmx::SelectionOptionInfo::setEvaluateVelocities ( bool  bEnabled)

Sets whether this option evaluates velocities for positions.

Parameters
[in]bEnabledIf true, velocities are evaluated.

Does not throw.

See Also
Selection::setEvaluateVelocities()
void gmx::SelectionOptionInfo::setOnlyAtoms ( bool  bEnabled)

Sets whether this option accepts positions that come from multiple atoms.

Parameters
[in]bEnabledIf true, the option accepts only positions that evaluate to atom positions.
See Also
SelectionOption::onlyAtoms()
void gmx::SelectionOptionInfo::setOnlyStatic ( bool  bEnabled)

Sets whether this option accepts dynamic selections.

Parameters
[in]bEnabledIf true, the option accepts only static selections.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif dynamic selections have already been provided.

Strong exception safety guarantee.

See Also
SelectionOption::onlyStatic()
void gmx::SelectionOptionInfo::setValueCount ( int  count)

Sets the number of selections allowed for the option.

Parameters
[in]countNumber of allowed selections.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif values have already been provided and their count does not match.

The documentation for this class was generated from the following files: