Gromacs  2016.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...
 
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::string formatDefaultValueIfSet () const
 Returns the default value if set for the option as a string. More...
 
int valueCount () const
 Returns the number of values given for the option.
 
std::string formatValue (int i) const
 Returns the i'th value of the option as a string.
 

Constructor & Destructor Documentation

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

Creates option info object for given storage object.

Does not throw.

Member Function Documentation

std::string gmx::OptionInfo::formatDefaultValueIfSet ( ) const
inherited

Returns the default value if set for the option as a string.

See Also
OptionTemplate::defaultValueIfSet()
template<class InfoType >
bool gmx::OptionInfo::isType ( ) const
inlineinherited

Test whether the option is of a particular type.

Template Parameters
InfoTypeOption type to test for. Should be a class derived from OptionInfo.
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.
template<class InfoType >
InfoType* gmx::OptionInfo::toType ( )
inlineinherited

Convert the info object to a particular type if the type is correct.

Template Parameters
InfoTypeOption type to convert to. Should be a class derived from OptionInfo.
Return values
thisconverted to a pointer to InfoType, or NULL if the conversion is not possible.
template<class InfoType >
const InfoType* gmx::OptionInfo::toType ( ) const
inlineinherited

Convert the info object to a particular type if the type is correct.

Template Parameters
InfoTypeOption type to convert to. Should be a class derived from OptionInfo.
Return values
thisconverted to a pointer to InfoType, or NULL if the conversion is not possible.

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