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@cbr.su.se>
36 * \ingroup module_options
38 #ifndef GMX_OPTIONS_BASICOPTIONSTORAGE_H
39 #define GMX_OPTIONS_BASICOPTIONSTORAGE_H
44 #include "basicoptions.h"
45 #include "basicoptioninfo.h"
46 #include "optionstoragetemplate.h"
56 /*! \addtogroup module_options
61 * Converts, validates, and stores boolean values.
63 class BooleanOptionStorage : public OptionStorageTemplate<bool>
67 * Initializes the storage from option settings.
69 * \param[in] settings Storage settings.
71 explicit BooleanOptionStorage(const BooleanOption &settings)
72 : MyBase(settings), info_(this)
76 virtual OptionInfo &optionInfo() { return info_; }
77 virtual const char *typeString() const { return "bool"; }
78 virtual std::string formatSingleValue(const bool &value) const;
81 virtual void convertValue(const std::string &value);
83 BooleanOptionInfo info_;
87 * Converts, validates, and stores integer values.
89 class IntegerOptionStorage : public OptionStorageTemplate<int>
92 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
93 explicit IntegerOptionStorage(const IntegerOption &settings)
94 : MyBase(settings), info_(this)
98 virtual OptionInfo &optionInfo() { return info_; }
99 virtual const char *typeString() const
100 { return hasFlag(efVector) ? "vector" : "int"; }
101 virtual std::string formatSingleValue(const int &value) const;
104 virtual void convertValue(const std::string &value);
105 virtual void processSetValues(ValueList *values);
107 IntegerOptionInfo info_;
111 * Converts, validates, and stores floating-point (double) values.
113 class DoubleOptionStorage : public OptionStorageTemplate<double>
116 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
117 explicit DoubleOptionStorage(const DoubleOption &settings);
119 virtual OptionInfo &optionInfo() { return info_; }
120 virtual const char *typeString() const;
121 virtual std::string formatSingleValue(const double &value) const;
123 //! \copydoc DoubleOptionInfo::isTime()
124 bool isTime() const { return bTime_; }
125 //! \copydoc DoubleOptionInfo::setScaleFactor()
126 void setScaleFactor(double factor);
129 virtual void convertValue(const std::string &value);
130 virtual void processSetValues(ValueList *values);
131 virtual void processAll();
133 DoubleOptionInfo info_;
139 * Converts, validates, and stores string values.
141 class StringOptionStorage : public OptionStorageTemplate<std::string>
144 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
145 explicit StringOptionStorage(const StringOption &settings);
147 virtual OptionInfo &optionInfo() { return _info; }
148 virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
149 virtual std::string formatSingleValue(const std::string &value) const;
152 virtual void convertValue(const std::string &value);
153 virtual void refreshValues();
155 StringOptionInfo _info;
157 int *_enumIndexStore;