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

#include <gromacs/selection/selectionoption.h>

+ Inheritance diagram for gmx::SelectionOption:
+ Collaboration diagram for gmx::SelectionOption:

Description

Specifies an option that provides selection(s).

Public methods in this class do not throw.

To use options of this type, SelectionOptionManager must first be added to the Options collection. For trajectory analysis tools, the framework takes care of this.

Todo:
Support for specifying that an option accepts, e.g., two to four selections. Currently, only a fixed count or any number of selections is possible.
Examples:
template.cpp.

Public Types

typedef SelectionOptionInfo InfoType
 OptionInfo subclass corresponding to this option type.
 
typedef Selection ValueType
 Type that stores a single option value.
 
typedef SelectionOption MyClass
 Alias for the derived class type.
 

Public Member Functions

 SelectionOption (const char *name)
 Initializes an option with the given name.
 
MyClassevaluateVelocities ()
 Request velocity evaluation for output positions. More...
 
MyClassevaluateForces ()
 Request force evaluation for output positions. More...
 
MyClassonlyAtoms ()
 Only accept selections that evaluate to atom positions.
 
MyClassonlySortedAtoms ()
 Only accept selections that evaluate to atom positions in sorted order.
 
MyClassonlyStatic ()
 Only accept static selections for this option.
 
MyClassdynamicMask ()
 Handle dynamic selections for this option with position masks. More...
 
MyClassallowEmpty ()
 Allow specifying an unconditionally empty selection for this option. More...
 
MyClassdefaultSelectionText (const char *text)
 Sets default selection text for the option. More...
 
MyClassdescription (const char *descr)
 Sets a description for the option. More...
 
MyClasshidden (bool bHidden=true)
 Hides the option from normal help output.
 
MyClassrequired (bool bRequired=true)
 Requires the option to be specified explicitly. More...
 
MyClassallowMultiple (bool bMulti=true)
 Allows the option to be specified multiple times.
 
MyClassvalueCount (int count)
 Requires exactly count values for the option.
 
MyClassmultiValue (bool bMulti=true)
 Allows any number of values for the option.
 
MyClassdefaultValue (const Selection &defaultValue)
 Sets a default value for the option. More...
 
MyClassdefaultValueIfSet (const Selection &defaultValue)
 Sets a default value for the option when it is set. More...
 
MyClassstore (Selection *store)
 Stores value(s) in memory pointed by store. More...
 
MyClassstoreCount (int *countptr)
 Stores number of values in the value pointed by countptr. More...
 
MyClassstoreVector (std::vector< Selection > *store)
 Stores option values in the provided vector. More...
 
MyClassstoreIsSet (bool *store)
 Stores whether the option was explicitly set. More...
 

Member Function Documentation

MyClass& gmx::SelectionOption::allowEmpty ( )
inline

Allow specifying an unconditionally empty selection for this option.

If this option is not set, selections that are unconditionally empty (i.e., can never match any atoms) result in errors. Note that even without this option, it is still possible that a dynamic selection evaluates to zero atoms for some frames.

MyClass& gmx::SelectionOption::defaultSelectionText ( const char *  text)
inline

Sets default selection text for the option.

If the option is not set by the user, the provided text is parsed as the value of the selection.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::defaultValue ( const Selection defaultValue)
inlineinherited

Sets a default value for the option.

Parameters
[in]defaultValueDefault value.

If the option is never set, the default value is copied to the assigned storage. Note that if the option is not set and there is no default value, the storage is not altered, which can also be used to provide a default value. The latter method has to be used if the option can take multiple values.

defaultValue is copied when the option is created.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::defaultValueIfSet ( const Selection defaultValue)
inlineinherited

Sets a default value for the option when it is set.

Parameters
[in]defaultValueDefault value.

This value is used if the option is set, but no value is provided. If the option is never set, the value set with defaultValue() is used. Can only be used for options that accept a single value.

defaultValue is copied when the option is created.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::description ( const char *  descr)
inlineinherited

Sets a description for the option.

Parameters
[in]descrDescription to set.

String in descr is copied when the option is created.

MyClass& gmx::SelectionOption::dynamicMask ( )
inline

Handle dynamic selections for this option with position masks.

See Also
Selection
SelectionPosition::selected()
MyClass& gmx::SelectionOption::evaluateForces ( )
inline

Request force evaluation for output positions.

See Also
Selection::setEvaluateForces()
MyClass& gmx::SelectionOption::evaluateVelocities ( )
inline

Request velocity evaluation for output positions.

See Also
Selection::setEvaluateVelocities()
MyClass& gmx::OptionTemplate< Selection , SelectionOption >::required ( bool  bRequired = true)
inlineinherited

Requires the option to be specified explicitly.

Note that if you specify defaultValue() together with required(), the user is not required to explicitly provide the option. In this case, required() only affects possible help output.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::store ( Selection store)
inlineinherited

Stores value(s) in memory pointed by store.

Parameters
[in]storeStorage for option value(s).

The caller is responsible for allocating enough memory such that the any allowed number of values fits into the array pointed by store. If there is no maximum allowed number or if the maximum is inconveniently large, storeVector() should be used.

For information on when values are available in the storage, see storeVector().

The pointer provided should remain valid as long as the associated Options object exists.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::storeCount ( int *  countptr)
inlineinherited

Stores number of values in the value pointed by countptr.

Parameters
[in]countptrStorage for the number of values.

For information on when values are available in the storage, see storeVector().

The pointers provided should remain valid as long as the associated Options object exists.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::storeIsSet ( bool *  store)
inlineinherited

Stores whether the option was explicitly set.

Parameters
[in]storeVariable to store the flag in.

The value is set to false on creation of the option, and to true as soon as a value is assigned to the option. A default value does not set the flag to true, but assignment that uses defaultValueIfSet() does.

The pointer provided should remain valid as long as the associated Options object exists.

MyClass& gmx::OptionTemplate< Selection , SelectionOption >::storeVector ( std::vector< Selection > *  store)
inlineinherited

Stores option values in the provided vector.

Parameters
[in]storeVector to store option values in.

Values are added to the vector after each successful set of values is parsed. Note that for some options, the value may be changed later, and is only guaranteed to be correct after Options::finish() has been called.

The pointer provided should remain valid as long as the associated Options object exists.


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