Gromacs
2018.1
|
Mock implementation of an option storage class for unit testing.
Provides facilities for checking that correct methods are called, and for controlling how they add values using the base class methods.
Public Member Functions | |
MockOptionStorage (const MockOption &settings) | |
Initializes the storage from option settings. More... | |
void | addDummyValue () |
Calls addValue("dummy") in the base class. | |
virtual gmx::OptionInfo & | optionInfo () |
Returns an option info object corresponding to this option. | |
virtual std::string | typeString () const |
Returns a short string describing the type of the option. | |
virtual std::string | formatSingleValue (const std::string &) const |
Formats a single value as a string. More... | |
virtual std::vector< gmx::Variant > | normalizeValues (const std::vector< gmx::Variant > &values) const |
virtual void | convertValue (const gmx::Variant &value) |
Adds a new value. More... | |
Public Member Functions inherited from gmx::OptionStorageTemplate< std::string > | |
virtual int | valueCount () const |
Returns the number of option values added so far. More... | |
virtual std::vector< Variant > | defaultValues () const |
virtual std::vector< std::string > | defaultValuesAsStrings () const |
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 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 Variant &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... | |
Additional Inherited Members | |
Public Types inherited from gmx::OptionStorageTemplate< std::string > | |
typedef OptionStorageTemplate < std::string > | MyBase |
Alias for the template class for use in base classes. | |
typedef std::vector< std::string > | ValueList |
Type of the container that contains the current values. | |
Protected Types inherited from gmx::OptionStorageTemplate< std::string > | |
typedef std::unique_ptr < IOptionValueStore < std::string > > | StorePointer |
Smart pointer for managing the final storage interface. | |
Protected Member Functions inherited from gmx::OptionStorageTemplate< std::string > | |
OptionStorageTemplate (const OptionTemplate< std::string, 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... | |
virtual void | clearSet () |
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... | |
virtual void | processSet () |
Performs validation and/or actions once a set of values has been added. More... | |
virtual void | processAll () |
Performs validation and/or actions once all values have been added. More... | |
void | addValue (const std::string &value) |
Adds a value to a temporary storage. More... | |
void | commitValues () |
Commits values added with addValue(). More... | |
void | setDefaultValue (const std::string &value) |
Sets the default value for the option. More... | |
void | setDefaultValueIfSet (const std::string &value) |
Sets the default value if set for the option. More... | |
ArrayRef< std::string > | values () |
Provides derived classes access to the current list of values. More... | |
ArrayRef< const std::string > | 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... | |
|
explicit |
Initializes the storage from option settings.
[in] | settings | Storage settings. |
|
inlinevirtual |
Adds a new value.
[in] | value | Value to convert. |
InvalidInputError | if value is not valid for this option or if there have been too many values in the set. |
This method may be called multiple times if the underlying option is defined to accept multiple values.
Derived classes should call addValue() after they have converted value
to the storage type. It is allowed to call addValue() more than once, or not at all. OptionsAssigner::appendValue() provides the same exception safety guarantee as this method, so it should be considered whether the implementation can be made strongly exception safe.
Implements gmx::OptionStorageTemplate< std::string >.
|
inlinevirtual |
Formats a single value as a string.
[in] | value | Value to format. |
value
formatted as a string.The derived class must provide this method to format values a strings. Called by defaultValuesAsStrings() to do the actual formatting.
Implements gmx::OptionStorageTemplate< std::string >.
|
inlinevirtual |
Implements gmx::AbstractOptionStorage.