/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, 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.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include <string>
+#include "../utility/basedefinitions.h"
#include "../utility/gmxassert.h"
#include "abstractoption.h"
class BooleanOptionStorage;
class IntegerOptionInfo;
class IntegerOptionStorage;
+class Int64OptionInfo;
+class Int64OptionStorage;
class DoubleOptionInfo;
class DoubleOptionStorage;
+class FloatOptionInfo;
+class FloatOptionStorage;
class StringOptionInfo;
class StringOptionStorage;
private:
//! Creates a BooleanOptionStorage object.
- virtual AbstractOptionStoragePointer createStorage() const;
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
};
/*! \brief
private:
//! Creates an IntegerOptionStorage object.
- virtual AbstractOptionStoragePointer createStorage() const;
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
/*! \brief
* Needed to initialize IntegerOptionStorage from this class without
friend class IntegerOptionStorage;
};
+/*! \brief
+ * Specifies an option that provides 64-bit integer values.
+ *
+ * Public methods in this class do not throw.
+ *
+ * \see IntegerOption
+ *
+ * \inpublicapi
+ */
+class Int64Option : public OptionTemplate<gmx_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.
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
+
+ /*! \brief
+ * Needed to initialize Int64OptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class Int64OptionStorage;
+};
+
/*! \brief
* Specifies an option that provides floating-point (double) values.
*
*
* 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
+ * 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);
private:
//! Creates a DoubleOptionStorage object.
- virtual AbstractOptionStoragePointer createStorage() const;
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
bool bTime_;
friend class DoubleOptionStorage;
};
+/*! \brief
+ * Specifies an option that provides floating-point (float) values.
+ *
+ * Public methods in this class do not throw.
+ *
+ * \see DoubleOption
+ *
+ * \inpublicapi
+ */
+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.
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
+
+ bool bTime_;
+
+ /*! \brief
+ * Needed to initialize FloatOptionStorage from this class without
+ * otherwise unnecessary accessors.
+ */
+ friend class FloatOptionStorage;
+};
+
/*! \brief
* Specifies an option that provides string values.
*
* The index (zero-based) of the selected value in the array \p values
* provided to enumValues() is written into \p *store after the
* option gets its value. If the option has not been provided,
- * and there is no default value, -1 is stored.
+ * and there is no default value, -1 is stored. If store(),
+ * storeVector() or defaultEnumIndex() is not present, the value in
+ * \p *store is kept as a default value, otherwise it is always
+ * overwritten.
*
* Cannot be specified without enumValue().
*
private:
//! Creates a StringOptionStorage object.
- virtual AbstractOptionStoragePointer createStorage() const;
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
const char *const *enumValues_;
int enumValuesCount_;
public:
//! Creates an option info object for the given option.
explicit BooleanOptionInfo(BooleanOptionStorage *option);
+
+ //! Returns the default value for this option.
+ bool defaultValue() const;
+
+ private:
+ const BooleanOptionStorage &option() const;
};
/*! \brief
explicit IntegerOptionInfo(IntegerOptionStorage *option);
};
+/*! \brief
+ * Wrapper class for accessing 64-bit integer option information.
+ *
+ * \inpublicapi
+ */
+class Int64OptionInfo : public OptionInfo
+{
+ public:
+ //! Creates an option info object for the given option.
+ explicit Int64OptionInfo(Int64OptionStorage *option);
+};
+
/*! \brief
* Wrapper class for accessing floating-point option information.
*
const DoubleOptionStorage &option() const;
};
+/*! \brief
+ * Wrapper class for accessing floating-point option information.
+ *
+ * \inpublicapi
+ */
+class FloatOptionInfo : public OptionInfo
+{
+ public:
+ //! Creates an option info object for the given option.
+ explicit FloatOptionInfo(FloatOptionStorage *option);
+
+ //! Whether the option specifies a time value.
+ bool isTime() const;
+
+ //! \copydoc DoubleOptionInfo::setScaleFactor()
+ void setScaleFactor(double factor);
+
+ private:
+ FloatOptionStorage &option();
+ const FloatOptionStorage &option() const;
+};
+
/*! \brief
* Wrapper class for accessing string option information.
*
const StringOptionStorage &option() const;
};
+/*! \typedef RealOption
+ * \brief
+ * Typedef for either DoubleOption or FloatOption, depending on precision.
+ *
+ * Generally, new would be better using DoubleOption, but this is provided for
+ * cases where the output value needs to be of type `real` for some reason.
+ */
+/*! \typedef RealOptionInfo
+ * \brief
+ * Typedef for either DoubleOptionInfo or FloatOptionInfo, depending on precision.
+ *
+ * Generally, new would be better using DoubleOption, but this is provided for
+ * cases where the output value needs to be of type `real` for some reason.
+ */
+#ifdef GMX_DOUBLE
+typedef DoubleOption RealOption;
+typedef DoubleOptionInfo RealOptionInfo;
+#else
+typedef FloatOption RealOption;
+typedef FloatOptionInfo RealOptionInfo;
+#endif
+
/*!\}*/
} // namespace gmx