#include <gromacs/options/basicoptions.h>
Specifies an option that provides floating-point (double) values.
Public methods in this class do not throw.
- Examples:
- template.cpp.
|
const double * | defaultValue () const |
| Returns a pointer to user-specified default value, or NULL if there is none.
|
|
const double * | defaultValueIfSet () const |
| Returns a pointer to user-specified default value, or NULL if there is none.
|
|
double * | store () const |
| Returns a pointer to the storage location, or NULL if none specified.
|
|
std::vector< double > * | storeVector () const |
| Returns a pointer to the storage vector, or NULL if none specified.
|
|
MyClass & | me () |
| Returns *this casted into MyClass to reduce typing.
|
|
void | setDescription (const char *descr) |
| Sets the description for the option.
|
|
void | setStoreIsSet (bool *store) |
| Sets the storage location for whether the option is set.
|
|
void | setFlag (OptionFlag flag) |
| Sets a flag for the option.
|
|
void | setFlag (OptionFlag flag, bool bSet) |
| Sets or clears a flag for the option.
|
|
void | clearFlag (OptionFlag flag) |
| Clears a flag for the option.
|
|
bool | isVector () const |
| Returns true if the option is vector-valued.
|
|
void | setVector () |
| Sets the option to be vector-valued. More...
|
|
void | setValueCount (int count) |
| Sets the required number of values for the option.
|
|
|
class | DoubleOptionStorage |
| Needed to initialize DoubleOptionStorage from this class without otherwise unnecessary accessors.
|
|
Sets a default value for the option.
- Parameters
-
[in] | defaultValue | Default 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.
Sets a default value for the option when it is set.
- Parameters
-
[in] | defaultValue | Default 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.
Sets a description for the option.
- Parameters
-
[in] | descr | Description to set. |
String in descr
is copied when the option is created.
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.
void gmx::AbstractOption::setVector |
( |
| ) |
|
|
inlineprotectedinherited |
Sets the option to be vector-valued.
This method is provided for convenience to make management of value counts easier. In order to implement a vector-valued option, the class derived from AbstractOption should expose a method that calls this method, and the storage object derived from AbstractOptionStorage should check isVector(). If only a single value is provided, the storage object should fill the whole vector with that value.
The length of the vector (the value of maxValueCount_) must be fixed. The default length is 3 elements.
Stores value(s) in memory pointed by store
.
- Parameters
-
[in] | store | Storage 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.
Stores number of values in the value pointed by countptr
.
- Parameters
-
[in] | countptr | Storage 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.
Stores whether the option was explicitly set.
- Parameters
-
[in] | store | Variable 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.
Stores option values in the provided vector.
- Parameters
-
[in] | store | Vector 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.
MyClass& gmx::DoubleOption::timeValue |
( |
| ) |
|
|
inline |
Marks this option as providing a time value whose unit can be changed.
By itself, this option does nothing. It marks the option as a time value such that TimeUnitManager::scaleTimeOptions() can process it. In typical cases, GROMACS scales the time options just before Options::finish() has been called, so the option value is only available after all option values have been processed. All values in the program are in ps (including any default value); user-provided values are scaled according to the time unit set in TimeUnitManager.
MyClass& gmx::DoubleOption::vector |
( |
| ) |
|
|
inline |
Sets the option to return a vector value.
A vector value returns a fixed number of values, the default being three (can be changed with valueCount()). However, it also accepts a single value, in which case the value is used to fill the whole vector.
The documentation for this class was generated from the following files:
- api/legacy/include/gromacs/options/basicoptions.h
- src/gromacs/options/basicoptions.cpp