Gromacs
2026.0-dev-20241204-d69d709
|
#include <gromacs/options/optionstoragetemplate.h>
Simplified option storage template for options that have one-to-one value conversion.
T | Assignable type that stores a single option value. |
To implement an option that always map a single input value to a single output value, derive from this class instead of OptionStorageTemplate. This class implements convertValue() in terms of two new virtual methods: initConverter() and processValue().
To specify how different types of values need to be converted, implement initConverter(). To do common post-processing of the values after conversion, but before they are added to the underlying storage, override processValue().
Public Types | |
typedef OptionStorageTemplateSimple< T > | MyBase |
Alias for the template class for use in base classes. | |
Public Types inherited from gmx::OptionStorageTemplate< T > | |
typedef OptionStorageTemplate< T > | MyBase |
Alias for the template class for use in base classes. | |
typedef std::vector< T > | ValueList |
Type of the container that contains the current values. | |
Protected Types | |
typedef OptionValueConverterSimple< T > | ConverterType |
Alias for the converter parameter type for initConverter(). | |
Protected Types inherited from gmx::OptionStorageTemplate< T > | |
typedef std::unique_ptr < IOptionValueStore< T > > | StorePointer |
Smart pointer for managing the final storage interface. | |
Protected Member Functions | |
template<class U > | |
OptionStorageTemplateSimple (const OptionTemplate< T, U > &settings, OptionFlags staticFlags=OptionFlags()) | |
Initializes the storage. | |
OptionStorageTemplateSimple (const AbstractOption &settings, typename OptionStorageTemplate< T >::StorePointer store) | |
Initializes the storage. | |
std::vector< Any > | normalizeValues (const std::vector< Any > &values) const override |
Converts given values to native representation for this option. More... | |
virtual void | initConverter (ConverterType *converter)=0 |
Specifies how different types are converted. More... | |
virtual T | processValue (const T &value) const |
Post-processes a value after conversion to the output type. More... | |
virtual Any | normalizeValue (const T &value) const |
Converts a single value to normalized type. More... | |
Protected Member Functions inherited from gmx::OptionStorageTemplate< T > | |
template<class U > | |
OptionStorageTemplate (const OptionTemplate< T, U > &settings, OptionFlags staticFlags=OptionFlags()) | |
Initializes the storage from option settings. More... | |
OptionStorageTemplate (const AbstractOption &settings, StorePointer store) | |
Initializes the storage from base option settings. More... | |
void | clearSet () override |
Removes all values from temporary storage for a set. More... | |
virtual void | processSetValues (ValueList *values) |
Processes values for a set after all have been converted. More... | |
void | processSet () override |
Performs validation and/or actions once a set of values has been added. More... | |
void | processAll () override |
Performs validation and/or actions once all values have been added. More... | |
virtual std::string | formatSingleValue (const T &value) const =0 |
Formats a single value as a string. More... | |
void | addValue (const T &value) |
Adds a value to a temporary storage. More... | |
void | commitValues () |
Commits values added with addValue(). More... | |
void | setDefaultValue (const T &value) |
Sets the default value for the option. More... | |
void | setDefaultValueIfSet (const T &value) |
Sets the default value if set for the option. More... | |
ArrayRef< T > | values () |
Provides derived classes access to the current list of values. More... | |
ArrayRef< const T > | values () const |
Provides derived classes access to the current list of values. | |
Protected Member Functions inherited from gmx::AbstractOptionStorage | |
AbstractOptionStorage (const AbstractOption &settings, OptionFlags staticFlags) | |
Initializes the storage object from the settings object. More... | |
void | markAsSet () |
Marks the option as set. | |
bool | hasFlag (OptionFlag flag) const |
Returns true if the given flag is set. | |
void | setFlag (OptionFlag flag) |
Sets the given flag. | |
void | clearFlag (OptionFlag flag) |
Clears the given flag. | |
void | setMinValueCount (int count) |
Sets a new minimum number of values required in one set. More... | |
void | setMaxValueCount (int count) |
Sets a new maximum number of values required in one set. More... | |
Additional Inherited Members | |
Public Member Functions inherited from gmx::OptionStorageTemplate< T > | |
std::string | typeString () const override=0 |
Returns a short string describing the type of the option. | |
int | valueCount () const override |
Returns the number of option values added so far. More... | |
std::vector< Any > | defaultValues () const override |
Returns the default value(s) of the option. More... | |
std::vector< std::string > | defaultValuesAsStrings () const override |
Returns the default value(s) of the option as strings. More... | |
Public Member Functions inherited from gmx::AbstractOptionStorage | |
bool | isSet () const |
Returns true if the option has been set. | |
bool | isBoolean () const |
Returns true if the option is a boolean option. More... | |
bool | isHidden () const |
Returns true if the option is a hidden option. | |
bool | isRequired () const |
Returns true if the option is required. | |
bool | isVector () const |
Returns true if the option is vector-valued. | |
const std::string & | name () const |
Returns the name of the option. | |
const std::string & | description () const |
Returns the description of the option set by the calling code. | |
bool | defaultValueIfSetExists () const |
Returns true if defaultValueIfSet() value is specified. | |
int | minValueCount () const |
Returns the minimum number of values required in one set. | |
int | maxValueCount () const |
Returns the maximum allowed number of values in one set (-1 = no limit). | |
virtual OptionInfo & | optionInfo ()=0 |
Returns an option info object corresponding to this option. | |
virtual std::string | formatExtraDescription () const |
Formats additional description for the option. More... | |
void | startSource () |
Starts adding values from a new source for the option. More... | |
void | startSet () |
Starts adding a new set of values for the option. More... | |
void | appendValue (const Any &value) |
Adds a new value for the option. More... | |
void | finishSet () |
Performs validation and/or actions once a set of values has been added. More... | |
void | finish () |
Performs validation and/or actions once all values have been added. More... | |
|
protectedpure virtual |
Specifies how different types are converted.
See OptionValueConverterSimple for more details.
|
inlineprotectedvirtual |
Converts a single value to normalized type.
[in] | value | Value after conversion. |
This can be overridden to serialize a different type than T
when using the option with KeyValueTreeObject.
Reimplemented in gmx::EnumOptionStorage.
|
inlineoverrideprotectedvirtual |
Converts given values to native representation for this option.
For example, strings are parsed to the type that is actually used to store the options.
The return value only depends on the option type, not on the current value of the option, and the current value in the option is not changed.
Implements gmx::AbstractOptionStorage.
|
inlineprotectedvirtual |
Post-processes a value after conversion to the output type.
[in] | value | Value after conversion. |
The default implementation only provides an identity mapping.