Split g96 I/O routines from confio.cpp
[gromacs.git] / src / gromacs / options.h
bloba6bc7e8362f7b94f4c5fa3077638f096e2411317
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \defgroup module_options Extensible Handling of Options (options)
36 * \ingroup group_utilitymodules
37 * \brief
38 * Provides functionality for handling options.
40 * <H3>Basic Use</H3>
42 * Basic interface for providing options is implemented by the Options class
43 * and classes defined in basicoptions.h for specifying individual options.
44 * Only these are needed if a class wants to provide a set of standard options.
45 * When creating an Options object and adding options, it is possible to add
46 * descriptions for individual options as well as for the whole set of options.
47 * These can then be used to write out help text.
49 * The sequence charts below provides an overview of how the options work from
50 * usage perspective. They include two fictional modules, A and B, that provide
51 * options, and a main routine that manages these. The first chart shows a
52 * typical initialization sequence, where the main routine creates an options
53 * object, and calls an initOptions() method in each module that can provide
54 * options (the modules may also request their submodules to add their own
55 * options). Each module uses gmx::Options::addOption() to add the options
56 * they require, and specify output variables into which the options values are
57 * stored.
58 * \msc
59 * main,
60 * options [ label="Options", URL="\ref gmx::Options" ],
61 * A [ label="module A" ],
62 * B [ label="module B" ];
64 * main box B [ label="main owns all objects" ];
65 * main => options [ label="create", URL="\ref gmx::Options::Options()" ];
66 * main => A [ label="initOptions()" ];
67 * A => options [ label="addOption()", URL="\ref gmx::Options::addOption()" ];
68 * ...;
69 * main << A;
70 * main => B [ label="initOptions()" ];
71 * B => options [ label="addOption()", URL="\ref gmx::Options::addOption()" ];
72 * ...;
73 * main << B;
74 * \endmsc
76 * After all options have been specified, they can be parsed. A parser splits
77 * the input into option-value pairs (one option may have multiple values), and
78 * passes these into the gmx::Options object, which is responsible for
79 * converting them into the appropriate types and storing the values into the
80 * variables provided in the calls to gmx::Options::addOption().
81 * \msc
82 * main,
83 * parser [ label="parser" ],
84 * options [ label="Options", URL="\ref gmx::Options" ],
85 * A [ label="module A" ],
86 * B [ label="module B" ];
88 * main => parser [ label="parse()" ];
89 * parser => options [ label="assign(string)" ];
90 * options -> A [ label="set variable" ];
91 * parser => options [ label="assign(string)" ];
92 * options -> B [ label="set variable" ];
93 * ...;
94 * \endmsc
96 * After all options have been parsed (possibly using multiple different
97 * parsers), gmx::Options::finish() is called. This performs final
98 * validation of the options and may further adjust the values stored in the
99 * output variables (see documentation on individual option types on when this
100 * may happen).
101 * \msc
102 * main,
103 * options [ label="Options", URL="\ref gmx::Options" ],
104 * A [ label="module A" ],
105 * B [ label="module B" ];
107 * main => options [ label="finish()", URL="\ref gmx::Options::finish()" ];
108 * options -> A [ label="set variable" ];
109 * options -> B [ label="set variable" ];
110 * ...;
111 * \endmsc
113 * Module \ref module_commandline implements classes that assign option values
114 * from command line and produce help for programs that use the command line
115 * parser.
117 * \if libapi
118 * <H3>Advanced Use (in library API)</H3>
120 * It is possible to extend the module with new option types and/or parsers for
121 * option values.
123 * To implement new option types, it is necessary to subclass the templates
124 * OptionTemplate and OptionStorageTemplate with the type of the values that
125 * the option should provide as the template argument. After this is done, it
126 * is possible to add options of this new type using Options::addOption().
128 * To implement new parsers, one can use OptionsAssigner, which provides an
129 * interface to set values in an Options object.
131 * There is also an interface to iterate over all options in an Options object.
132 * One should implement the OptionsVisitor interface, and then use
133 * OptionsIterator to apply this visitor to the Options object.
134 * \endif
136 * \author Teemu Murtola <teemu.murtola@gmail.com>
138 /*! \file
139 * \brief
140 * Public API convenience header for handling of options.
142 * \author Teemu Murtola <teemu.murtola@gmail.com>
143 * \inpublicapi
144 * \ingroup module_options
146 #ifndef GMX_OPTIONS_H
147 #define GMX_OPTIONS_H
149 #include "gromacs/fileio/filenm.h"
150 #include "gromacs/options/basicoptions.h"
151 #include "gromacs/options/filenameoption.h"
152 #include "gromacs/options/filenameoptionmanager.h"
153 #include "gromacs/options/options.h"
155 #endif