*/
AbstractOptionStorage::AbstractOptionStorage(const AbstractOption &settings,
- Options *options,
OptionFlags staticFlags)
: _flags(settings._flags | staticFlags),
_minValueCount(settings._minValueCount),
_maxValueCount(settings._maxValueCount),
- _inSet(false),
- _options(*options)
+ _inSet(false)
{
// If the maximum number of values is not known, storage to
// caller-allocated memory is unsafe.
* them. All error checking and memory management should be postponed to the
* point when the actual option is created.
*
- * Subclasses should override createDefaultStorage() to create the correct type
+ * Subclasses should override createStorage() to create the correct type
* of storage object.
*
* \ingroup module_options
/*! \brief
* Creates a default storage object for the option.
*
- * \param[in] options Option collection object.
* \returns The created storage object.
* \throws APIError if invalid option settings have been provided.
*
- * This method is called by when creating an option object
- * The \p options object is used to implement global properties.
+ * This method is called by Options::addOption() when initializing an
+ * option from the settings.
*
* Derived classes should implement the method to create an actual
* storage object and populate it with correct values.
*
* Should only be called by Options::addOption().
*/
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const = 0;
+ virtual AbstractOptionStoragePointer createStorage() const = 0;
/*! \brief
* Creates the description string for the option.
*/
friend class AbstractOptionStorage;
/*! \brief
- * Needed to be able to call createDefaultStorage().
+ * Needed to be able to call createStorage().
*/
friend class Options;
};
* Initializes the storage object from the settings object.
*
* \param[in] settings Option settings.
- * \param[in] options Option collection that will contain the
- * option.
* \param[in] staticFlags Option flags that are always set and specify
* generic behavior of the option.
* \throws APIError if invalid settings have been provided.
*/
- AbstractOptionStorage(const AbstractOption &settings, Options *options,
+ AbstractOptionStorage(const AbstractOption &settings,
OptionFlags staticFlags);
//! Returns true if the given flag is set.
*/
void setMaxValueCount(int count);
- //! Returns the Options object that houses the option.
- Options &hostOptions() { return _options; }
- //! \copydoc hostOptions()
- const Options &hostOptions() const { return _options; }
-
/*! \brief
* Removes all values from temporary storage for a set.
*
int _maxValueCount;
//! Whether we are currently assigning values to a set.
bool _inSet;
- //! Parent Options object.
- Options &_options;
GMX_DISALLOW_COPY_AND_ASSIGN(AbstractOptionStorage);
};
* BooleanOption
*/
-AbstractOptionStoragePointer BooleanOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer BooleanOption::createStorage() const
{
- return AbstractOptionStoragePointer(new BooleanOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new BooleanOptionStorage(*this));
}
* IntegerOption
*/
-AbstractOptionStoragePointer IntegerOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer IntegerOption::createStorage() const
{
- return AbstractOptionStoragePointer(new IntegerOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new IntegerOptionStorage(*this));
}
* DoubleOptionStorage
*/
-DoubleOptionStorage::DoubleOptionStorage(const DoubleOption &settings, Options *options)
- : MyBase(settings, options), info_(this), bTime_(settings._bTime), factor_(1.0)
+DoubleOptionStorage::DoubleOptionStorage(const DoubleOption &settings)
+ : MyBase(settings), info_(this), bTime_(settings._bTime), factor_(1.0)
{
}
* DoubleOption
*/
-AbstractOptionStoragePointer DoubleOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer DoubleOption::createStorage() const
{
- return AbstractOptionStoragePointer(new DoubleOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new DoubleOptionStorage(*this));
}
* StringOptionStorage
*/
-StringOptionStorage::StringOptionStorage(const StringOption &settings, Options *options)
- : MyBase(settings, options), _info(this), _enumIndexStore(NULL)
+StringOptionStorage::StringOptionStorage(const StringOption &settings)
+ : MyBase(settings), _info(this), _enumIndexStore(NULL)
{
if (settings._defaultEnumIndex >= 0 && settings._enumValues == NULL)
{
* StringOption
*/
-AbstractOptionStoragePointer StringOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer StringOption::createStorage() const
{
- return AbstractOptionStoragePointer(new StringOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new StringOptionStorage(*this));
}
std::string StringOption::createDescription() const
* FileNameOptionStorage
*/
-FileNameOptionStorage::FileNameOptionStorage(const FileNameOption &settings, Options *options)
- : MyBase(settings, options), info_(this), filetype_(settings.filetype_),
+FileNameOptionStorage::FileNameOptionStorage(const FileNameOption &settings)
+ : MyBase(settings), info_(this), filetype_(settings.filetype_),
bRead_(settings.bRead_), bWrite_(settings.bWrite_),
bLibrary_(settings.bLibrary_)
{
* FileNameOption
*/
-AbstractOptionStoragePointer FileNameOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer FileNameOption::createStorage() const
{
- return AbstractOptionStoragePointer(new FileNameOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new FileNameOptionStorage(*this));
}
} // namespace gmx
private:
//! Creates a BooleanOptionStorage object.
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
};
/*! \brief
private:
//! Creates an IntegerOptionStorage object.
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
/*! \brief
* Needed to initialize IntegerOptionStorage from this class without
private:
//! Creates a DoubleOptionStorage object.
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
bool _bTime;
private:
//! Creates a StringOptionStorage object.
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
virtual std::string createDescription() const;
const char *const *_enumValues;
private:
//! Creates a FileNameOptionStorage object.
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
OptionFileType filetype_;
bool bRead_;
* Initializes the storage from option settings.
*
* \param[in] settings Storage settings.
- * \param[in] options Options object.
*/
- BooleanOptionStorage(const BooleanOption &settings, Options *options)
- : MyBase(settings, options), info_(this)
+ explicit BooleanOptionStorage(const BooleanOption &settings)
+ : MyBase(settings), info_(this)
{
}
{
public:
//! \copydoc BooleanOptionStorage::BooleanOptionStorage()
- IntegerOptionStorage(const IntegerOption &settings, Options *options)
- : MyBase(settings, options), info_(this)
+ explicit IntegerOptionStorage(const IntegerOption &settings)
+ : MyBase(settings), info_(this)
{
}
{
public:
//! \copydoc IntegerOptionStorage::IntegerOptionStorage()
- DoubleOptionStorage(const DoubleOption &settings, Options *options);
+ explicit DoubleOptionStorage(const DoubleOption &settings);
virtual OptionInfo &optionInfo() { return info_; }
virtual const char *typeString() const;
{
public:
//! \copydoc DoubleOptionStorage::DoubleOptionStorage()
- StringOptionStorage(const StringOption &settings, Options *options);
+ explicit StringOptionStorage(const StringOption &settings);
virtual OptionInfo &optionInfo() { return _info; }
virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
{
public:
//! \copydoc StringOptionStorage::StringOptionStorage()
- FileNameOptionStorage(const FileNameOption &settings, Options *options);
+ explicit FileNameOptionStorage(const FileNameOption &settings);
virtual OptionInfo &optionInfo() { return info_; }
virtual const char *typeString() const { return "file"; }
void Options::addOption(const AbstractOption &settings)
{
- AbstractOptionStoragePointer option(settings.createDefaultStorage(this));
+ AbstractOptionStoragePointer option(settings.createStorage());
if (_impl->findOption(option->name().c_str()) != NULL)
{
GMX_THROW(APIError("Duplicate option: " + option->name()));
* Initializes the storage from option settings.
*
* \param[in] settings Option settings.
- * \param[in] options Option collection that will contain the
- * option.
* \param[in] staticFlags Option flags that are always set and specify
* generic behavior of the option.
* \throws APIError if invalid settings have been provided.
*/
template <class U>
- OptionStorageTemplate(const OptionTemplate<T, U> &settings, Options *options,
+ OptionStorageTemplate(const OptionTemplate<T, U> &settings,
OptionFlags staticFlags = OptionFlags());
template <typename T>
template <class U>
OptionStorageTemplate<T>::OptionStorageTemplate(const OptionTemplate<T, U> &settings,
- Options *options,
OptionFlags staticFlags)
- : AbstractOptionStorage(settings, options, staticFlags),
+ : AbstractOptionStorage(settings, staticFlags),
_values(settings._storeVector),
_store(settings._store),
_countptr(settings._countptr)
* Initializes the storage from option settings.
*
* \param[in] settings Storage settings.
- * \param[in] options Options object.
*/
- MockOptionStorage(const MockOption &settings, gmx::Options *options);
+ MockOptionStorage(const MockOption &settings);
/*! \brief
* Calls addValue("dummy") in the base class.
{ _storagePtr = storagePtr; return me(); }
private:
- virtual gmx::AbstractOptionStoragePointer createDefaultStorage(gmx::Options *options) const
+ virtual gmx::AbstractOptionStoragePointer createStorage() const
{
- MockOptionStorage *storage = new MockOptionStorage(*this, options);
+ MockOptionStorage *storage = new MockOptionStorage(*this);
if (_storagePtr != NULL)
{
*_storagePtr = storage;
MockOptionStorage **_storagePtr;
};
-MockOptionStorage::MockOptionStorage(const MockOption &settings, gmx::Options *options)
- : MyBase(settings, options)
+MockOptionStorage::MockOptionStorage(const MockOption &settings)
+ : MyBase(settings)
{
using ::testing::_;
using ::testing::Invoke;
* SelectionOptionStorage
*/
-SelectionOptionStorage::SelectionOptionStorage(const SelectionOption &settings,
- Options *options)
- : MyBase(settings, options,
- OptionFlags() | efNoDefaultValue | efDontCheckMinimumCount),
+SelectionOptionStorage::SelectionOptionStorage(const SelectionOption &settings)
+ : MyBase(settings, OptionFlags() | efNoDefaultValue | efDontCheckMinimumCount),
_info(this), _sc(NULL), _selectionFlags(settings._selectionFlags)
{
if (settings._infoPtr != NULL)
* SelectionOption
*/
-AbstractOptionStoragePointer SelectionOption::createDefaultStorage(Options *options) const
+AbstractOptionStoragePointer SelectionOption::createStorage() const
{
- return AbstractOptionStoragePointer(new SelectionOptionStorage(*this, options));
+ return AbstractOptionStoragePointer(new SelectionOptionStorage(*this));
}
using MyBase::defaultValue;
using MyBase::defaultValueIfSet;
- virtual AbstractOptionStoragePointer createDefaultStorage(Options *options) const;
+ virtual AbstractOptionStoragePointer createStorage() const;
SelectionFlags _selectionFlags;
SelectionOptionInfo **_infoPtr;
* Initializes the storage from option settings.
*
* \param[in] settings Storage settings.
- * \param[in] options Options object.
*/
- SelectionOptionStorage(const SelectionOption &settings, Options *options);
+ SelectionOptionStorage(const SelectionOption &settings);
virtual OptionInfo &optionInfo() { return _info; }
virtual const char *typeString() const { return "sel"; }