2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * 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"
59 /*! \addtogroup module_options
64 * Converts, validates, and stores boolean values.
66 class BooleanOptionStorage : public OptionStorageTemplate<bool>
70 * Initializes the storage from option settings.
72 * \param[in] settings Storage settings.
74 explicit BooleanOptionStorage(const BooleanOption &settings)
75 : MyBase(settings), info_(this)
79 virtual OptionInfo &optionInfo() { return info_; }
80 virtual const char *typeString() const { return "bool"; }
81 virtual std::string formatSingleValue(const bool &value) const;
84 virtual void convertValue(const std::string &value);
86 BooleanOptionInfo info_;
90 * Converts, validates, and stores integer values.
92 class IntegerOptionStorage : public OptionStorageTemplate<int>
95 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
96 explicit IntegerOptionStorage(const IntegerOption &settings)
97 : MyBase(settings), info_(this)
101 virtual OptionInfo &optionInfo() { return info_; }
102 virtual const char *typeString() const
103 { return isVector() ? "vector" : "int"; }
104 virtual std::string formatSingleValue(const int &value) const;
107 virtual void convertValue(const std::string &value);
108 virtual void processSetValues(ValueList *values);
110 IntegerOptionInfo info_;
114 * Converts, validates, and stores floating-point (double) values.
116 class DoubleOptionStorage : public OptionStorageTemplate<double>
119 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
120 explicit DoubleOptionStorage(const DoubleOption &settings);
122 virtual OptionInfo &optionInfo() { return info_; }
123 virtual const char *typeString() const;
124 virtual std::string formatSingleValue(const double &value) const;
126 //! \copydoc DoubleOptionInfo::isTime()
127 bool isTime() const { return bTime_; }
128 //! \copydoc DoubleOptionInfo::setScaleFactor()
129 void setScaleFactor(double factor);
132 virtual void convertValue(const std::string &value);
133 virtual void processSetValues(ValueList *values);
134 virtual void processAll();
136 DoubleOptionInfo info_;
142 * Converts, validates, and stores string values.
144 class StringOptionStorage : public OptionStorageTemplate<std::string>
147 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
148 explicit StringOptionStorage(const StringOption &settings);
150 virtual OptionInfo &optionInfo() { return info_; }
151 virtual const char *typeString() const { return allowed_.empty() ? "string" : "enum"; }
152 virtual std::string formatSingleValue(const std::string &value) const;
154 //! \copydoc StringOptionInfo::allowedValues()
155 const ValueList &allowedValues() const { return allowed_; }
158 virtual void convertValue(const std::string &value);
159 virtual void refreshValues();
161 StringOptionInfo info_;
163 int *enumIndexStore_;