2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 * Declares storage classes for basic option types.
39 * \author Teemu Murtola <teemu.murtola@gmail.com>
40 * \ingroup module_options
42 #ifndef GMX_OPTIONS_BASICOPTIONSTORAGE_H
43 #define GMX_OPTIONS_BASICOPTIONSTORAGE_H
48 #include "basicoptions.h"
49 #include "optionstoragetemplate.h"
54 /*! \addtogroup module_options
59 * Converts, validates, and stores boolean values.
61 class BooleanOptionStorage : public OptionStorageTemplate<bool>
65 * Initializes the storage from option settings.
67 * \param[in] settings Storage settings.
69 explicit BooleanOptionStorage(const BooleanOption &settings)
70 : MyBase(settings), info_(this)
74 virtual OptionInfo &optionInfo() { return info_; }
75 virtual std::string typeString() const { return "bool"; }
76 virtual std::string formatSingleValue(const bool &value) const;
79 virtual void convertValue(const std::string &value);
81 BooleanOptionInfo info_;
85 * Converts, validates, and stores integer values.
87 class IntegerOptionStorage : public OptionStorageTemplate<int>
90 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
91 explicit IntegerOptionStorage(const IntegerOption &settings)
92 : MyBase(settings), info_(this)
96 virtual OptionInfo &optionInfo() { return info_; }
97 virtual std::string typeString() const
98 { return isVector() ? "vector" : "int"; }
99 virtual std::string formatSingleValue(const int &value) const;
102 virtual void convertValue(const std::string &value);
103 virtual void processSetValues(ValueList *values);
105 IntegerOptionInfo info_;
109 * Converts, validates, and stores integer values.
111 class Int64OptionStorage : public OptionStorageTemplate<gmx_int64_t>
114 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
115 explicit Int64OptionStorage(const Int64Option &settings)
116 : MyBase(settings), info_(this)
120 virtual OptionInfo &optionInfo() { return info_; }
121 virtual std::string typeString() const { return "int"; }
122 virtual std::string formatSingleValue(const gmx_int64_t &value) const;
125 virtual void convertValue(const std::string &value);
127 Int64OptionInfo info_;
131 * Converts, validates, and stores floating-point (double) values.
133 class DoubleOptionStorage : public OptionStorageTemplate<double>
136 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
137 explicit DoubleOptionStorage(const DoubleOption &settings);
139 virtual OptionInfo &optionInfo() { return info_; }
140 virtual std::string typeString() const;
141 virtual std::string formatSingleValue(const double &value) const;
143 //! \copydoc DoubleOptionInfo::isTime()
144 bool isTime() const { return bTime_; }
145 //! \copydoc DoubleOptionInfo::setScaleFactor()
146 void setScaleFactor(double factor);
149 virtual void convertValue(const std::string &value);
150 virtual void processSetValues(ValueList *values);
152 DoubleOptionInfo info_;
158 * Converts, validates, and stores floating-point (float) values.
160 class FloatOptionStorage : public OptionStorageTemplate<float>
163 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
164 explicit FloatOptionStorage(const FloatOption &settings);
166 virtual OptionInfo &optionInfo() { return info_; }
167 virtual std::string typeString() const;
168 virtual std::string formatSingleValue(const float &value) const;
170 //! \copydoc DoubleOptionStorage::isTime()
171 bool isTime() const { return bTime_; }
172 //! \copydoc DoubleOptionStorage::setScaleFactor()
173 void setScaleFactor(double factor);
176 virtual void convertValue(const std::string &value);
177 virtual void processSetValues(ValueList *values);
179 FloatOptionInfo info_;
185 * Converts, validates, and stores string values.
187 class StringOptionStorage : public OptionStorageTemplate<std::string>
190 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
191 explicit StringOptionStorage(const StringOption &settings);
193 virtual OptionInfo &optionInfo() { return info_; }
194 virtual std::string typeString() const
195 { return allowed_.empty() ? "string" : "enum"; }
196 virtual std::string formatExtraDescription() const;
197 virtual std::string formatSingleValue(const std::string &value) const;
199 //! \copydoc StringOptionInfo::allowedValues()
200 const ValueList &allowedValues() const { return allowed_; }
203 virtual void convertValue(const std::string &value);
204 virtual void refreshValues();
206 StringOptionInfo info_;
208 int *enumIndexStore_;