Extract IOptionsContainer from Options
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 17 Jul 2015 10:29:06 +0000 (13:29 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sat, 25 Jul 2015 09:45:07 +0000 (11:45 +0200)
- Create a separate interface that declares addOption(), and make
  Options implement it.
- Change methods that took an Options just to call addOption() to take
  an instance of the new interface instead of a full Options object.
- Adjust documentation.

This isolates callers that only provide options from other details of
the options implementation, and allows further refactoring (that will
provide more implementations for this same interface).

Change-Id: I26d3f03602a8edd130d05231b3b0ee14b598ec8e

38 files changed:
docs/doxygen/user/analysisframework.md
share/template/template.cpp
src/gromacs/analysisdata/modules/plot.cpp
src/gromacs/analysisdata/modules/plot.h
src/gromacs/commandline/cmdlineoptionsmodule.h
src/gromacs/commandline/tests/cmdlinehelpmodule.cpp
src/gromacs/commandline/tests/cmdlinemodulemanagertest.h
src/gromacs/gmxpreprocess/insert-molecules.cpp
src/gromacs/options.h
src/gromacs/options/CMakeLists.txt
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/options/filenameoptionmanager.h
src/gromacs/options/ioptionscontainer.h [new file with mode: 0644]
src/gromacs/options/options.cpp
src/gromacs/options/options.h
src/gromacs/options/timeunitmanager.cpp
src/gromacs/options/timeunitmanager.h
src/gromacs/selection/selectioncollection.cpp
src/gromacs/selection/selectioncollection.h
src/gromacs/selection/selectionoption.h
src/gromacs/selection/tests/selectioncollection.cpp
src/gromacs/simd/tests/base.cpp
src/gromacs/trajectoryanalysis/analysismodule.h
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/modules/distance.cpp
src/gromacs/trajectoryanalysis/modules/freevolume.cpp
src/gromacs/trajectoryanalysis/modules/pairdist.cpp
src/gromacs/trajectoryanalysis/modules/rdf.cpp
src/gromacs/trajectoryanalysis/modules/sasa.cpp
src/gromacs/trajectoryanalysis/modules/select.cpp
src/gromacs/trajectoryanalysis/runnercommon.cpp
src/gromacs/trajectoryanalysis/runnercommon.h
src/gromacs/trajectoryanalysis/tests/test_selection.cpp
src/programs/mdrun/tests/moduletest.cpp
src/testutils/stringtest.cpp
src/testutils/testfilemanager.cpp
src/testutils/testoptions.cpp
src/testutils/testoptions.h

index 29358489b9fe24997f1ed49b595f3a7e1a689e22..46ce511fca362c23385e45f0cde1a1eae9552347 100644 (file)
@@ -114,14 +114,14 @@ Input options {#section_analysisframework_options}
 
 To declare input data for the tool (typically, command-line options, including
 input files and selections), \ref module_options module is used.
 
 To declare input data for the tool (typically, command-line options, including
 input files and selections), \ref module_options module is used.
-The analysis tool code receives a pre-initialized gmx::Options object in one of
-its initialization methods, and fills it with its input options.
+The analysis tool code receives an instance of gmx::IOptionsContainer for one of
+its initialization methods, and uses it to provide its input options.
 Basic options are declared in basicoptions.h, and also gmx::SelectionOption is
 used in the same manner.  For each option, the tool declares a local variable
 that will receive the value for that option.  After the options are parsed from
 the command line (by the framework), the tool code can read the values from
 Basic options are declared in basicoptions.h, and also gmx::SelectionOption is
 used in the same manner.  For each option, the tool declares a local variable
 that will receive the value for that option.  After the options are parsed from
 the command line (by the framework), the tool code can read the values from
-these variables.  The option declarations, and other information filled into
-the gmx::Options object, are also used to provide help to the user (also
+these variables.  The option declarations filled into the
+gmx::IOptionsContainer object are also used to provide help to the user (also
 handled by the framework).
 See the documentation for gmx::TrajectoryAnalysisModule and the
 [options module documentation](\ref module_options) for more details.
 handled by the framework).
 See the documentation for gmx::TrajectoryAnalysisModule and the
 [options module documentation](\ref module_options) for more details.
index 3cb55d5e89183b6b5586e9a522e12d6a02d8e7ae..3b9d3ddf47b9a5175eed41065daa3cb0fadf9ee3 100644 (file)
@@ -47,7 +47,7 @@ class AnalysisTemplate : public TrajectoryAnalysisModule
     public:
         AnalysisTemplate();
 
     public:
         AnalysisTemplate();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
@@ -82,7 +82,7 @@ AnalysisTemplate::AnalysisTemplate()
 
 
 void
 
 
 void
-AnalysisTemplate::initOptions(Options                    *options,
+AnalysisTemplate::initOptions(IOptionsContainer          *options,
                               TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
                               TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
index e60648e4fa333b6275fca1396b92755817598e3a..572c2d5a10ae43a33c4b7c0a097f050effde73c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -57,7 +57,7 @@
 #include "gromacs/legacyheaders/oenv.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/legacyheaders/oenv.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/timeunitmanager.h"
 #include "gromacs/selection/selectioncollection.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/options/timeunitmanager.h"
 #include "gromacs/selection/selectioncollection.h"
 #include "gromacs/utility/exceptions.h"
@@ -95,7 +95,7 @@ AnalysisDataPlotSettings::setSelectionCollection(const SelectionCollection *sele
 
 
 void
 
 
 void
-AnalysisDataPlotSettings::addOptions(Options *options)
+AnalysisDataPlotSettings::initOptions(IOptionsContainer *options)
 {
     options->addOption(StringOption("xvg").enumValue(g_plotFormats)
                            .defaultValue("xmgrace")
 {
     options->addOption(StringOption("xvg").enumValue(g_plotFormats)
                            .defaultValue("xmgrace")
index 78c48d5eecfe2957b58de860703487e8b7ff9e4f..2eb8b821591f5eb4cb6ea232b01b269395fce17c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -55,7 +55,7 @@ namespace gmx
 {
 
 class AnalysisDataValue;
 {
 
 class AnalysisDataValue;
-class Options;
+class IOptionsContainer;
 class SelectionCollection;
 
 /*! \brief
 class SelectionCollection;
 
 /*! \brief
@@ -109,7 +109,7 @@ class AnalysisDataPlotSettings
          *
          * \param[in,out] options Options object to which options are added.
          */
          *
          * \param[in,out] options Options object to which options are added.
          */
-        void addOptions(Options *options);
+        void initOptions(IOptionsContainer *options);
 
     private:
         const SelectionCollection *selections_;
 
     private:
         const SelectionCollection *selections_;
index ae7c004d013224c76fd80c6f2e724de2b46849cf..529bc55f98d6f3b60bfe06703c6fd705d38219f0 100644 (file)
@@ -52,6 +52,7 @@ template <typename T> class ConstArrayRef;
 
 class CommandLineModuleManager;
 class ICommandLineModule;
 
 class CommandLineModuleManager;
 class ICommandLineModule;
+class IOptionsContainer;
 class Options;
 
 /*! \brief
 class Options;
 
 /*! \brief
@@ -230,7 +231,7 @@ class ICommandLineOptionsModule
          * the module to \p options.  Output values from options should be
          * stored in member variables.
          */
          * the module to \p options.  Output values from options should be
          * stored in member variables.
          */
-        virtual void initOptions(Options                           *options,
+        virtual void initOptions(IOptionsContainer                 *options,
                                  ICommandLineOptionsModuleSettings *settings) = 0;
         /*! \brief
          * Called after all option values have been set.
                                  ICommandLineOptionsModuleSettings *settings) = 0;
         /*! \brief
          * Called after all option values have been set.
index ba62e55e0393cc399472320a3b5e68b214008497..871abe926f8059432cb242294c561cb2a38c728c 100644 (file)
@@ -107,7 +107,7 @@ TEST_F(CommandLineHelpModuleTest, PrintsHelpOnTopic)
  *
  * \ingroup module_commandline
  */
  *
  * \ingroup module_commandline
  */
-void initOptionsBasic(gmx::Options                           *options,
+void initOptionsBasic(gmx::IOptionsContainer                 *options,
                       gmx::ICommandLineOptionsModuleSettings *settings)
 {
     const char *const desc[] = {
                       gmx::ICommandLineOptionsModuleSettings *settings)
 {
     const char *const desc[] = {
index deb27ddb3a50325d1ec50b6e92aefc575c49f41d..9cb462f6b26c7de3638a4a2f032a767916aaf759 100644 (file)
@@ -108,7 +108,7 @@ class MockOptionsModule : public gmx::ICommandLineOptionsModule
         ~MockOptionsModule();
 
         MOCK_METHOD1(init, void(gmx::CommandLineModuleSettings *settings));
         ~MockOptionsModule();
 
         MOCK_METHOD1(init, void(gmx::CommandLineModuleSettings *settings));
-        MOCK_METHOD2(initOptions, void(gmx::Options *options, gmx::ICommandLineOptionsModuleSettings *settings));
+        MOCK_METHOD2(initOptions, void(gmx::IOptionsContainer *options, gmx::ICommandLineOptionsModuleSettings *settings));
         MOCK_METHOD1(optionsFinished, void(gmx::Options *options));
         MOCK_METHOD0(run, int());
 };
         MOCK_METHOD1(optionsFinished, void(gmx::Options *options));
         MOCK_METHOD0(run, int());
 };
index b4f77af2b32f1a6bee8332a1ab30182876ee1a6b..aefe09956344e63595e3900c225ba3ab379cda69 100644 (file)
@@ -51,6 +51,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
@@ -318,7 +319,7 @@ class InsertMolecules : public ICommandLineOptionsModule
         {
         }
 
         {
         }
 
-        virtual void initOptions(Options                           *options,
+        virtual void initOptions(IOptionsContainer                 *options,
                                  ICommandLineOptionsModuleSettings *settings);
         virtual void optionsFinished(Options *options);
 
                                  ICommandLineOptionsModuleSettings *settings);
         virtual void optionsFinished(Options *options);
 
@@ -340,7 +341,7 @@ class InsertMolecules : public ICommandLineOptionsModule
         int         enumRot_;
 };
 
         int         enumRot_;
 };
 
-void InsertMolecules::initOptions(Options                           *options,
+void InsertMolecules::initOptions(IOptionsContainer                 *options,
                                   ICommandLineOptionsModuleSettings *settings)
 {
     const char *const desc[] = {
                                   ICommandLineOptionsModuleSettings *settings)
 {
     const char *const desc[] = {
index a6bc7e8362f7b94f4c5fa3077638f096e2411317..01993c4d81082bb5a8cb5556d7dc6f5811326d60 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  *
  * <H3>Basic Use</H3>
  *
  *
  * <H3>Basic Use</H3>
  *
- * Basic interface for providing options is implemented by the Options class
- * and classes defined in basicoptions.h for specifying individual options.
- * Only these are needed if a class wants to provide a set of standard options.
- * When creating an Options object and adding options, it is possible to add
- * descriptions for individual options as well as for the whole set of options.
- * These can then be used to write out help text.
+ * Code that provides options does so using methods in gmx::IOptionsContainer
+ * and classes defined in basicoptions.h.
+ * Only these are needed if a class wants to provide a set of standard options
+ * (other modules can provide additional option types, such as
+ * gmx::SelectionOption).
+ * For each option, the caller provides an output variable that will receive
+ * the final value of the option once user input has been parsed.
+ * When adding options, it is possible to also provide descriptions for the
+ * options for use in generated help text.
+ *
+ * Generic code that handles the user input does so by creating a gmx::Options
+ * instance and passing it (as gmx::IOptionsContainer) to the classes that add
+ * the actual options.  It can then use a parser to set values to the options.
+ * Final values for the options can be inspected in the code that added the
+ * individual options, from the provided output variables.
  *
  * The sequence charts below provides an overview of how the options work from
  * usage perspective.  They include two fictional modules, A and B, that provide
  *
  * The sequence charts below provides an overview of how the options work from
  * usage perspective.  They include two fictional modules, A and B, that provide
@@ -52,9 +61,9 @@
  * typical initialization sequence, where the main routine creates an options
  * object, and calls an initOptions() method in each module that can provide
  * options (the modules may also request their submodules to add their own
  * typical initialization sequence, where the main routine creates an options
  * object, and calls an initOptions() method in each module that can provide
  * options (the modules may also request their submodules to add their own
- * options).  Each module uses gmx::Options::addOption() to add the options
- * they require, and specify output variables into which the options values are
- * stored.
+ * options).  Each module uses gmx::IOptionsContainer::addOption() to add the
+ * options they require, and specify output variables into which the options
+ * values are stored.
  * \msc
  *     main,
  *     options [ label="Options", URL="\ref gmx::Options" ],
  * \msc
  *     main,
  *     options [ label="Options", URL="\ref gmx::Options" ],
  *     main box B [ label="main owns all objects" ];
  *     main => options [ label="create", URL="\ref gmx::Options::Options()" ];
  *     main => A [ label="initOptions()" ];
  *     main box B [ label="main owns all objects" ];
  *     main => options [ label="create", URL="\ref gmx::Options::Options()" ];
  *     main => A [ label="initOptions()" ];
- *     A => options [ label="addOption()", URL="\ref gmx::Options::addOption()" ];
+ *     A => options [ label="addOption()", URL="\ref gmx::IOptionsContainer::addOption()" ];
  *     ...;
  *     main << A;
  *     main => B [ label="initOptions()" ];
  *     ...;
  *     main << A;
  *     main => B [ label="initOptions()" ];
- *     B => options [ label="addOption()", URL="\ref gmx::Options::addOption()" ];
+ *     B => options [ label="addOption()", URL="\ref gmx::IOptionsContainer::addOption()" ];
  *     ...;
  *     main << B;
  * \endmsc
  *     ...;
  *     main << B;
  * \endmsc
@@ -77,7 +86,7 @@
  * the input into option-value pairs (one option may have multiple values), and
  * passes these into the gmx::Options object, which is responsible for
  * converting them into the appropriate types and storing the values into the
  * the input into option-value pairs (one option may have multiple values), and
  * passes these into the gmx::Options object, which is responsible for
  * converting them into the appropriate types and storing the values into the
- * variables provided in the calls to gmx::Options::addOption().
+ * variables provided in the calls to gmx::IOptionsContainer::addOption().
  * \msc
  *     main,
  *     parser [ label="parser" ],
  * \msc
  *     main,
  *     parser [ label="parser" ],
  * To implement new option types, it is necessary to subclass the templates
  * OptionTemplate and OptionStorageTemplate with the type of the values that
  * the option should provide as the template argument.  After this is done, it
  * To implement new option types, it is necessary to subclass the templates
  * OptionTemplate and OptionStorageTemplate with the type of the values that
  * the option should provide as the template argument.  After this is done, it
- * is possible to add options of this new type using Options::addOption().
+ * is possible to add options of this new type using IOptionsContainer::addOption().
  *
  * To implement new parsers, one can use OptionsAssigner, which provides an
  * interface to set values in an Options object.
  *
  * To implement new parsers, one can use OptionsAssigner, which provides an
  * interface to set values in an Options object.
index a04d94e1a184ab50c61fe45137f0f43c1ec62f4c..d565ace7791733135358f41b21819bf4880dca27 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2010,2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2010,2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -40,6 +40,7 @@ gmx_install_headers(
     basicoptions.h
     filenameoption.h
     filenameoptionmanager.h
     basicoptions.h
     filenameoption.h
     filenameoptionmanager.h
+    ioptionscontainer.h
     optionfiletype.h
     optionflags.h
     options.h
     optionfiletype.h
     optionflags.h
     options.h
index 1a627cd85c6d7f550f915cd71458928357855854..f83c63a1ecd45eea028b4d69eb1e6d6e344c203a 100644 (file)
@@ -50,7 +50,7 @@
 #include "gromacs/fileio/filenm.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/fileio/filenm.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/fileredirector.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/fileredirector.h"
@@ -149,7 +149,7 @@ void FileNameOptionManager::disableInputOptionChecking(bool bDisable)
 }
 
 void FileNameOptionManager::addDefaultFileNameOption(
 }
 
 void FileNameOptionManager::addDefaultFileNameOption(
-        Options *options, const char *name)
+        IOptionsContainer *options, const char *name)
 {
     options->addOption(
             StringOption(name).store(&impl_->defaultFileName_)
 {
     options->addOption(
             StringOption(name).store(&impl_->defaultFileName_)
index fd2099a40b4b22e03e3c2e436102b0e292ed49d5..a8182162b2f2817a2d0f5acbd47cf42f5b6af318 100644 (file)
@@ -53,7 +53,7 @@ namespace gmx
 
 class FileNameOptionInfo;
 class IFileInputRedirector;
 
 class FileNameOptionInfo;
 class IFileInputRedirector;
-class Options;
+class IOptionsContainer;
 
 /*! \brief
  * Handles interaction of file name options with global options.
 
 /*! \brief
  * Handles interaction of file name options with global options.
@@ -132,7 +132,7 @@ class FileNameOptionManager : public IOptionManager
          * instead from an option-specific default
          * (FileNameOption::defaultBaseName()).
          */
          * instead from an option-specific default
          * (FileNameOption::defaultBaseName()).
          */
-        void addDefaultFileNameOption(Options *options, const char *name);
+        void addDefaultFileNameOption(IOptionsContainer *options, const char *name);
 
         /*! \brief
          * Completes file name option values.
 
         /*! \brief
          * Completes file name option values.
diff --git a/src/gromacs/options/ioptionscontainer.h b/src/gromacs/options/ioptionscontainer.h
new file mode 100644 (file)
index 0000000..1e8eddb
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \file
+ * \brief
+ * Declares gmx::IOptionsContainer.
+ *
+ * \author Teemu Murtola <teemu.murtola@gmail.com>
+ * \inpublicapi
+ * \ingroup module_options
+ */
+#ifndef GMX_OPTIONS_IOPTIONSCONTAINER_H
+#define GMX_OPTIONS_IOPTIONSCONTAINER_H
+
+#include "gromacs/options/abstractoption.h"
+#include "gromacs/utility/gmxassert.h"
+
+namespace gmx
+{
+
+/*! \brief
+ * Interface for adding input options.
+ *
+ * This interface provides methods to add new options.
+ * Standard usage is for code to receive this interface and populate it with
+ * supported options:
+ * \code
+   // <as class attributes>
+   std::string  arg1;
+   int          arg2;
+
+   void MyClass::initOptions(gmx::IOptionsContainer *options)
+   {
+       options->addOption(gmx::StringOption("arg1").store(&arg1));
+       options->addOption(gmx::IntegerOption("arg2").store(&arg2));
+   }
+   \endcode
+ * The caller can collect options from multiple sources into a single container
+ * (a gmx::Options), and use a parser implementation such as CommandLineParser
+ * to provide values for the options.
+ *
+ * Header basicoptions.h provides declarations of several standard
+ * option types for use with addOption().  Documentation of those classes
+ * also give more examples of how to define options.
+ *
+ * \inpublicapi
+ * \ingroup module_options
+ */
+class IOptionsContainer
+{
+    public:
+        /*! \brief
+         * Adds a recognized option.
+         *
+         * \param[in] settings Option description.
+         * \returns   OptionInfo object for the created option (never NULL).
+         * \throws    APIError if invalid option settings are provided.
+         *
+         * This method provides the internal implementation, but in most cases
+         * the templated method is called from user code.
+         * See the templated method for more details.
+         */
+        virtual OptionInfo *addOption(const AbstractOption &settings) = 0;
+        /*! \brief
+         * Adds a recognized option.
+         *
+         * \tparam    OptionType Type of the options description object.
+         * \param[in] settings   Option description.
+         * \returns   OptionInfo object for the created option (never NULL).
+         * \throws    APIError if invalid option settings are provided.
+         *
+         * The return value is a pointer for more convenient use in callers:
+         * often callers need to declare the variable that will hold the return
+         * value in wider scope than would be achieved by declaring it at the
+         * site where addOption() is called.
+         * The returned pointer must not be freed.
+         *
+         * See \link Options class documentation \endlink for example usage.
+         *
+         * \libinternal
+         * \p OptionType::InfoType must specify a type that derives from
+         * OptionInfo and matches the type that is returned by
+         * AbstractOptionStorage::optionInfo() for the storage object that
+         * corresponds to \p OptionType.
+         */
+        template <class OptionType>
+        typename OptionType::InfoType *addOption(const OptionType &settings)
+        {
+            OptionInfo *info
+                = addOption(static_cast<const AbstractOption &>(settings));
+            GMX_ASSERT(info->isType<typename OptionType::InfoType>(),
+                       "Mismatching option info type declaration and implementation");
+            return info->toType<typename OptionType::InfoType>();
+        }
+
+    protected:
+        // Disallow deletion through the interface.
+        // (no need for the virtual, but some compilers warn otherwise)
+        virtual ~IOptionsContainer();
+
+};
+
+} // namespace
+
+#endif
index c0cff702033c691e79be4913cb2c05356117446b..9b422c96404ec531809c7310f6873fedcf735f3c 100644 (file)
@@ -63,6 +63,14 @@ IOptionManager::~IOptionManager()
 {
 }
 
 {
 }
 
+/********************************************************************
+ * IOptionsContainer
+ */
+
+IOptionsContainer::~IOptionsContainer()
+{
+}
+
 /********************************************************************
  * Options::Impl
  */
 /********************************************************************
  * Options::Impl
  */
index d62319b0a0626bea7b7c814dec5892f4bacab023..b312218a56bbb12a611cf03a8e6e7adc9676a737 100644 (file)
@@ -48,9 +48,8 @@
 
 #include <string>
 
 
 #include <string>
 
-#include "gromacs/options/abstractoption.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/classhelpers.h"
 #include "gromacs/utility/classhelpers.h"
-#include "gromacs/utility/gmxassert.h"
 
 namespace gmx
 {
 
 namespace gmx
 {
@@ -83,32 +82,10 @@ class IOptionManager
 /*! \brief
  * Collection of options.
  *
 /*! \brief
  * Collection of options.
  *
- * This class provides a standard interface for implementing input options.
- * Standard usage is to write a method that creates an Options that is owned by
- * the object, populates it with supported options, and then returns it:
- * \code
-   // <as class attributes>
-   using gmx::Options;
-   Options      options("common", "Common Options");
-   std::string  arg1;
-   int          arg2;
-
-   // <populating>
-   using gmx::StringOption;
-   using gmx::IntegerOption;
-   options.addOption(StringOption("arg1").store(&arg1));
-   options.addOption(IntegerOption("arg2").store(&arg2));
-   return &options;
-   \endcode
- * The caller of that method can then use a parser implementation such as
- * CommandLineParser to provide values for the options.
+ * See \ref module_options for an overview of how the options work.
+ * The IOptionsContainer interface documents how to add options.
  *
  *
- * Header basicoptions.h provides declarations of several standard
- * option types for use with addOption().  Documentation of those classes
- * also give more examples of how to define options.
- *
- * In order to keep the public interface of this class simple and to reduce
- * build dependencies on objects that simply provide options, functionality
+ * In order to keep the public interface of this class simple, functionality
  * to assign values to options is provided by a separate OptionsAssigner class.
  * Similarly, functionality for looping over all options (e.g., for writing out
  * help) is provided by OptionsIterator.
  * to assign values to options is provided by a separate OptionsAssigner class.
  * Similarly, functionality for looping over all options (e.g., for writing out
  * help) is provided by OptionsIterator.
@@ -116,7 +93,7 @@ class IOptionManager
  * \inpublicapi
  * \ingroup module_options
  */
  * \inpublicapi
  * \ingroup module_options
  */
-class Options
+class Options : public IOptionsContainer
 {
     public:
         /*! \brief
 {
     public:
         /*! \brief
@@ -175,49 +152,10 @@ class Options
          * If an attempt is made, the function asserts.
          */
         void addSubSection(Options *section);
          * If an attempt is made, the function asserts.
          */
         void addSubSection(Options *section);
-        /*! \brief
-         * Adds a recognized option to the collection.
-         *
-         * \param[in] settings Option description.
-         * \returns   OptionInfo object for the created option (never NULL).
-         * \throws    APIError if invalid option settings are provided.
-         *
-         * This method provides the internal implementation, but in most cases
-         * the templated method is called from user code.
-         * See the templated method for more details.
-         */
-        OptionInfo *addOption(const AbstractOption &settings);
-        /*! \brief
-         * Adds a recognized option to the collection.
-         *
-         * \tparam    OptionType Type of the options description object.
-         * \param[in] settings   Option description.
-         * \returns   OptionInfo object for the created option (never NULL).
-         * \throws    APIError if invalid option settings are provided.
-         *
-         * The return value is a pointer for more convenient use in callers:
-         * often callers need to declare the variable that will hold the return
-         * value in wider scope than would be achieved by declaring it at the
-         * site where addOption() is called.
-         * The returned pointer must not be freed.
-         *
-         * See \link Options class documentation \endlink for example usage.
-         *
-         * \libinternal
-         * \p OptionType::InfoType must specify a type that derives from
-         * OptionInfo and matches the type that is returned by
-         * AbstractOptionStorage::optionInfo() for the storage object that
-         * corresponds to \p OptionType.
-         */
-        template <class OptionType>
-        typename OptionType::InfoType *addOption(const OptionType &settings)
-        {
-            OptionInfo *info
-                = addOption(static_cast<const AbstractOption &>(settings));
-            GMX_ASSERT(info->isType<typename OptionType::InfoType>(),
-                       "Mismatching option info type declaration and implementation");
-            return info->toType<typename OptionType::InfoType>();
-        }
+
+        // From IOptionsContainer
+        virtual OptionInfo *addOption(const AbstractOption &settings);
+        using IOptionsContainer::addOption;
 
         //! Returns true if option \p name is set.
         bool isSet(const char *name) const;
 
         //! Returns true if option \p name is set.
         bool isSet(const char *name) const;
index b687c31bb7518ac606a33b23edfd94edd296683a..87b5e477b7f5629e9e8bc568bfb03983da6f4b82 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -48,6 +48,7 @@
 #include <algorithm>
 
 #include "gromacs/options/basicoptions.h"
 #include <algorithm>
 
 #include "gromacs/options/basicoptions.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsvisitor.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsvisitor.h"
 #include "gromacs/utility/arrayref.h"
@@ -138,7 +139,7 @@ void TimeUnitManager::setTimeUnitFromEnvironment()
     }
 }
 
     }
 }
 
-void TimeUnitManager::addTimeUnitOption(Options *options, const char *name)
+void TimeUnitManager::addTimeUnitOption(IOptionsContainer *options, const char *name)
 {
     options->addOption(StringOption(name).enumValue(g_timeUnits)
                            .defaultValue(g_timeUnits[timeUnit()])
 {
     options->addOption(StringOption(name).enumValue(g_timeUnits)
                            .defaultValue(g_timeUnits[timeUnit()])
index 76e08312bebfe16603db5e5e015ba24f21d29c6f..d35f6e5ae996e40ae3621c8ebfdaf68fdde12f9f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -48,6 +48,7 @@
 namespace gmx
 {
 
 namespace gmx
 {
 
+class IOptionsContainer;
 class Options;
 
 /*! \brief
 class Options;
 
 /*! \brief
@@ -130,7 +131,7 @@ class TimeUnitManager
          * Adds an enum option to \p options to select the time unit for this
          * manager.
          */
          * Adds an enum option to \p options to select the time unit for this
          * manager.
          */
-        void addTimeUnitOption(Options *options, const char *name);
+        void addTimeUnitOption(IOptionsContainer *options, const char *name);
         /*! \brief
          * Scales user input values given to time options.
          *
         /*! \brief
          * Scales user input values given to time options.
          *
index b7ee4d0b2d67b75835196179a9a6a4878c6f5727..2c07363e20fae379978efe256fa611e676053d32 100644 (file)
@@ -57,7 +57,7 @@
 #include "gromacs/onlinehelp/helpmanager.h"
 #include "gromacs/onlinehelp/helpwritercontext.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/onlinehelp/helpmanager.h"
 #include "gromacs/onlinehelp/helpwritercontext.h"
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selhelp.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selhelp.h"
 #include "gromacs/topology/topology.h"
@@ -496,7 +496,7 @@ SelectionCollection::~SelectionCollection()
 
 
 void
 
 
 void
-SelectionCollection::initOptions(Options *options)
+SelectionCollection::initOptions(IOptionsContainer *options)
 {
     const char * const debug_levels[]
         = { "no", "basic", "compile", "eval", "full" };
 {
     const char * const debug_levels[]
         = { "no", "basic", "compile", "eval", "full" };
index 826f20a04d1a85c3a8ddd23f6e2afda3995d8ec4..663667abc7696d573459a2368ffc87da0e234937 100644 (file)
@@ -60,7 +60,7 @@ struct t_trxframe;
 namespace gmx
 {
 
 namespace gmx
 {
 
-class Options;
+class IOptionsContainer;
 class SelectionCompiler;
 class SelectionEvaluator;
 class TextInputStream;
 class SelectionCompiler;
 class SelectionEvaluator;
 class TextInputStream;
@@ -130,7 +130,7 @@ class SelectionCollection
          * position types (see setReferencePosType() and setOutputPosType())
          * and debugging flags.
          */
          * position types (see setReferencePosType() and setOutputPosType())
          * and debugging flags.
          */
-        void initOptions(Options *options);
+        void initOptions(IOptionsContainer *options);
 
         /*! \brief
          * Sets the default reference position handling for a selection
 
         /*! \brief
          * Sets the default reference position handling for a selection
index 0af37dddc73c36cb077d3446a9cbdc692321170a..199b19128fc6dbae4f0e4149f7876cd14bff8da1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -178,7 +178,7 @@ class SelectionOption : public OptionTemplate<Selection, SelectionOption>
  * appropriate.  Otherwise, values that are provided before adjustments will
  * need to follow the more strict checks.  In most cases in trajectory analysis
  * (which is the main use case for selection options), the adjustments should
  * appropriate.  Otherwise, values that are provided before adjustments will
  * need to follow the more strict checks.  In most cases in trajectory analysis
  * (which is the main use case for selection options), the adjustments should
- * be done in TrajectoryAnalysisModule::initOptionsDone() for them to take
+ * be done in TrajectoryAnalysisModule::optionsFinished() for them to take
  * place before interactive selection prompts.
  *
  * An instance of this class for a selection option can be obtained with
  * place before interactive selection prompts.
  *
  * An instance of this class for a selection option can be obtained with
index 436abee87dafae069916d136e170ff7adefb6a08..095a203953a0dbdbe3ff60e6b673f8eb211878c4 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "gromacs/fileio/trx.h"
 #include "gromacs/options/basicoptions.h"
 
 #include "gromacs/fileio/trx.h"
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/selection/indexutil.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/selection/indexutil.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/topology/topology.h"
index c13862a222bce444f0c395fc67ab92a06f297f2e..34438ac2769097412ebc46623c3170a62cf18275 100644 (file)
@@ -39,7 +39,7 @@
 #include <math.h>
 
 #include "gromacs/options/basicoptions.h"
 #include <math.h>
 
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/basedefinitions.h"
 
 #include "testutils/testoptions.h"
 #include "gromacs/utility/basedefinitions.h"
 
 #include "testutils/testoptions.h"
index f2756b88f0af1e1b963cec75c0e75bf232e442b5..6735b21c4caf79b4b0a0c22ab3ed47bbc49cff94 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -62,6 +62,7 @@ class AbstractAnalysisData;
 class AnalysisData;
 class AnalysisDataHandle;
 class AnalysisDataParallelOptions;
 class AnalysisData;
 class AnalysisDataHandle;
 class AnalysisDataParallelOptions;
+class IOptionsContainer;
 class Options;
 class SelectionCollection;
 class TopologyInformation;
 class Options;
 class SelectionCollection;
 class TopologyInformation;
@@ -249,7 +250,7 @@ class TrajectoryAnalysisModule
          * If settings depend on the option values provided by the user, see
          * optionsFinished().
          */
          * If settings depend on the option values provided by the user, see
          * optionsFinished().
          */
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings) = 0;
         /*! \brief
          * Called after all option values have been set.
                                  TrajectoryAnalysisSettings *settings) = 0;
         /*! \brief
          * Called after all option values have been set.
index 8968c49690135fc1bb83325e75cab9b21639c1e3..c9826aed25a157337da46610b4132cdc1c67c75b 100644 (file)
@@ -55,6 +55,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
@@ -245,7 +246,7 @@ class Angle : public TrajectoryAnalysisModule
     public:
         Angle();
 
     public:
         Angle();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
@@ -304,7 +305,7 @@ Angle::Angle()
 
 
 void
 
 
 void
-Angle::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+Angle::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] computes different types of angles between vectors.",
 {
     static const char *const desc[] = {
         "[THISMODULE] computes different types of angles between vectors.",
index bc9fb9687eed8c046772211c9a262a5e7a72d8d4..32f9faf3a730ee44a8ce642a8a08677b1eeaa2d0 100644 (file)
@@ -53,7 +53,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
@@ -76,7 +76,7 @@ class Distance : public TrajectoryAnalysisModule
     public:
         Distance();
 
     public:
         Distance();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
@@ -132,7 +132,7 @@ Distance::Distance()
 
 
 void
 
 
 void
-Distance::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+Distance::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates distances between pairs of positions",
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates distances between pairs of positions",
index a99215cffd6df62af3073d3fb686859f2b33f76f..a07cebffd9e240d5576aac74083d9ca046f37d62 100644 (file)
@@ -53,7 +53,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
 #include "gromacs/selection/nbsearch.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
 #include "gromacs/selection/nbsearch.h"
@@ -85,28 +85,16 @@ namespace
 class FreeVolume : public TrajectoryAnalysisModule
 {
     public:
 class FreeVolume : public TrajectoryAnalysisModule
 {
     public:
-        //! Constructor
         FreeVolume();
         FreeVolume();
-
-        //! Destructor
         virtual ~FreeVolume();
 
         virtual ~FreeVolume();
 
-        //! Set the options and setting
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
                                  TrajectoryAnalysisSettings *settings);
-
-        //! First routine called by the analysis framework
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
-
-        //! Call for each frame of the trajectory
         virtual void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                                   TrajectoryAnalysisModuleData *pdata);
         virtual void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                                   TrajectoryAnalysisModuleData *pdata);
-
-        //! Last routine called by the analysis framework
         virtual void finishAnalysis(int nframes);
         virtual void finishAnalysis(int nframes);
-
-        //! Routine to write output, that is additional over the built-in
         virtual void writeOutput();
 
     private:
         virtual void writeOutput();
 
     private:
@@ -162,7 +150,7 @@ FreeVolume::~FreeVolume()
 
 
 void
 
 
 void
-FreeVolume::initOptions(Options                    *options,
+FreeVolume::initOptions(IOptionsContainer          *options,
                         TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
                         TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
index 0d365ffa34be4257c474666b1cc80638c842f20e..43b47b6c33661e5c7f82762391f158c6deaeb4b9 100644 (file)
@@ -55,7 +55,7 @@
 #include "gromacs/fileio/trx.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/fileio/trx.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/selection/nbsearch.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/selection/nbsearch.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
@@ -105,7 +105,7 @@ class PairDistance : public TrajectoryAnalysisModule
     public:
         PairDistance();
 
     public:
         PairDistance();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
@@ -177,7 +177,7 @@ PairDistance::PairDistance()
 
 
 void
 
 
 void
-PairDistance::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+PairDistance::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates pairwise distances between one reference",
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates pairwise distances between one reference",
index 448095bdf3f328534b285fab0212465ce88459b7..5a11f9f369cac49adf60ad2270f1135ac5803eee 100644 (file)
@@ -61,6 +61,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/nbsearch.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/nbsearch.h"
@@ -96,7 +97,7 @@ class Rdf : public TrajectoryAnalysisModule
     public:
         Rdf();
 
     public:
         Rdf();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
@@ -200,7 +201,7 @@ Rdf::Rdf()
 }
 
 void
 }
 
 void
-Rdf::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+Rdf::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates radial distribution functions from one",
 {
     static const char *const desc[] = {
         "[THISMODULE] calculates radial distribution functions from one",
index edff30830f3311f17a373206b4b51f39ceddcca0..2d14a8f00c921635513b6d098af88abd6745fd8f 100644 (file)
@@ -60,7 +60,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
@@ -287,7 +287,7 @@ class Sasa : public TrajectoryAnalysisModule
     public:
         Sasa();
 
     public:
         Sasa();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
@@ -406,7 +406,7 @@ Sasa::Sasa()
 }
 
 void
 }
 
 void
-Sasa::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+Sasa::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] computes solvent accessible surface areas.",
 {
     static const char *const desc[] = {
         "[THISMODULE] computes solvent accessible surface areas.",
index 0239d188603c6ae2749689be43a94b3b631ce883..7a49a0e839dc2d53d548c3e49b8c736e4cfee7a8 100644 (file)
@@ -62,7 +62,7 @@
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/topology/topology.h"
@@ -261,7 +261,7 @@ class Select : public TrajectoryAnalysisModule
     public:
         Select();
 
     public:
         Select();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
                                  TrajectoryAnalysisSettings *settings);
         virtual void optionsFinished(Options                    *options,
                                      TrajectoryAnalysisSettings *settings);
@@ -327,7 +327,7 @@ Select::Select()
 
 
 void
 
 
 void
-Select::initOptions(Options *options, TrajectoryAnalysisSettings *settings)
+Select::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
         "[THISMODULE] writes out basic data about dynamic selections.",
 {
     static const char *const desc[] = {
         "[THISMODULE] writes out basic data about dynamic selections.",
index f7db22934184a287a8330d4c5f7f4c85e7b2a7f3..befa025b175b9cf1d3bd5a93fe4413d7634a4723 100644 (file)
@@ -53,6 +53,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/rmpbc.h"
 #include "gromacs/selection/indexutil.h"
 #include "gromacs/options/options.h"
 #include "gromacs/pbcutil/rmpbc.h"
 #include "gromacs/selection/indexutil.h"
@@ -167,7 +168,7 @@ TrajectoryAnalysisRunnerCommon::~TrajectoryAnalysisRunnerCommon()
 
 
 void
 
 
 void
-TrajectoryAnalysisRunnerCommon::initOptions(Options *options)
+TrajectoryAnalysisRunnerCommon::initOptions(IOptionsContainer *options)
 {
     TrajectoryAnalysisSettings &settings = impl_->settings_;
 
 {
     TrajectoryAnalysisSettings &settings = impl_->settings_;
 
@@ -200,7 +201,7 @@ TrajectoryAnalysisRunnerCommon::initOptions(Options *options)
     settings.impl_->timeUnitManager.addTimeUnitOption(options, "tu");
 
     // Add plot options.
     settings.impl_->timeUnitManager.addTimeUnitOption(options, "tu");
 
     // Add plot options.
-    settings.impl_->plotSettings.addOptions(options);
+    settings.impl_->plotSettings.initOptions(options);
 
     // Add common options for trajectory processing.
     if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserRmPBC))
 
     // Add common options for trajectory processing.
     if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserRmPBC))
index 3fd5057ec6ada73d27112fc3545f3ada5b7dfa07..82fea3bf7957db2080279d7de39a46709e4d2c5f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -49,6 +49,7 @@ struct t_trxframe;
 namespace gmx
 {
 
 namespace gmx
 {
 
+class IOptionsContainer;
 class Options;
 class SelectionCollection;
 class TopologyInformation;
 class Options;
 class SelectionCollection;
 class TopologyInformation;
@@ -79,7 +80,7 @@ class TrajectoryAnalysisRunnerCommon
          *
          * \param[in,out] options  Options object to add the options to.
          */
          *
          * \param[in,out] options  Options object to add the options to.
          */
-        void initOptions(Options *options);
+        void initOptions(IOptionsContainer *options);
         //! Scales time option values according to the time unit set.
         void scaleTimeOptions(Options *options);
         /*! \brief
         //! Scales time option values according to the time unit set.
         void scaleTimeOptions(Options *options);
         /*! \brief
index c0868646e6f2d685ae1cf76dd0129406f10b7395..a6a0b62320bad0e6ec9c765325559db82d7f23f1 100644 (file)
@@ -41,7 +41,7 @@
 #include "gmxpre.h"
 
 #include "gromacs/options/basicoptions.h"
 #include "gmxpre.h"
 
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/trajectoryanalysis/analysismodule.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
 #include "gromacs/trajectoryanalysis/analysismodule.h"
@@ -59,7 +59,7 @@ class SelectionTester : public TrajectoryAnalysisModule
         SelectionTester();
         virtual ~SelectionTester();
 
         SelectionTester();
         virtual ~SelectionTester();
 
-        virtual void initOptions(Options                    *options,
+        virtual void initOptions(IOptionsContainer          *options,
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
                                  TrajectoryAnalysisSettings *settings);
         virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
                                   const TopologyInformation        &top);
@@ -99,7 +99,7 @@ SelectionTester::printSelections()
 }
 
 void
 }
 
 void
-SelectionTester::initOptions(Options                    *options,
+SelectionTester::initOptions(IOptionsContainer          *options,
                              TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
                              TrajectoryAnalysisSettings *settings)
 {
     static const char *const desc[] = {
index b793af46c56d853cbbeb4e3a69ef496b1ca47ca3..3f4bd2656a25f369aefcf6ab2319fa004edce841 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "gromacs/gmxpreprocess/grompp.h"
 #include "gromacs/options/basicoptions.h"
 
 #include "gromacs/gmxpreprocess/grompp.h"
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/gmxmpi.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/gmxmpi.h"
index ad63a444f72a73bedd704209f4dcb0642478b510..2ff4a776a20e4b7e27460f2caea7ac3475e2cc0f 100644 (file)
@@ -48,7 +48,7 @@
 #include <boost/scoped_ptr.hpp>
 
 #include "gromacs/options/basicoptions.h"
 #include <boost/scoped_ptr.hpp>
 
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/textreader.h"
 
 #include "testutils/refdata.h"
 #include "gromacs/utility/textreader.h"
 
 #include "testutils/refdata.h"
index da988ea99ae12f9f15848147faedd1b156936d92..e3841fb48cabe7caab479c80d494b883327930d4 100644 (file)
@@ -52,7 +52,7 @@
 #include <gtest/gtest.h>
 
 #include "gromacs/options/basicoptions.h"
 #include <gtest/gtest.h>
 
 #include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
+#include "gromacs/options/ioptionscontainer.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/path.h"
 
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/path.h"
 
index 976b8d79892061c74a6ac35928e68428165fdd30..5f63a6d970e356793a54440633ed9b314bc4acde 100644 (file)
@@ -79,7 +79,7 @@ class TestOptionsRegistry
         }
 
         //! Initializes the options from all the provides.
         }
 
         //! Initializes the options from all the provides.
-        void initOptions(Options *options);
+        void initOptions(IOptionsContainer *options);
 
     private:
         TestOptionsRegistry() {}
 
     private:
         TestOptionsRegistry() {}
@@ -92,7 +92,7 @@ class TestOptionsRegistry
         GMX_DISALLOW_COPY_AND_ASSIGN(TestOptionsRegistry);
 };
 
         GMX_DISALLOW_COPY_AND_ASSIGN(TestOptionsRegistry);
 };
 
-void TestOptionsRegistry::initOptions(Options *options)
+void TestOptionsRegistry::initOptions(IOptionsContainer *options)
 {
     // TODO: Have some deterministic order for the options; now it depends on
     // the order in which the global initializers are run.
 {
     // TODO: Have some deterministic order for the options; now it depends on
     // the order in which the global initializers are run.
@@ -111,7 +111,7 @@ void registerTestOptions(const char *name, TestOptionsProvider *provider)
     TestOptionsRegistry::getInstance().add(name, provider);
 }
 
     TestOptionsRegistry::getInstance().add(name, provider);
 }
 
-void initTestOptions(Options *options)
+void initTestOptions(IOptionsContainer *options)
 {
     TestOptionsRegistry::getInstance().initOptions(options);
 }
 {
     TestOptionsRegistry::getInstance().initOptions(options);
 }
index bdc980504c0bc84c9c2023586d93994554192e2a..62dd76926f0ccd6d56543d092ae2cba0b2589884 100644 (file)
@@ -50,7 +50,7 @@
 namespace gmx
 {
 
 namespace gmx
 {
 
-class Options;
+class IOptionsContainer;
 
 namespace test
 {
 
 namespace test
 {
@@ -72,7 +72,7 @@ class TestOptionsProvider
          *
          * \param   options  The options need to be added here.
          */
          *
          * \param   options  The options need to be added here.
          */
-        virtual void initOptions(Options *options) = 0;
+        virtual void initOptions(IOptionsContainer *options) = 0;
 
     protected:
         virtual ~TestOptionsProvider() {}
 
     protected:
         virtual ~TestOptionsProvider() {}
@@ -106,7 +106,7 @@ void registerTestOptions(const char *name, TestOptionsProvider *provider);
  *
  * \ingroup module_testutils
  */
  *
  * \ingroup module_testutils
  */
-void initTestOptions(Options *options);
+void initTestOptions(IOptionsContainer *options);
 
 // Uncrustify screws up the indentation for the example otherwise.
 /* *INDENT-OFF* */
 
 // Uncrustify screws up the indentation for the example otherwise.
 /* *INDENT-OFF* */
@@ -127,7 +127,7 @@ void initTestOptions(Options *options);
  * Typical usage:
  * \code
    #include "gromacs/options/basicoptions.h"
  * Typical usage:
  * \code
    #include "gromacs/options/basicoptions.h"
-   #include "gromacs/options/options.h"
+   #include "gromacs/options/ioptionscontainer.h"
 
    #include "testutils/testoptions.h"
 
 
    #include "testutils/testoptions.h"
 
@@ -170,12 +170,12 @@ void initTestOptions(Options *options);
             { \
                 ::gmx::test::registerTestOptions(#name, this); \
             } \
             { \
                 ::gmx::test::registerTestOptions(#name, this); \
             } \
-            virtual void initOptions(::gmx::Options *options); \
+            virtual void initOptions(::gmx::IOptionsContainer *options); \
     }; \
     \
     static name s_ ## name ## Instance; \
     \
     }; \
     \
     static name s_ ## name ## Instance; \
     \
-    void name::initOptions(::gmx::Options *options)
+    void name::initOptions(::gmx::IOptionsContainer *options)
 
 } // namespace test
 } // namespace gmx
 
 } // namespace test
 } // namespace gmx