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 "optionfiletype.h"
45 #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.
70 * \param[in] options Options object.
72 BooleanOptionStorage(const BooleanOption &settings, Options *options)
73 : MyBase(settings, options)
77 virtual const char *typeString() const { return "bool"; }
78 virtual std::string formatValue(int i) const;
81 virtual void convertValue(const std::string &value);
85 * Converts, validates, and stores integer values.
87 class IntegerOptionStorage : public OptionStorageTemplate<int>
90 //! \copydoc BooleanOptionStorage::BooleanOptionStorage()
91 IntegerOptionStorage(const IntegerOption &settings, Options *options)
92 : MyBase(settings, options)
96 virtual const char *typeString() const
97 { return hasFlag(efVector) ? "vector" : "int"; }
98 virtual std::string formatValue(int i) const;
101 virtual void convertValue(const std::string &value);
102 virtual void processSetValues(ValueList *values);
106 * Converts, validates, and stores floating-point (double) values.
108 class DoubleOptionStorage : public OptionStorageTemplate<double>
111 //! \copydoc IntegerOptionStorage::IntegerOptionStorage()
112 DoubleOptionStorage(const DoubleOption &settings, Options *options);
114 virtual const char *typeString() const;
115 virtual std::string formatValue(int i) const;
118 virtual void convertValue(const std::string &value);
119 virtual void processSetValues(ValueList *values);
120 virtual void processAll();
126 * Converts, validates, and stores string values.
128 class StringOptionStorage : public OptionStorageTemplate<std::string>
131 //! \copydoc DoubleOptionStorage::DoubleOptionStorage()
132 StringOptionStorage(const StringOption &settings, Options *options);
134 virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
135 virtual std::string formatValue(int i) const;
138 virtual void convertValue(const std::string &value);
139 virtual void refreshValues();
142 int *_enumIndexStore;
146 * Converts, validates, and stores file names.
148 class FileNameOptionStorage : public OptionStorageTemplate<std::string>
151 //! \copydoc StringOptionStorage::StringOptionStorage()
152 FileNameOptionStorage(const FileNameOption &settings, Options *options);
154 virtual const char *typeString() const { return "file"; }
155 virtual std::string formatValue(int i) const;
158 virtual void convertValue(const std::string &value);
160 OptionFileType _filetype;