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.
73 explicit BooleanOptionStorage(const BooleanOption &settings)
74 : MyBase(settings), info_(this)
78 virtual OptionInfo &optionInfo() { return info_; }
79 virtual const char *typeString() const { return "bool"; }
80 virtual std::string formatValue(int i) const;
83 virtual void convertValue(const std::string &value);
85 BooleanOptionInfo info_;
89 * Converts, validates, and stores integer values.
91 class IntegerOptionStorage : public OptionStorageTemplate<int>
94 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
95 explicit IntegerOptionStorage(const IntegerOption &settings)
96 : MyBase(settings), info_(this)
100 virtual OptionInfo &optionInfo() { return info_; }
101 virtual const char *typeString() const
102 { return hasFlag(efVector) ? "vector" : "int"; }
103 virtual std::string formatValue(int i) const;
106 virtual void convertValue(const std::string &value);
107 virtual void processSetValues(ValueList *values);
109 IntegerOptionInfo info_;
113 * Converts, validates, and stores floating-point (double) values.
115 class DoubleOptionStorage : public OptionStorageTemplate<double>
118 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
119 explicit DoubleOptionStorage(const DoubleOption &settings);
121 virtual OptionInfo &optionInfo() { return info_; }
122 virtual const char *typeString() const;
123 virtual std::string formatValue(int i) const;
125 //! \copydoc DoubleOptionInfo::isTime()
126 bool isTime() const { return bTime_; }
127 //! \copydoc DoubleOptionInfo::setScaleFactor()
128 void setScaleFactor(double factor);
131 virtual void convertValue(const std::string &value);
132 virtual void processSetValues(ValueList *values);
133 virtual void processAll();
135 DoubleOptionInfo info_;
141 * Converts, validates, and stores string values.
143 class StringOptionStorage : public OptionStorageTemplate<std::string>
146 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
147 explicit StringOptionStorage(const StringOption &settings);
149 virtual OptionInfo &optionInfo() { return _info; }
150 virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
151 virtual std::string formatValue(int i) const;
154 virtual void convertValue(const std::string &value);
155 virtual void refreshValues();
157 StringOptionInfo _info;
159 int *_enumIndexStore;
163 * Converts, validates, and stores file names.
165 class FileNameOptionStorage : public OptionStorageTemplate<std::string>
168 //! \copydoc StringOptionStorage::StringOptionStorage()
169 explicit FileNameOptionStorage(const FileNameOption &settings);
171 virtual OptionInfo &optionInfo() { return info_; }
172 virtual const char *typeString() const { return "file"; }
173 virtual std::string formatValue(int i) const;
175 //! \copydoc FileNameOptionInfo::isInputFile()
176 bool isInputFile() const { return bRead_ && !bWrite_; }
177 //! \copydoc FileNameOptionInfo::isOutputFile()
178 bool isOutputFile() const { return !bRead_ && bWrite_; }
179 //! \copydoc FileNameOptionInfo::isInputOutputFile()
180 bool isInputOutputFile() const { return bRead_ && bWrite_; }
181 //! \copydoc FileNameOptionInfo::isLibraryFile()
182 bool isLibraryFile() const { return bLibrary_; }
185 virtual void convertValue(const std::string &value);
187 FileNameOptionInfo info_;
188 OptionFileType filetype_;