/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2010-2018, The GROMACS development team.
+ * Copyright (c) 2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
class BooleanOption : public OptionTemplate<bool, BooleanOption>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef BooleanOptionInfo InfoType;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef BooleanOptionInfo InfoType;
- //! Initializes an option with the given name.
- explicit BooleanOption(const char *name) : MyBase(name) {}
+ //! Initializes an option with the given name.
+ explicit BooleanOption(const char* name) : MyBase(name) {}
- private:
- //! Creates a BooleanOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
+private:
+ //! Creates a BooleanOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
};
/*! \brief
*/
class IntegerOption : public OptionTemplate<int, IntegerOption>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef IntegerOptionInfo InfoType;
-
- //! Initializes an option with the given name.
- explicit IntegerOption(const char *name) : MyBase(name) {}
-
- /*! \brief
- * 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.
- */
- MyClass &vector() { setVector(); return me(); }
-
- private:
- //! Creates an IntegerOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
-
- /*! \brief
- * Needed to initialize IntegerOptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class IntegerOptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef IntegerOptionInfo InfoType;
+
+ //! Initializes an option with the given name.
+ explicit IntegerOption(const char* name) : MyBase(name) {}
+
+ /*! \brief
+ * 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.
+ */
+ MyClass& vector()
+ {
+ setVector();
+ return me();
+ }
+
+private:
+ //! Creates an IntegerOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
+
+ /*! \brief
+ * Needed to initialize IntegerOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class IntegerOptionStorage;
};
/*! \brief
*/
class Int64Option : public OptionTemplate<int64_t, Int64Option>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef Int64OptionInfo InfoType;
-
- //! Initializes an option with the given name.
- explicit Int64Option(const char *name) : MyBase(name) {}
-
- private:
- //! Creates an Int64OptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
-
- /*! \brief
- * Needed to initialize Int64OptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class Int64OptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef Int64OptionInfo InfoType;
+
+ //! Initializes an option with the given name.
+ explicit Int64Option(const char* name) : MyBase(name) {}
+
+private:
+ //! Creates an Int64OptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
+
+ /*! \brief
+ * Needed to initialize Int64OptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class Int64OptionStorage;
};
/*! \brief
*/
class DoubleOption : public OptionTemplate<double, DoubleOption>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef DoubleOptionInfo InfoType;
-
- //! Initializes an option with the given name.
- explicit DoubleOption(const char *name) : MyBase(name), bTime_(false)
- {
- }
-
- //! \copydoc IntegerOption::vector()
- MyClass &vector() { setVector(); return me(); }
- /*! \brief
- * 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 &timeValue() { bTime_ = true; return me(); }
-
- private:
- //! Creates a DoubleOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
-
- bool bTime_;
-
- /*! \brief
- * Needed to initialize DoubleOptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class DoubleOptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef DoubleOptionInfo InfoType;
+
+ //! Initializes an option with the given name.
+ explicit DoubleOption(const char* name) : MyBase(name), bTime_(false) {}
+
+ //! \copydoc IntegerOption::vector()
+ MyClass& vector()
+ {
+ setVector();
+ return me();
+ }
+ /*! \brief
+ * 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& timeValue()
+ {
+ bTime_ = true;
+ return me();
+ }
+
+private:
+ //! Creates a DoubleOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
+
+ bool bTime_;
+
+ /*! \brief
+ * Needed to initialize DoubleOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class DoubleOptionStorage;
};
/*! \brief
*/
class FloatOption : public OptionTemplate<float, FloatOption>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef FloatOptionInfo InfoType;
-
- //! Initializes an option with the given name.
- explicit FloatOption(const char *name) : MyBase(name), bTime_(false)
- {
- }
-
- //! \copydoc IntegerOption::vector()
- MyClass &vector() { setVector(); return me(); }
- //! \copydoc DoubleOption::timeValue()
- MyClass &timeValue() { bTime_ = true; return me(); }
-
- private:
- //! Creates a FloatOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
-
- bool bTime_;
-
- /*! \brief
- * Needed to initialize FloatOptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class FloatOptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef FloatOptionInfo InfoType;
+
+ //! Initializes an option with the given name.
+ explicit FloatOption(const char* name) : MyBase(name), bTime_(false) {}
+
+ //! \copydoc IntegerOption::vector()
+ MyClass& vector()
+ {
+ setVector();
+ return me();
+ }
+ //! \copydoc DoubleOption::timeValue()
+ MyClass& timeValue()
+ {
+ bTime_ = true;
+ return me();
+ }
+
+private:
+ //! Creates a FloatOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
+
+ bool bTime_;
+
+ /*! \brief
+ * Needed to initialize FloatOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class FloatOptionStorage;
};
/*! \brief
*/
class StringOption : public OptionTemplate<std::string, StringOption>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef StringOptionInfo InfoType;
-
- //! Initializes an option with the given name.
- explicit StringOption(const char *name)
- : MyBase(name), enumValues_(nullptr), enumValuesCount_(0),
- defaultEnumIndex_(-1)
- {
- }
-
- /*! \brief
- * Sets the option to only accept one of a fixed set of strings.
- *
- * \param[in] values Array of strings to accept.
- *
- * Also accepts prefixes of the strings; if a prefix matches more than
- * one of the possible strings, the shortest one is used (in a tie, the
- * first one is).
- *
- * The strings are copied once the option is created.
- */
- template <size_t count>
- MyClass &enumValue(const char *const (&values)[count])
- {
- GMX_ASSERT(enumValues_ == nullptr,
- "Multiple sets of enumerated values specified");
- enumValues_ = values;
- enumValuesCount_ = count;
- return me();
- }
- /*! \brief
- * Sets the option to only accept one of a fixed set of strings.
- *
- * \param[in] values Array of strings to accept, with a NULL pointer
- * following the last string.
- *
- * Works otherwise as the array version, but accepts a pointer to
- * an array of undetermined length. The end of the array is indicated
- * by a NULL pointer in the array.
- *
- * \see enumValue()
- */
- MyClass &enumValueFromNullTerminatedArray(const char *const *values)
- {
- GMX_ASSERT(enumValues_ == nullptr,
- "Multiple sets of enumerated values specified");
- enumValues_ = values;
- enumValuesCount_ = -1;
- return me();
- }
- /*! \brief
- * Sets the default value using an index into the enumeration table.
- *
- * Cannot be specified without enumValue().
- */
- MyClass &defaultEnumIndex(int index)
- {
- GMX_ASSERT(index >= 0, "Invalid enumeration index");
- defaultEnumIndex_ = index;
- return me();
- }
-
- private:
- //! Creates a StringOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer &managers) const override;
-
- const char *const *enumValues_;
- int enumValuesCount_;
- int defaultEnumIndex_;
-
- /*! \brief
- * Needed to initialize StringOptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class StringOptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef StringOptionInfo InfoType;
+
+ //! Initializes an option with the given name.
+ explicit StringOption(const char* name) :
+ MyBase(name),
+ enumValues_(nullptr),
+ enumValuesCount_(0),
+ defaultEnumIndex_(-1)
+ {
+ }
+
+ /*! \brief
+ * Sets the option to only accept one of a fixed set of strings.
+ *
+ * \param[in] values Array of strings to accept.
+ *
+ * Also accepts prefixes of the strings; if a prefix matches more than
+ * one of the possible strings, the shortest one is used (in a tie, the
+ * first one is).
+ *
+ * The strings are copied once the option is created.
+ */
+ template<size_t count>
+ MyClass& enumValue(const char* const (&values)[count])
+ {
+ GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified");
+ enumValues_ = values;
+ enumValuesCount_ = count;
+ return me();
+ }
+ /*! \brief
+ * Sets the option to only accept one of a fixed set of strings.
+ *
+ * \param[in] values Array of strings to accept, with a NULL pointer
+ * following the last string.
+ *
+ * Works otherwise as the array version, but accepts a pointer to
+ * an array of undetermined length. The end of the array is indicated
+ * by a NULL pointer in the array.
+ *
+ * \see enumValue()
+ */
+ MyClass& enumValueFromNullTerminatedArray(const char* const* values)
+ {
+ GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified");
+ enumValues_ = values;
+ enumValuesCount_ = -1;
+ return me();
+ }
+ /*! \brief
+ * Sets the default value using an index into the enumeration table.
+ *
+ * Cannot be specified without enumValue().
+ */
+ MyClass& defaultEnumIndex(int index)
+ {
+ GMX_ASSERT(index >= 0, "Invalid enumeration index");
+ defaultEnumIndex_ = index;
+ return me();
+ }
+
+private:
+ //! Creates a StringOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& managers) const override;
+
+ const char* const* enumValues_;
+ int enumValuesCount_;
+ int defaultEnumIndex_;
+
+ /*! \brief
+ * Needed to initialize StringOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class StringOptionStorage;
};
//! \}
*
* \ingroup module_options
*/
-template <typename EnumType>
+template<typename EnumType>
class EnumIndexStore : public IOptionValueStore<int>
{
- public:
- //! Initializes the storage for the given actual enum variables.
- EnumIndexStore(EnumType *store, std::vector<EnumType> *storeVector)
- : store_(store), storeVector_(storeVector)
+public:
+ //! Initializes the storage for the given actual enum variables.
+ EnumIndexStore(EnumType* store, std::vector<EnumType>* storeVector) :
+ store_(store),
+ storeVector_(storeVector)
+ {
+ if (storeVector_ != nullptr)
{
- if (storeVector_ != nullptr)
- {
- for (EnumType value : *storeVector_)
- {
- intStore_.push_back(static_cast<int>(value));
- }
- }
- else if (store_ != nullptr)
+ for (EnumType value : *storeVector_)
{
- // TODO: Copy more than one value if that would make sense.
- intStore_.push_back(static_cast<int>(store_[0]));
+ intStore_.push_back(static_cast<int>(value));
}
}
-
- int valueCount() override { return ssize(intStore_); }
- ArrayRef<int> values() override { return intStore_; }
- void clear() override
+ else if (store_ != nullptr)
{
- intStore_.clear();
- if (storeVector_ != nullptr)
- {
- storeVector_->clear();
- }
+ // TODO: Copy more than one value if that would make sense.
+ intStore_.push_back(static_cast<int>(store_[0]));
}
- void reserve(size_t count) override
+ }
+
+ int valueCount() override { return ssize(intStore_); }
+ ArrayRef<int> values() override { return intStore_; }
+ void clear() override
+ {
+ intStore_.clear();
+ if (storeVector_ != nullptr)
{
- intStore_.reserve(intStore_.size() + count);
- if (storeVector_ != nullptr)
- {
- storeVector_->reserve(storeVector_->size() + count);
- }
+ storeVector_->clear();
}
- void append(const int &value) override
+ }
+ void reserve(size_t count) override
+ {
+ intStore_.reserve(intStore_.size() + count);
+ if (storeVector_ != nullptr)
{
- const size_t count = intStore_.size();
- intStore_.push_back(value);
- if (store_ != nullptr)
- {
- store_[count] = static_cast<EnumType>(value);
- }
- if (storeVector_ != nullptr)
- {
- storeVector_->push_back(static_cast<EnumType>(value));
- }
+ storeVector_->reserve(storeVector_->size() + count);
}
+ }
+ void append(const int& value) override
+ {
+ const size_t count = intStore_.size();
+ intStore_.push_back(value);
+ if (store_ != nullptr)
+ {
+ store_[count] = static_cast<EnumType>(value);
+ }
+ if (storeVector_ != nullptr)
+ {
+ storeVector_->push_back(static_cast<EnumType>(value));
+ }
+ }
- private:
- //! Stores the integer values for values().
- std::vector<int> intStore_;
- EnumType *store_;
- std::vector<EnumType> *storeVector_;
+private:
+ //! Stores the integer values for values().
+ std::vector<int> intStore_;
+ EnumType* store_;
+ std::vector<EnumType>* storeVector_;
};
//! \cond internal
*
* \ingroup module_options
*/
-AbstractOptionStorage *
-createEnumOptionStorage(const AbstractOption &option,
- const char *const *enumValues, int count,
- int defaultValue, int defaultValueIfSet,
- std::unique_ptr<IOptionValueStore<int> > store);
+AbstractOptionStorage* createEnumOptionStorage(const AbstractOption& option,
+ const char* const* enumValues,
+ int count,
+ int defaultValue,
+ int defaultValueIfSet,
+ std::unique_ptr<IOptionValueStore<int>> store);
//! \endcond
-} // namespace internal
+} // namespace internal
//! \addtogroup module_options
//! \{
*
* \inpublicapi
*/
-template <typename EnumType>
-class EnumOption : public OptionTemplate<EnumType, EnumOption<EnumType> >
+template<typename EnumType>
+class EnumOption : public OptionTemplate<EnumType, EnumOption<EnumType>>
{
- public:
- //! OptionInfo subclass corresponding to this option type.
- typedef EnumOptionInfo InfoType;
-
- // This needs to be duplicated from OptionTemplate because this class
- // is a template.
- //! Short-hand for the base class.
- typedef OptionTemplate<EnumType, EnumOption<EnumType> > MyBase;
-
- //! Initializes an option with the given name.
- explicit EnumOption(const char *name)
- : MyBase(name), enumValues_(nullptr), enumValuesCount_(0)
- {
- }
-
- /*! \brief
- * Sets the option to only accept one of a fixed set of strings.
- *
- * \param[in] values Array of strings to accept.
- *
- * Also accepts prefixes of the strings; if a prefix matches more than
- * one of the possible strings, the shortest one is used (in a tie, the
- * first one is).
- *
- * The strings are copied once the option is created.
- */
- template <size_t count>
- EnumOption &enumValue(const char *const (&values)[count])
- {
- GMX_ASSERT(enumValues_ == nullptr,
- "Multiple sets of enumerated values specified");
- enumValues_ = values;
- enumValuesCount_ = count;
- return MyBase::me();
- }
- /*! \brief
- * Sets the option to only accept one of a fixed set of strings.
- *
- * \param[in] values Array of strings to accept, with a NULL pointer
- * following the last string.
- *
- * Works otherwise as the array version, but accepts a pointer to
- * an array of undetermined length. The end of the array is indicated
- * by a NULL pointer in the array.
- *
- * \see enumValue()
- */
- EnumOption &enumValueFromNullTerminatedArray(const char *const *values)
- {
- GMX_ASSERT(enumValues_ == nullptr,
- "Multiple sets of enumerated values specified");
- enumValues_ = values;
- enumValuesCount_ = -1;
- return MyBase::me();
- }
-
- private:
- //! Helper function to convert default values for storate initialization.
- static int convertToInt(const EnumType *defaultValue)
- {
- return defaultValue != nullptr ? static_cast<int>(*defaultValue) : -1;
- }
-
- //! Creates a EnumOptionStorage object.
- AbstractOptionStorage *createStorage(
- const OptionManagerContainer & /*managers*/) const override
- {
- // TODO: Implement storeCount() if necessary.
- return internal::createEnumOptionStorage(
- *this, enumValues_, enumValuesCount_,
- convertToInt(MyBase::defaultValue()),
- convertToInt(MyBase::defaultValueIfSet()),
- std::make_unique<internal::EnumIndexStore<EnumType> >(
- MyBase::store(), MyBase::storeVector()));
- }
-
- const char *const *enumValues_;
- int enumValuesCount_;
-
- /*! \brief
- * Needed to initialize EnumOptionStorage from this class without
- * otherwise unnecessary accessors.
- */
- friend class EnumOptionStorage;
+public:
+ //! OptionInfo subclass corresponding to this option type.
+ typedef EnumOptionInfo InfoType;
+
+ // This needs to be duplicated from OptionTemplate because this class
+ // is a template.
+ //! Short-hand for the base class.
+ typedef OptionTemplate<EnumType, EnumOption<EnumType>> MyBase;
+
+ //! Initializes an option with the given name.
+ explicit EnumOption(const char* name) : MyBase(name), enumValues_(nullptr), enumValuesCount_(0)
+ {
+ }
+
+ /*! \brief
+ * Sets the option to only accept one of a fixed set of strings.
+ *
+ * \param[in] values Array of strings to accept.
+ *
+ * Also accepts prefixes of the strings; if a prefix matches more than
+ * one of the possible strings, the shortest one is used (in a tie, the
+ * first one is).
+ *
+ * The strings are copied once the option is created.
+ */
+ template<size_t count>
+ EnumOption& enumValue(const char* const (&values)[count])
+ {
+ GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified");
+ enumValues_ = values;
+ enumValuesCount_ = count;
+ return MyBase::me();
+ }
+ /*! \brief
+ * Sets the option to only accept one of a fixed set of strings.
+ *
+ * \param[in] values Array of strings to accept, with a NULL pointer
+ * following the last string.
+ *
+ * Works otherwise as the array version, but accepts a pointer to
+ * an array of undetermined length. The end of the array is indicated
+ * by a NULL pointer in the array.
+ *
+ * \see enumValue()
+ */
+ EnumOption& enumValueFromNullTerminatedArray(const char* const* values)
+ {
+ GMX_ASSERT(enumValues_ == nullptr, "Multiple sets of enumerated values specified");
+ enumValues_ = values;
+ enumValuesCount_ = -1;
+ return MyBase::me();
+ }
+
+private:
+ //! Helper function to convert default values for storate initialization.
+ static int convertToInt(const EnumType* defaultValue)
+ {
+ return defaultValue != nullptr ? static_cast<int>(*defaultValue) : -1;
+ }
+
+ //! Creates a EnumOptionStorage object.
+ AbstractOptionStorage* createStorage(const OptionManagerContainer& /*managers*/) const override
+ {
+ // TODO: Implement storeCount() if necessary.
+ return internal::createEnumOptionStorage(*this, enumValues_, enumValuesCount_,
+ convertToInt(MyBase::defaultValue()),
+ convertToInt(MyBase::defaultValueIfSet()),
+ std::make_unique<internal::EnumIndexStore<EnumType>>(
+ MyBase::store(), MyBase::storeVector()));
+ }
+
+ const char* const* enumValues_;
+ int enumValuesCount_;
+
+ /*! \brief
+ * Needed to initialize EnumOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class EnumOptionStorage;
};
//! Shorthand for an enumerated option that stores into an `int` variable.
*/
class BooleanOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit BooleanOptionInfo(BooleanOptionStorage *option);
+public:
+ //! Creates an option info object for the given option.
+ explicit BooleanOptionInfo(BooleanOptionStorage* option);
- //! Returns the default value for this option.
- bool defaultValue() const;
+ //! Returns the default value for this option.
+ bool defaultValue() const;
- private:
- const BooleanOptionStorage &option() const;
+private:
+ const BooleanOptionStorage& option() const;
};
/*! \brief
*/
class IntegerOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit IntegerOptionInfo(IntegerOptionStorage *option);
+public:
+ //! Creates an option info object for the given option.
+ explicit IntegerOptionInfo(IntegerOptionStorage* option);
};
/*! \brief
*/
class Int64OptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit Int64OptionInfo(Int64OptionStorage *option);
+public:
+ //! Creates an option info object for the given option.
+ explicit Int64OptionInfo(Int64OptionStorage* option);
};
/*! \brief
*/
class DoubleOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit DoubleOptionInfo(DoubleOptionStorage *option);
-
- //! Whether the option specifies a time value.
- bool isTime() const;
-
- /*! \brief
- * Sets a scale factor for user-provided values.
- *
- * Any user-provided value is scaled by the provided factor.
- * Programmatically set default values are not scaled.
- * If called multiple times, later calls override the previously set
- * value. In other words, the scaling is not cumulative.
- */
- void setScaleFactor(double factor);
-
- private:
- DoubleOptionStorage &option();
- const DoubleOptionStorage &option() const;
+public:
+ //! Creates an option info object for the given option.
+ explicit DoubleOptionInfo(DoubleOptionStorage* option);
+
+ //! Whether the option specifies a time value.
+ bool isTime() const;
+
+ /*! \brief
+ * Sets a scale factor for user-provided values.
+ *
+ * Any user-provided value is scaled by the provided factor.
+ * Programmatically set default values are not scaled.
+ * If called multiple times, later calls override the previously set
+ * value. In other words, the scaling is not cumulative.
+ */
+ void setScaleFactor(double factor);
+
+private:
+ DoubleOptionStorage& option();
+ const DoubleOptionStorage& option() const;
};
/*! \brief
*/
class FloatOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit FloatOptionInfo(FloatOptionStorage *option);
+public:
+ //! Creates an option info object for the given option.
+ explicit FloatOptionInfo(FloatOptionStorage* option);
- //! Whether the option specifies a time value.
- bool isTime() const;
+ //! Whether the option specifies a time value.
+ bool isTime() const;
- //! \copydoc DoubleOptionInfo::setScaleFactor()
- void setScaleFactor(double factor);
+ //! \copydoc DoubleOptionInfo::setScaleFactor()
+ void setScaleFactor(double factor);
- private:
- FloatOptionStorage &option();
- const FloatOptionStorage &option() const;
+private:
+ FloatOptionStorage& option();
+ const FloatOptionStorage& option() const;
};
/*! \brief
*/
class StringOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit StringOptionInfo(StringOptionStorage *option);
-
- /*! \brief
- * Whether this option accepts an enumerated set of values.
- *
- * Returns true if StringOption::enumValues() was used when creating
- * this option.
- */
- bool isEnumerated() const;
- /*! \brief
- * Returns the set of allowed values for this option.
- *
- * Returns an empty vector if isEnumerated() returns false.
- */
- const std::vector<std::string> &allowedValues() const;
-
- private:
- const StringOptionStorage &option() const;
+public:
+ //! Creates an option info object for the given option.
+ explicit StringOptionInfo(StringOptionStorage* option);
+
+ /*! \brief
+ * Whether this option accepts an enumerated set of values.
+ *
+ * Returns true if StringOption::enumValues() was used when creating
+ * this option.
+ */
+ bool isEnumerated() const;
+ /*! \brief
+ * Returns the set of allowed values for this option.
+ *
+ * Returns an empty vector if isEnumerated() returns false.
+ */
+ const std::vector<std::string>& allowedValues() const;
+
+private:
+ const StringOptionStorage& option() const;
};
/*! \brief
*/
class EnumOptionInfo : public OptionInfo
{
- public:
- //! Creates an option info object for the given option.
- explicit EnumOptionInfo(EnumOptionStorage *option);
+public:
+ //! Creates an option info object for the given option.
+ explicit EnumOptionInfo(EnumOptionStorage* option);
- /*! \brief
- * Returns the set of allowed values for this option.
- */
- const std::vector<std::string> &allowedValues() const;
+ /*! \brief
+ * Returns the set of allowed values for this option.
+ */
+ const std::vector<std::string>& allowedValues() const;
- private:
- const EnumOptionStorage &option() const;
+private:
+ const EnumOptionStorage& option() const;
};
/*! \typedef RealOption
typedef DoubleOption RealOption;
typedef DoubleOptionInfo RealOptionInfo;
#else
-typedef FloatOption RealOption;
-typedef FloatOptionInfo RealOptionInfo;
+typedef FloatOption RealOption;
+typedef FloatOptionInfo RealOptionInfo;
#endif
//! \}