3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Declares storage classes for basic option types.
35 * \author Teemu Murtola <teemu.murtola@gmail.com>
36 * \ingroup module_options
38 #ifndef GMX_OPTIONS_BASICOPTIONSTORAGE_H
39 #define GMX_OPTIONS_BASICOPTIONSTORAGE_H
44 #include "basicoptions.h"
45 #include "optionstoragetemplate.h"
55 /*! \addtogroup module_options
60 * Converts, validates, and stores boolean values.
62 class BooleanOptionStorage : public OptionStorageTemplate<bool>
66 * Initializes the storage from option settings.
68 * \param[in] settings Storage settings.
70 explicit BooleanOptionStorage(const BooleanOption &settings)
71 : MyBase(settings), info_(this)
75 virtual OptionInfo &optionInfo() { return info_; }
76 virtual const char *typeString() const { return "bool"; }
77 virtual std::string formatSingleValue(const bool &value) const;
80 virtual void convertValue(const std::string &value);
82 BooleanOptionInfo info_;
86 * Converts, validates, and stores integer values.
88 class IntegerOptionStorage : public OptionStorageTemplate<int>
91 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
92 explicit IntegerOptionStorage(const IntegerOption &settings)
93 : MyBase(settings), info_(this)
97 virtual OptionInfo &optionInfo() { return info_; }
98 virtual const char *typeString() const
99 { return isVector() ? "vector" : "int"; }
100 virtual std::string formatSingleValue(const int &value) const;
103 virtual void convertValue(const std::string &value);
104 virtual void processSetValues(ValueList *values);
106 IntegerOptionInfo info_;
110 * Converts, validates, and stores floating-point (double) values.
112 class DoubleOptionStorage : public OptionStorageTemplate<double>
115 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
116 explicit DoubleOptionStorage(const DoubleOption &settings);
118 virtual OptionInfo &optionInfo() { return info_; }
119 virtual const char *typeString() const;
120 virtual std::string formatSingleValue(const double &value) const;
122 //! \copydoc DoubleOptionInfo::isTime()
123 bool isTime() const { return bTime_; }
124 //! \copydoc DoubleOptionInfo::setScaleFactor()
125 void setScaleFactor(double factor);
128 virtual void convertValue(const std::string &value);
129 virtual void processSetValues(ValueList *values);
130 virtual void processAll();
132 DoubleOptionInfo info_;
138 * Converts, validates, and stores string values.
140 class StringOptionStorage : public OptionStorageTemplate<std::string>
143 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
144 explicit StringOptionStorage(const StringOption &settings);
146 virtual OptionInfo &optionInfo() { return info_; }
147 virtual const char *typeString() const { return allowed_.empty() ? "string" : "enum"; }
148 virtual std::string formatSingleValue(const std::string &value) const;
151 virtual void convertValue(const std::string &value);
152 virtual void refreshValues();
154 StringOptionInfo info_;
156 int *enumIndexStore_;