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 "optionfiletype.h"
47 #include "optionstoragetemplate.h"
58 /*! \addtogroup module_options
63 * Converts, validates, and stores boolean values.
65 class BooleanOptionStorage : public OptionStorageTemplate<bool>
69 * Initializes the storage from option settings.
71 * \param[in] settings Storage settings.
72 * \param[in] options Options object.
74 BooleanOptionStorage(const BooleanOption &settings, Options *options)
75 : MyBase(settings, options), info_(this)
79 virtual OptionInfo &optionInfo() { return info_; }
80 virtual const char *typeString() const { return "bool"; }
81 virtual std::string formatValue(int i) 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 IntegerOptionStorage(const IntegerOption &settings, Options *options)
97 : MyBase(settings, options), info_(this)
101 virtual OptionInfo &optionInfo() { return info_; }
102 virtual const char *typeString() const
103 { return hasFlag(efVector) ? "vector" : "int"; }
104 virtual std::string formatValue(int i) 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 DoubleOptionStorage(const DoubleOption &settings, Options *options);
122 virtual OptionInfo &optionInfo() { return info_; }
123 virtual const char *typeString() const;
124 virtual std::string formatValue(int i) const;
126 bool isTime() const { return bTime_; }
127 void setScaleFactor(double factor);
130 virtual void convertValue(const std::string &value);
131 virtual void processSetValues(ValueList *values);
132 virtual void processAll();
134 DoubleOptionInfo info_;
140 * Converts, validates, and stores string values.
142 class StringOptionStorage : public OptionStorageTemplate<std::string>
145 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
146 StringOptionStorage(const StringOption &settings, Options *options);
148 virtual OptionInfo &optionInfo() { return _info; }
149 virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
150 virtual std::string formatValue(int i) const;
153 virtual void convertValue(const std::string &value);
154 virtual void refreshValues();
156 StringOptionInfo _info;
158 int *_enumIndexStore;
162 * Converts, validates, and stores file names.
164 class FileNameOptionStorage : public OptionStorageTemplate<std::string>
167 //! \copydoc StringOptionStorage::StringOptionStorage()
168 FileNameOptionStorage(const FileNameOption &settings, Options *options);
170 virtual OptionInfo &optionInfo() { return info_; }
171 virtual const char *typeString() const { return "file"; }
172 virtual std::string formatValue(int i) const;
174 bool isInputFile() const { return bRead_ && !bWrite_; }
175 bool isOutputFile() const { return !bRead_ && bWrite_; }
176 bool isInputOutputFile() const { return bRead_ && bWrite_; }
177 bool isLibraryFile() const { return bLibrary_; }
180 virtual void convertValue(const std::string &value);
182 FileNameOptionInfo info_;
183 OptionFileType filetype_;