template<typename T, class U>
class gmx::OptionTemplate< T, U >
Templated base class for constructing concrete option settings classes.
- Template Parameters
-
T | Assignable type that stores a single option value. |
U | Type of the derived class. |
This template is used as a base class like this:
All public functions in this class return *this
casted to a reference to U
. They do not throw.
For examples of how to use classes derived from this class, see the class documentation for Options.
|
| OptionTemplate (const char *name) |
| Initializes the name and default values for an option.
|
|
const T * | defaultValue () const |
| Returns a pointer to user-specified default value, or NULL if there is none.
|
|
const T * | defaultValueIfSet () const |
| Returns a pointer to user-specified default value, or NULL if there is none.
|
|
T * | store () const |
| Returns a pointer to the storage location, or NULL if none specified.
|
|
std::vector< T > * | storeVector () const |
| Returns a pointer to the storage vector, or NULL if none specified.
|
|
MyClass & | me () |
| Returns *this casted into MyClass to reduce typing.
|
|
| AbstractOption (const char *name) |
| Initializes the name and default values for an option.
|
|
virtual AbstractOptionStorage * | createStorage (const OptionManagerContainer &managers) const =0 |
| Creates a default storage object for the option. More...
|
|
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 | clearFlag (OptionFlag flag) |
| Clears a flag for the option.
|
|
void | setFlag (OptionFlag flag, bool bSet) |
| Sets or 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.
|
|
template<typename T, class U>
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.
template<typename T, class U>
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.
template<typename T, class U>
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.
template<typename T, class U>
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.
template<typename T, class U>
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.