Merge *optioninfo.h to *option.h.
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 9 Sep 2012 10:38:29 +0000 (13:38 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 10 Sep 2012 19:02:30 +0000 (21:02 +0200)
Merge each *optioninfo.h header to the header that declared the
corresponding public option classes (setManagerForSelectionOptions() was
moved to selectionoptionmanager.*).  After 030c229 (I143592ed), there is
little need to have these in separate headers, as the OptionInfo classes
are now required when creating options.

Not having the implementation split over so many headers makes the code
easier to understand and to maintain, and this outweighs the small
benefits from being able to use the OptionInfo classes without adding a
dependency also on the Option classes (only OptionVisitor would
currently benefit from that).

Adjusted Doxygen documentation for OptionInfo and SelectionOptionInfo
(and some of the files) as part of the reorganization and did some
include cleanup related to the reorganization.  Otherwise, this change
only moves existing code around with no functional changes.

Change-Id: Ic1c62739beca09028887179da26b33516d01624b

33 files changed:
src/gromacs/commandline/cmdlinehelpwriter.cpp
src/gromacs/commandline/tests/cmdlinehelpwriter.cpp
src/gromacs/options.h
src/gromacs/options/CMakeLists.txt
src/gromacs/options/abstractoption.cpp
src/gromacs/options/abstractoption.h
src/gromacs/options/basicoptioninfo.h [deleted file]
src/gromacs/options/basicoptions.cpp
src/gromacs/options/basicoptions.h
src/gromacs/options/basicoptionstorage.h
src/gromacs/options/filenameoption.cpp
src/gromacs/options/filenameoption.h
src/gromacs/options/filenameoptioninfo.h [deleted file]
src/gromacs/options/filenameoptionstorage.h
src/gromacs/options/optioninfo.h [deleted file]
src/gromacs/options/options.h
src/gromacs/options/optionsvisitor.h
src/gromacs/options/tests/abstractoptionstorage.cpp
src/gromacs/options/timeunitmanager.cpp
src/gromacs/selection.h
src/gromacs/selection/CMakeLists.txt
src/gromacs/selection/selectionfileoption.h
src/gromacs/selection/selectionfileoptioninfo.h [deleted file]
src/gromacs/selection/selectionfileoptionstorage.h
src/gromacs/selection/selectionoption.cpp
src/gromacs/selection/selectionoption.h
src/gromacs/selection/selectionoptioninfo.h [deleted file]
src/gromacs/selection/selectionoptionmanager.cpp
src/gromacs/selection/selectionoptionmanager.h
src/gromacs/selection/selectionoptionstorage.h
src/gromacs/selection/tests/selectionoption.cpp
src/gromacs/trajectoryanalysis/cmdlinerunner.cpp
src/gromacs/trajectoryanalysis/modules/angle.cpp

index 89e6d29a9455deb42ed460a2a4506f0c7b805216..a11ebe00f8beac502234eeb7641fbd9a9f52e530 100644 (file)
 
 #include "gromacs/onlinehelp/helpformat.h"
 #include "gromacs/onlinehelp/helpwritercontext.h"
-#include "gromacs/options/basicoptioninfo.h"
-#include "gromacs/options/filenameoptioninfo.h"
+#include "gromacs/options/basicoptions.h"
+#include "gromacs/options/filenameoption.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsvisitor.h"
 #include "gromacs/options/timeunitmanager.h"
-#include "gromacs/selection/selectionfileoptioninfo.h"
-#include "gromacs/selection/selectionoptioninfo.h"
+#include "gromacs/selection/selectionfileoption.h"
+#include "gromacs/selection/selectionoption.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/file.h"
 #include "gromacs/utility/stringutil.h"
index 2c80aa9803fdacc13d6603924794ba3b53a96479..6fa71651f4c01a8aeed752e52699e0e2cc3775ea 100644 (file)
@@ -53,7 +53,6 @@
 #include "gromacs/selection/selectioncollection.h"
 #include "gromacs/selection/selectionfileoption.h"
 #include "gromacs/selection/selectionoption.h"
-#include "gromacs/selection/selectionoptioninfo.h"
 #include "gromacs/selection/selectionoptionmanager.h"
 #include "gromacs/utility/file.h"
 
index 6f0797cae250e23e95cf51e439e4cf5e40f1ba7f..8984423bc86d33aa0cc9824c20e82b89976ea1ef 100644 (file)
@@ -78,9 +78,7 @@
 #ifndef GMX_OPTIONS_H
 #define GMX_OPTIONS_H
 
-#include "options/basicoptioninfo.h"
 #include "options/basicoptions.h"
-#include "options/filenameoptioninfo.h"
 #include "options/filenameoption.h"
 #include "options/options.h"
 
index 7b9e90e5b23b6867ad62eea0a62c383ce501d216..c81e0aa803dfcab9d6c4a0963e642951c3ccca4e 100644 (file)
@@ -3,13 +3,10 @@ set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${OPTIONS_SOURCES} PARENT_SCOPE)
 
 set(OPTIONS_PUBLIC_HEADERS
     abstractoption.h
-    basicoptioninfo.h
     basicoptions.h
     filenameoption.h
-    filenameoptioninfo.h
     optionfiletype.h
     optionflags.h
-    optioninfo.h
     options.h
     timeunitmanager.h)
 install(FILES ${OPTIONS_PUBLIC_HEADERS}
index a4d8685bcfee2f2625ffd91fd72a042be64f1893..f4d5dfc108622c45ab5f43349d91689688fa0114 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "gromacs/options/abstractoptionstorage.h"
 #include "gromacs/options/optionflags.h"
-#include "gromacs/options/optioninfo.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 
index 50a0c023f073b50b04d97a51b0a91576cd40e2b0..ba2fccb2cfac3c76bbd6a5a3de6753df5027a716 100644 (file)
@@ -30,7 +30,7 @@
  */
 /*! \file
  * \brief
- * Defines gmx::AbstractOption and a related template.
+ * Defines gmx::AbstractOption, gmx::OptionTemplate and gmx::OptionInfo.
  *
  * This header defines base classes for option settings that are used with
  * Options::addOption().  These classes implement the "named parameter"
@@ -53,6 +53,7 @@
 #include <string>
 #include <vector>
 
+#include "../utility/common.h"
 #include "../utility/uniqueptr.h"
 
 #include "optionflags.h"
@@ -370,6 +371,121 @@ class OptionTemplate : public AbstractOption
         friend class OptionStorageTemplate<T>;
 };
 
+/*! \brief
+ * Gives information and allows modifications to an option after creation.
+ *
+ * When an option is added with Options::addOption(), an object of a subclass
+ * of OptionInfo is returned.  This object can be later used to access
+ * information about the option.  Non-const methods also allow later changing
+ * (some of) the option settings provided at initialization time.
+ * The properties accessible/modifiable through this interface are implemented
+ * based on need, and may not be implemented for all cases.
+ *
+ * \if libapi
+ * This class is also used by OptionsVisitor and OptionsModifyingVisitor as
+ * the interface that allows querying/modifying each visited option.
+ * \endif
+ *
+ * This class isolates the details of the internal option implementation from
+ * callers.  Although this class is a simple reference to the underlying
+ * implementation, it is implemented as non-copyable to allow const/non-const
+ * status of a reference to this class to indicate whether modifications are
+ * allowed.  Otherwise, separate classes would be needed for access and
+ * modification, complicating the implementation.  In the implementation,
+ * there is always a single OptionInfo instance referring to one option.
+ * The underlying implementation object always owns this instance, and only
+ * references are passed to callers.
+ *
+ * \see Options::addOption()
+ * \if libapi
+ * \see OptionsVisitor
+ * \see OptionsModifyingVisitor
+ * \endif
+ *
+ * \inpublicapi
+ * \ingroup module_options
+ */
+class OptionInfo
+{
+    public:
+        virtual ~OptionInfo();
+
+        /*! \brief
+         * Test whether the option is of a particular type.
+         *
+         * \tparam InfoType  Option type to test for. Should be a class derived
+         *      from OptionInfo.
+         */
+        template <class InfoType>
+        bool isType() const
+        {
+            return toType<InfoType>() != NULL;
+        }
+        /*! \brief
+         * Convert the info object to a particular type if the type is correct.
+         *
+         * \tparam InfoType  Option type to convert to. Should be a class
+         *      derived from OptionInfo.
+         * \retval this converted to a pointer to \p InfoType, or NULL if the
+         *      conversion is not possible.
+         */
+        template <class InfoType>
+        InfoType *toType()
+        {
+            return dynamic_cast<InfoType *>(this);
+        }
+        //! \copydoc toType()
+        template <class InfoType>
+        const InfoType *toType() const
+        {
+            return dynamic_cast<const InfoType *>(this);
+        }
+
+        //! Returns true if the option has been set.
+        bool isSet() const;
+        //! Returns true if the option is a hidden option.
+        bool isHidden() const;
+        //! Returns true if the option is required.
+        bool isRequired() const;
+        //! Returns the name of the option.
+        const std::string &name() const;
+        //! Returns the description of the option.
+        const std::string &description() const;
+        //! Returns the type of the option as a string.
+        const char *type() const;
+        //! Returns the number of values given for the option.
+        int valueCount() const;
+        //! Returns the i'th value of the option as a string.
+        std::string formatValue(int i) const;
+        /*! \brief
+         * Returns the default value if set for the option as a string.
+         *
+         * \see OptionTemplate::defaultValueIfSet()
+         */
+        std::string formatDefaultValueIfSet() const;
+
+    protected:
+        /*! \cond libapi */
+        /*! \brief
+         * Wraps a given option object.
+         *
+         * Does not throw.
+         */
+        explicit OptionInfo(AbstractOptionStorage *option);
+
+        //! Returns the wrapped option storage object.
+        AbstractOptionStorage &option() { return option_; }
+        //! Returns the wrapped option storage object.
+        const AbstractOptionStorage &option() const { return option_; }
+        //! \endcond
+
+    private:
+        //! The wrapped option.
+        AbstractOptionStorage  &option_;
+
+        GMX_DISALLOW_COPY_AND_ASSIGN(OptionInfo);
+};
+
 } // namespace gmx
 
 #endif
diff --git a/src/gromacs/options/basicoptioninfo.h b/src/gromacs/options/basicoptioninfo.h
deleted file mode 100644 (file)
index 5e19c0e..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, 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 www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \file
- * \brief
- * Declares option info objects for basic option types.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inpublicapi
- * \ingroup module_options
- */
-#ifndef GMX_OPTIONS_BASICOPTIONINFO_H
-#define GMX_OPTIONS_BASICOPTIONINFO_H
-
-#include "optioninfo.h"
-
-namespace gmx
-{
-
-class BooleanOptionStorage;
-class IntegerOptionStorage;
-class DoubleOptionStorage;
-class StringOptionStorage;
-
-/*! \addtogroup module_options
- * \{
- */
-
-/*! \brief
- * Wrapper class for accessing boolean option information.
- *
- * \inpublicapi
- */
-class BooleanOptionInfo : public OptionInfo
-{
-    public:
-        //! Creates an option info object for the given option.
-        explicit BooleanOptionInfo(BooleanOptionStorage *option);
-};
-
-/*! \brief
- * Wrapper class for accessing integer option information.
- *
- * \inpublicapi
- */
-class IntegerOptionInfo : public OptionInfo
-{
-    public:
-        //! Creates an option info object for the given option.
-        explicit IntegerOptionInfo(IntegerOptionStorage *option);
-};
-
-/*! \brief
- * Wrapper class for accessing floating-point option information.
- *
- * \inpublicapi
- */
-class DoubleOptionInfo : public OptionInfo
-{
-    public:
-        //! Creates an option info object for the given option.
-        explicit DoubleOptionInfo(DoubleOptionStorage *option);
-
-        //! Whether the option specifies a time value.
-        bool isTime() const;
-
-        /*! \brief
-         * Sets a scale factor for user-provided values.
-         *
-         * Any user-provided value is scaled by the provided factor.
-         * Programmatically set default values are not scaled.
-         * If called multiple times, later calls override the previously set
-         * value.  In other words, the scaling is not cumulative.
-         */
-        void setScaleFactor(double factor);
-
-    private:
-        DoubleOptionStorage &option();
-        const DoubleOptionStorage &option() const;
-};
-
-/*! \brief
- * Wrapper class for accessing string option information.
- *
- * \inpublicapi
- */
-class StringOptionInfo : public OptionInfo
-{
-    public:
-        //! Creates an option info object for the given option.
-        explicit StringOptionInfo(StringOptionStorage *option);
-};
-
-/*!\}*/
-
-} // namespace gmx
-
-#endif
index 96ec04d8592d9bb18378945bf02f209bed90f5e8..0f0826b3563465695fb741d60ec37c21ffa5f48f 100644 (file)
  */
 /*! \internal \file
  * \brief
- * Implements classes in basicoptions.h, basicoptioninfo.h and
- * basicoptionstorage.h.
+ * Implements classes in basicoptions.h and basicoptionstorage.h.
  *
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \ingroup module_options
  */
-#include "gromacs/options/basicoptions.h"
+#include "basicoptions.h"
+#include "basicoptionstorage.h"
 
 #include <cerrno>
 #include <cstdio>
 #include <string>
 #include <vector>
 
-#include "gromacs/options/basicoptioninfo.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/stringutil.h"
 
-#include "basicoptionstorage.h"
-
 namespace
 {
 
index 5d6904536e22293a8bec960bd85cc4379b60cc7b..c43b5f747dc632e42eb6fa6e01885dac70da2635 100644 (file)
@@ -30,7 +30,7 @@
  */
 /*! \file
  * \brief
- * Declares option settings objects for basic option types.
+ * Declares option objects for basic option types.
  *
  * Together with options.h, this header forms the part of the public API
  * that most classes will use to provide options.
 #include "../utility/gmxassert.h"
 
 #include "abstractoption.h"
-#include "basicoptioninfo.h"
 
 namespace gmx
 {
 
+class BooleanOptionInfo;
+class BooleanOptionStorage;
+class IntegerOptionInfo;
 class IntegerOptionStorage;
+class DoubleOptionInfo;
 class DoubleOptionStorage;
+class StringOptionInfo;
 class StringOptionStorage;
 
 /*! \addtogroup module_options
@@ -276,6 +280,71 @@ class StringOption : public OptionTemplate<std::string, StringOption>
         friend class StringOptionStorage;
 };
 
+/*! \brief
+ * Wrapper class for accessing boolean option information.
+ *
+ * \inpublicapi
+ */
+class BooleanOptionInfo : public OptionInfo
+{
+    public:
+        //! Creates an option info object for the given option.
+        explicit BooleanOptionInfo(BooleanOptionStorage *option);
+};
+
+/*! \brief
+ * Wrapper class for accessing integer option information.
+ *
+ * \inpublicapi
+ */
+class IntegerOptionInfo : public OptionInfo
+{
+    public:
+        //! Creates an option info object for the given option.
+        explicit IntegerOptionInfo(IntegerOptionStorage *option);
+};
+
+/*! \brief
+ * Wrapper class for accessing floating-point option information.
+ *
+ * \inpublicapi
+ */
+class DoubleOptionInfo : public OptionInfo
+{
+    public:
+        //! Creates an option info object for the given option.
+        explicit DoubleOptionInfo(DoubleOptionStorage *option);
+
+        //! Whether the option specifies a time value.
+        bool isTime() const;
+
+        /*! \brief
+         * Sets a scale factor for user-provided values.
+         *
+         * Any user-provided value is scaled by the provided factor.
+         * Programmatically set default values are not scaled.
+         * If called multiple times, later calls override the previously set
+         * value.  In other words, the scaling is not cumulative.
+         */
+        void setScaleFactor(double factor);
+
+    private:
+        DoubleOptionStorage &option();
+        const DoubleOptionStorage &option() const;
+};
+
+/*! \brief
+ * Wrapper class for accessing string option information.
+ *
+ * \inpublicapi
+ */
+class StringOptionInfo : public OptionInfo
+{
+    public:
+        //! Creates an option info object for the given option.
+        explicit StringOptionInfo(StringOptionStorage *option);
+};
+
 /*!\}*/
 
 } // namespace gmx
index 8438135f5bfa1a7aa23c2540ee06e54ede91991b..4c50d9187538ded87efafd15fc7ef945667ca485 100644 (file)
@@ -42,7 +42,6 @@
 #include <vector>
 
 #include "basicoptions.h"
-#include "basicoptioninfo.h"
 #include "optionstoragetemplate.h"
 
 namespace gmx
index c4f1b4a73968d77962f7fa1c4f048e7208a0ff98..099c7968b9628bbeabc076d1a8b5e60499eef9bc 100644 (file)
  */
 /*! \internal \file
  * \brief
- * Implements classes in filenameoption.h, filenameoptioninfo.h and
- * filenameoptionstorage.h.
+ * Implements classes in filenameoption.h and filenameoptionstorage.h.
  *
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \ingroup module_options
  */
 #include "filenameoption.h"
+#include "filenameoptionstorage.h"
 
 #include <string>
 #include <vector>
 
-#include "gromacs/options/filenameoptioninfo.h"
 #include "gromacs/utility/file.h"
 #include "gromacs/utility/stringutil.h"
 
-#include "filenameoptionstorage.h"
-
 namespace gmx
 {
 
index 0b5e64bbda967cf4ee756a31260720fd54a8f163..280d7a87ad59894395f608bc502bb21187597cb1 100644 (file)
@@ -30,7 +30,7 @@
  */
 /*! \file
  * \brief
- * Declares gmx::FileNameOption for setting file name options.
+ * Declares gmx::FileNameOption and gmx::FileNameOptionInfo.
  *
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \inpublicapi
 #include <string>
 
 #include "abstractoption.h"
-#include "filenameoptioninfo.h"
 #include "optionfiletype.h"
 
 namespace gmx
 {
 
+class FileNameOptionInfo;
 class FileNameOptionStorage;
 
 /*! \brief
@@ -114,6 +114,35 @@ class FileNameOption : public OptionTemplate<std::string, FileNameOption>
         friend class FileNameOptionStorage;
 };
 
+/*! \brief
+ * Wrapper class for accessing file name option information.
+ *
+ * \inpublicapi
+ * \ingroup module_options
+ */
+class FileNameOptionInfo : public OptionInfo
+{
+    public:
+        //! Creates an option info object for the given option.
+        explicit FileNameOptionInfo(FileNameOptionStorage *option);
+
+        //! Whether the option specifies an input file.
+        bool isInputFile() const;
+        //! Whether the option specifies an output file.
+        bool isOutputFile() const;
+        //! Whether the option specifies a file used for both input and output.
+        bool isInputOutputFile() const;
+        /*! \brief
+         * Whether the option specifies a library file.
+         *
+         * \see FileNameOption::libraryFile()
+         */
+        bool isLibraryFile() const;
+
+    private:
+        const FileNameOptionStorage &option() const;
+};
+
 } // namespace gmx
 
 #endif
diff --git a/src/gromacs/options/filenameoptioninfo.h b/src/gromacs/options/filenameoptioninfo.h
deleted file mode 100644 (file)
index be6fdf1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, 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 www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \file
- * \brief
- * Declares gmx::FileNameOptionInfo.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inpublicapi
- * \ingroup module_options
- */
-#ifndef GMX_OPTIONS_FILENAMEOPTIONINFO_H
-#define GMX_OPTIONS_FILENAMEOPTIONINFO_H
-
-#include "optioninfo.h"
-
-namespace gmx
-{
-
-class FileNameOptionStorage;
-
-/*! \brief
- * Wrapper class for accessing file name option information.
- *
- * \inpublicapi
- * \ingroup module_options
- */
-class FileNameOptionInfo : public OptionInfo
-{
-    public:
-        //! Creates an option info object for the given option.
-        explicit FileNameOptionInfo(FileNameOptionStorage *option);
-
-        //! Whether the option specifies an input file.
-        bool isInputFile() const;
-        //! Whether the option specifies an output file.
-        bool isOutputFile() const;
-        //! Whether the option specifies a file used for both input and output.
-        bool isInputOutputFile() const;
-        /*! \brief
-         * Whether the option specifies a library file.
-         *
-         * \see FileNameOption::libraryFile()
-         */
-        bool isLibraryFile() const;
-
-    private:
-        const FileNameOptionStorage &option() const;
-};
-
-} // namespace gmx
-
-#endif
index 6db97156c84eb62700c9ea2435a56103b41585a4..64b60d4f86f84042308de3ed3aec9a6c978d10b9 100644 (file)
@@ -41,7 +41,6 @@
 #include <string>
 
 #include "filenameoption.h"
-#include "filenameoptioninfo.h"
 #include "optionfiletype.h"
 #include "optionstoragetemplate.h"
 
diff --git a/src/gromacs/options/optioninfo.h b/src/gromacs/options/optioninfo.h
deleted file mode 100644 (file)
index 49fb30b..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, 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 www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \file
- * \brief
- * Declares gmx::OptionInfo.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inpublicapi
- * \ingroup module_options
- */
-#ifndef GMX_OPTIONS_OPTIONINFO_H
-#define GMX_OPTIONS_OPTIONINFO_H
-
-#include <cstddef>
-
-#include <string>
-
-#include "../utility/common.h"
-
-namespace gmx
-{
-
-class AbstractOptionStorage;
-
-/*! \brief
- * Wrapper class for accessing option information.
- *
- * This class isolates the details of the internal option implementation
- * from option visitors.  Non-const methods in this class or in derived classes
- * also allow modifying the underlying option after its initial creation with
- * Options::addOption().
- *
- * \see OptionsVisitor
- * \see OptionsModifyingVisitor
- *
- * \inpublicapi
- * \ingroup module_options
- */
-class OptionInfo
-{
-    public:
-        virtual ~OptionInfo();
-
-        /*! \brief
-         * Test whether the option is of a particular type.
-         *
-         * \tparam InfoType  Option type to test for. Should be a class derived
-         *      from OptionInfo.
-         */
-        template <class InfoType>
-        bool isType() const
-        {
-            return toType<InfoType>() != NULL;
-        }
-        /*! \brief
-         * Convert the info object to a particular type if the type is correct.
-         *
-         * \tparam InfoType  Option type to convert to. Should be a class
-         *      derived from OptionInfo.
-         * \retval this converted to a pointer to \p InfoType, or NULL if the
-         *      conversion is not possible.
-         */
-        template <class InfoType>
-        InfoType *toType()
-        {
-            return dynamic_cast<InfoType *>(this);
-        }
-        //! \copydoc toType()
-        template <class InfoType>
-        const InfoType *toType() const
-        {
-            return dynamic_cast<const InfoType *>(this);
-        }
-
-        //! Returns true if the option has been set.
-        bool isSet() const;
-        //! Returns true if the option is a hidden option.
-        bool isHidden() const;
-        //! Returns true if the option is required.
-        bool isRequired() const;
-        //! Returns the name of the option.
-        const std::string &name() const;
-        //! Returns the description of the option.
-        const std::string &description() const;
-        //! Returns the type of the option as a string.
-        const char *type() const;
-        //! Returns the number of values given for the option.
-        int valueCount() const;
-        //! Returns the i'th value of the option as a string.
-        std::string formatValue(int i) const;
-        /*! \brief
-         * Returns the default value if set for the option as a string.
-         *
-         * \see OptionTemplate::defaultValueIfSet()
-         */
-        std::string formatDefaultValueIfSet() const;
-
-    protected:
-        /*! \cond libapi */
-        /*! \brief
-         * Wraps a given option object.
-         *
-         * Does not throw.
-         */
-        explicit OptionInfo(AbstractOptionStorage *option);
-
-        //! Returns the wrapped option storage object.
-        AbstractOptionStorage &option() { return option_; }
-        //! Returns the wrapped option storage object.
-        const AbstractOptionStorage &option() const { return option_; }
-        //! \endcond
-
-    private:
-        //! The wrapped option.
-        AbstractOptionStorage  &option_;
-
-        GMX_DISALLOW_COPY_AND_ASSIGN(OptionInfo);
-};
-
-} // namespace gmx
-
-#endif
index c6f264019aafa9d122e04d7d827c9aae98f0889e..3caf93b5a971be3dc46d24f75e3a68d2ee617438 100644 (file)
@@ -47,7 +47,7 @@
 #include "../utility/common.h"
 #include "../utility/gmxassert.h"
 
-#include "optioninfo.h"
+#include "abstractoption.h"
 
 namespace gmx
 {
index aef9ee38461ff3df9866528c83a4f8eb0c4b8bd1..2a4e95b06a9870b0151ee5560b225fda6e9056b1 100644 (file)
@@ -45,7 +45,7 @@
 
 #include "../utility/common.h"
 
-#include "optioninfo.h"
+#include "abstractoption.h"
 
 namespace gmx
 {
index c62c9aa247a6bd2c870a50568d9ab0a36134222a..b0a949195f0d9336ca9282a4181a0aa288e2736c 100644 (file)
@@ -45,7 +45,6 @@
 #include <gtest/gtest.h>
 
 #include "gromacs/options/abstractoption.h"
-#include "gromacs/options/optioninfo.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionstoragetemplate.h"
 #include "gromacs/options/optionsassigner.h"
index 0b15b60f76920df69d9ca60f19f217fd5e5504c0..dfa410b18563454dab87273a9d5db1aa7f2cf07d 100644 (file)
@@ -37,7 +37,6 @@
  */
 #include "gromacs/options/timeunitmanager.h"
 
-#include "gromacs/options/basicoptioninfo.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsvisitor.h"
index 2ca93137eafd37bf9fb53a8253ad4b584ff89768..7d175cdfb6accc2e5a8972e02cb1ce3476794623 100644 (file)
@@ -89,7 +89,6 @@
 #include "selection/selection.h"
 #include "selection/selectioncollection.h"
 #include "selection/selectionoption.h"
-#include "selection/selectionoptioninfo.h"
 #include "selection/selectionoptionmanager.h"
 
 #endif
index 40437385f3b4fdd75984b7c96e6fb2643a1c5dc8..acd52c0c080c3e7bb3b2b04b300b59e6595e1fe0 100644 (file)
@@ -9,7 +9,6 @@ set(SELECTION_PUBLIC_HEADERS
     selectioncollection.h
     selectionenums.h
     selectionoption.h
-    selectionoptioninfo.h
     selectionoptionmanager.h)
 install(FILES ${SELECTION_PUBLIC_HEADERS}
         DESTINATION ${INCL_INSTALL_DIR}/gromacs/selection
index 10a63a5bd7edb9151068dc6a105891919ec84370..9fcf3f3efe94de34b3f291b85b19cd8d90e7d04d 100644 (file)
@@ -30,7 +30,7 @@
  */
 /*! \libinternal \file
  * \brief
- * Declares gmx::SelectionFileOption.
+ * Declares gmx::SelectionFileOption and gmx::SelectionFileOptionInfo.
  *
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \inlibraryapi
 namespace gmx
 {
 
+class SelectionFileOptionInfo;
+class SelectionFileOptionStorage;
+class SelectionOptionManager;
+
 /*! \libinternal \brief
  * Specifies a special option that provides selections from a file.
  *
@@ -61,6 +65,9 @@ namespace gmx
 class SelectionFileOption : public AbstractOption
 {
     public:
+        //! OptionInfo subclass corresponding to this option type.
+        typedef SelectionFileOptionInfo InfoType;
+
         //! Initializes an option with the given name.
         explicit SelectionFileOption(const char *name);
 
@@ -68,6 +75,30 @@ class SelectionFileOption : public AbstractOption
         virtual AbstractOptionStoragePointer createStorage() const;
 };
 
+/*! \libinternal \brief
+ * Wrapper class for accessing and modifying selection file option information.
+ *
+ * \inlibraryapi
+ * \ingroup module_selection
+ */
+class SelectionFileOptionInfo : public OptionInfo
+{
+    public:
+        /*! \brief
+         * Creates option info object for given storage object.
+         *
+         * Does not throw.
+         */
+        explicit SelectionFileOptionInfo(SelectionFileOptionStorage *option);
+
+        //! \copydoc SelectionOptionInfo::setManager()
+        void setManager(SelectionOptionManager *manager);
+
+    private:
+        SelectionFileOptionStorage &option();
+        const SelectionFileOptionStorage &option() const;
+};
+
 } // namespace gmx
 
 #endif
diff --git a/src/gromacs/selection/selectionfileoptioninfo.h b/src/gromacs/selection/selectionfileoptioninfo.h
deleted file mode 100644 (file)
index f189899..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, 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 www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \libinternal \file
- * \brief
- * Declares gmx::SelectionFileOptionInfo.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inlibraryapi
- * \ingroup module_selection
- */
-#ifndef GMX_SELECTION_SELECTIONFILEOPTIONINFO_H
-#define GMX_SELECTION_SELECTIONFILEOPTIONINFO_H
-
-#include "../options/optioninfo.h"
-
-namespace gmx
-{
-
-class SelectionFileOptionStorage;
-class SelectionOptionManager;
-
-/*! \libinternal \brief
- * Wrapper class for accessing and modifying selection file option information.
- *
- * \inlibraryapi
- * \ingroup module_selection
- */
-class SelectionFileOptionInfo : public OptionInfo
-{
-    public:
-        /*! \brief
-         * Creates option info object for given storage object.
-         *
-         * Does not throw.
-         */
-        explicit SelectionFileOptionInfo(SelectionFileOptionStorage *option);
-
-        //! \copydoc SelectionOptionInfo::setManager()
-        void setManager(SelectionOptionManager *manager);
-
-    private:
-        SelectionFileOptionStorage &option();
-        const SelectionFileOptionStorage &option() const;
-};
-
-} // namespace gmx
-
-#endif
index 12a29cc7bd248b8088c3a88948a490733bc3b78e..5c5ef38be7962f65190531add302c4b31da510e5 100644 (file)
@@ -39,7 +39,7 @@
 #define GMX_SELECTION_SELECTIONFILEOPTIONSTORAGE_H
 
 #include "../options/abstractoptionstorage.h"
-#include "selectionfileoptioninfo.h"
+#include "selectionfileoption.h"
 
 namespace gmx
 {
index 911628028498e5cf9f6d6e406b2a0baecc5ebe8b..03a6420044747e593f5daa9c5f9dcf208e0396c9 100644 (file)
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \ingroup module_selection
  */
-#include "selectionfileoption.h"
-#include "selectionfileoptioninfo.h"
 #include "selectionoption.h"
-#include "selectionoptioninfo.h"
+#include "selectionfileoption.h"
+#include "selectionoptionstorage.h"
+#include "selectionfileoptionstorage.h"
 
 #include <string>
 
-#include "gromacs/options/optionsvisitor.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoptionmanager.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/messagestringcollector.h"
 
-#include "selectionfileoptionstorage.h"
-#include "selectionoptionstorage.h"
-
 namespace gmx
 {
 
@@ -354,61 +350,4 @@ AbstractOptionStoragePointer SelectionFileOption::createStorage() const
     return AbstractOptionStoragePointer(new SelectionFileOptionStorage(*this));
 }
 
-
-/********************************************************************
- * Global functions
- */
-
-namespace
-{
-
-/*! \internal \brief
- * Visitor that sets the manager for each selection option.
- *
- * \ingroup module_selection
- */
-class SelectionOptionManagerSetter : public OptionsModifyingVisitor
-{
-    public:
-        //! Construct a visitor that sets given manager.
-        explicit SelectionOptionManagerSetter(SelectionOptionManager *manager)
-            : manager_(manager)
-        {
-        }
-
-        void visitSubSection(Options *section)
-        {
-            OptionsModifyingIterator iterator(section);
-            iterator.acceptSubSections(this);
-            iterator.acceptOptions(this);
-        }
-
-        void visitOption(OptionInfo *option)
-        {
-            SelectionOptionInfo *selOption
-                = option->toType<SelectionOptionInfo>();
-            if (selOption != NULL)
-            {
-                selOption->setManager(manager_);
-            }
-            SelectionFileOptionInfo *selFileOption
-                = option->toType<SelectionFileOptionInfo>();
-            if (selFileOption != NULL)
-            {
-                selFileOption->setManager(manager_);
-            }
-        }
-
-    private:
-        SelectionOptionManager *manager_;
-};
-
-} // namespace
-
-void setManagerForSelectionOptions(Options *options,
-                                   SelectionOptionManager *manager)
-{
-    SelectionOptionManagerSetter(manager).visitSubSection(options);
-}
-
 } // namespace gmx
index 18c1b3e137902f79b6a2ffbbf97125070e050b8f..20c9083fb9f19aee22df10c33b7dc4402f19327b 100644 (file)
@@ -30,7 +30,7 @@
  */
 /*! \file
  * \brief
- * Declares gmx::SelectionOption.
+ * Declares gmx::SelectionOption and gmx::SelectionOptionInfo.
  *
  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
  * \inpublicapi
 #define GMX_SELECTION_SELECTIONOPTION_H
 
 #include "../options/abstractoption.h"
+
 #include "selection.h"
 #include "selectionenums.h"
-#include "selectionoptioninfo.h"
 
 namespace gmx
 {
 
 class SelectionOptionInfo;
+class SelectionOptionManager;
 class SelectionOptionStorage;
 
 /*! \brief
@@ -139,6 +140,159 @@ class SelectionOption : public OptionTemplate<Selection, SelectionOption>
         friend class SelectionOptionStorage;
 };
 
+/*! \brief
+ * Wrapper class for accessing and modifying selection option information.
+ *
+ * Allows changes to a selection option after creation.
+ *
+ * This class provides the necessary interface for changing, e.g., the number
+ * of allowed selections for a selection option after the option has been
+ * created with Options::addOption().  This is needed if the number or other
+ * flags are only known after other options have been parsed.  The main
+ * advantage of this class over custom checks is that if used before
+ * interactive selection prompt, the interactive prompt is updated accordingly.
+ *
+ * When using this class, the option should be initially created with the most
+ * permissive flags, and this class should be used to place restrictions where
+ * 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
+ * place before interactive selection prompts.
+ *
+ * An instance of this class for a selection option can be obtained with
+ * SelectionOption::getAdjuster() when the option is created.
+ *
+ * Example use:
+ * \code
+SelectionList sel;
+Options options("example", "Example options");
+SelectionOptionInfo *info;
+info = options.addOption(SelectionOption("sel").storeVector(&sel)
+                             .multiValue());
+// < ... assign values to options ...>
+if ( condition )
+{
+    // Put limitations on the selections based on the condition,
+    // which can depend on other option values.
+    // Throws if input given so far violates the limitations.
+    info->setValueCount(2);
+    info->setOnlyStatic(true);
+}
+ * \endcode
+ *
+ * \inpublicapi
+ * \ingroup module_selection
+ */
+class SelectionOptionInfo : public OptionInfo
+{
+    public:
+        /*! \brief
+         * Creates option info object for given storage object.
+         *
+         * Does not throw.
+         */
+        explicit SelectionOptionInfo(SelectionOptionStorage *option);
+
+        /*! \brief
+         * Set manager for handling interaction with other options and the
+         * selection collection.
+         *
+         * \param   manager  Selection manager to set.
+         *
+         * This must be called before the values are added.
+         *
+         * Typically it is called through setManagerForSelectionOptions(),
+         * which recursively sets the manager for all selection options in
+         * an Options object.
+         *
+         * Does not throw.
+         */
+        void setManager(SelectionOptionManager *manager);
+
+        /*! \brief
+         * Sets the number of selections allowed for the option.
+         *
+         * \param[in] count  Number of allowed selections.
+         * \throws    std::bad_alloc if out of memory.
+         * \throws    InvalidInputError if values have already been provided
+         *      and their count does not match.
+         */
+        void setValueCount(int count);
+
+        /*! \brief
+         * Sets whether this option evaluates velocities for positions.
+         *
+         * \param[in] bEnabled  If true, velocities are evaluated.
+         *
+         * Does not throw.
+         *
+         * \see SelectionOption::evaluateVelocities()
+         */
+        void setEvaluateVelocities(bool bEnabled);
+        /*! \brief
+         * Sets whether this option evaluates forces for positions.
+         *
+         * \param[in] bEnabled  If true, forces are evaluated.
+         *
+         * Does not throw.
+         *
+         * \see SelectionOption::evaluateForces()
+         */
+        void setEvaluateForces(bool bEnabled);
+        /*! \brief
+         * Sets whether this option accepts positions that come from multiple
+         * atoms.
+         *
+         * \param[in] bEnabled  If true, the option accepts only positions that
+         *      evaluate to atom positions.
+         *
+         * TODO: This is not yet implemented.
+         *
+         * \see SelectionOption::onlyAtoms()
+         */
+        void setOnlyAtoms(bool bEnabled);
+        /*! \brief
+         * Sets whether this option accepts dynamic selections.
+         *
+         * \param[in] bEnabled  If true, the option accepts only static
+         *      selections.
+         * \throws    std::bad_alloc if out of memory.
+         * \throws    InvalidInputError if dynamic selections have already been
+         *      provided.
+         *
+         * Strong exception safety guarantee.
+         *
+         * \see SelectionOption::onlyStatic()
+         */
+        void setOnlyStatic(bool bEnabled);
+        /*! \brief
+         * Sets whether this option uses position masks for dynamic selections.
+         *
+         * \param[in] bEnabled  If true, the position masks are used.
+         *
+         * Does not throw.
+         *
+         * \see SelectionOption::dynamicMask()
+         */
+        void setDynamicMask(bool bEnabled);
+        /*! \brief
+         * Sets whether atom coordinates are allowed as reference positions.
+         *
+         * \param[in] bEnabled  If true, the option does not accept atom
+         *      coordinates as reference positions.
+         *
+         * TODO: This is not yet implemented.
+         *
+         * \see SelectionOption::dynamicOnlyWhole()
+         */
+        void setDynamicOnlyWhole(bool bEnabled);
+
+    private:
+        SelectionOptionStorage &option();
+        const SelectionOptionStorage &option() const;
+};
+
 } // namespace gmx
 
 #endif
diff --git a/src/gromacs/selection/selectionoptioninfo.h b/src/gromacs/selection/selectionoptioninfo.h
deleted file mode 100644 (file)
index 3a05b2c..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, 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 www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \file
- * \brief
- * Declares gmx::SelectionOptionInfo.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inpublicapi
- * \ingroup module_selection
- */
-#ifndef GMX_SELECTION_SELECTIONOPTIONINFO_H
-#define GMX_SELECTION_SELECTIONOPTIONINFO_H
-
-#include "../options/optioninfo.h"
-
-namespace gmx
-{
-
-class Options;
-class SelectionOptionManager;
-class SelectionOptionStorage;
-
-/*! \brief
- * Wrapper class for accessing and modifying selection option information.
- *
- * Allows changes to a selection option after creation.
- *
- * This class provides the necessary interface for changing, e.g., the number
- * of allowed selections for a selection option after the option has been
- * created with Options::addOption().  This is needed if the number or other
- * flags are only known after other options have been parsed.  The main
- * advantage of this class over custom checks is that if used before
- * interactive selection prompt, the interactive prompt is updated accordingly.
- *
- * When using this class, the option should be initially created with the most
- * permissive flags, and this class should be used to place restrictions where
- * 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
- * place before interactive selection prompts.
- *
- * An instance of this class for a selection option can be obtained with
- * SelectionOption::getAdjuster() when the option is created.
- *
- * Example use:
- * \code
-SelectionList sel;
-Options options("example", "Example options");
-SelectionOptionInfo *info;
-options.addOption(SelectionOption("sel").storeVector(&sel)
-                      .multiValue().getAdjuster(&info));
-// < ... assign values to options ...>
-if ( condition )
-{
-    // Put limitations on the selections based on the condition,
-    // which can depend on other option values.
-    // Throws if input given so far violates the limitations.
-    info->setValueCount(2);
-    info->setOnlyStatic(true);
-}
- * \endcode
- *
- * \inpublicapi
- * \ingroup module_selection
- */
-class SelectionOptionInfo : public OptionInfo
-{
-    public:
-        /*! \brief
-         * Creates option info object for given storage object.
-         *
-         * Does not throw.
-         */
-        explicit SelectionOptionInfo(SelectionOptionStorage *option);
-
-        /*! \brief
-         * Set manager for handling interaction with other options and the
-         * selection collection.
-         *
-         * \param   manager  Selection manager to set.
-         *
-         * This must be called before the values are added.
-         *
-         * Typically it is called through setManagerForSelectionOptions(),
-         * which recursively sets the manager for all selection options in
-         * an Options object.
-         *
-         * Does not throw.
-         */
-        void setManager(SelectionOptionManager *manager);
-
-        /*! \brief
-         * Sets the number of selections allowed for the option.
-         *
-         * \param[in] count  Number of allowed selections.
-         * \throws    std::bad_alloc if out of memory.
-         * \throws    InvalidInputError if values have already been provided
-         *      and their count does not match.
-         */
-        void setValueCount(int count);
-
-        /*! \brief
-         * Sets whether this option evaluates velocities for positions.
-         *
-         * \param[in] bEnabled  If true, velocities are evaluated.
-         *
-         * Does not throw.
-         *
-         * \see SelectionOption::evaluateVelocities()
-         */
-        void setEvaluateVelocities(bool bEnabled);
-        /*! \brief
-         * Sets whether this option evaluates forces for positions.
-         *
-         * \param[in] bEnabled  If true, forces are evaluated.
-         *
-         * Does not throw.
-         *
-         * \see SelectionOption::evaluateForces()
-         */
-        void setEvaluateForces(bool bEnabled);
-        /*! \brief
-         * Sets whether this option accepts positions that come from multiple
-         * atoms.
-         *
-         * \param[in] bEnabled  If true, the option accepts only positions that
-         *      evaluate to atom positions.
-         *
-         * TODO: This is not yet implemented.
-         *
-         * \see SelectionOption::onlyAtoms()
-         */
-        void setOnlyAtoms(bool bEnabled);
-        /*! \brief
-         * Sets whether this option accepts dynamic selections.
-         *
-         * \param[in] bEnabled  If true, the option accepts only static
-         *      selections.
-         * \throws    std::bad_alloc if out of memory.
-         * \throws    InvalidInputError if dynamic selections have already been
-         *      provided.
-         *
-         * Strong exception safety guarantee.
-         *
-         * \see SelectionOption::onlyStatic()
-         */
-        void setOnlyStatic(bool bEnabled);
-        /*! \brief
-         * Sets whether this option uses position masks for dynamic selections.
-         *
-         * \param[in] bEnabled  If true, the position masks are used.
-         *
-         * Does not throw.
-         *
-         * \see SelectionOption::dynamicMask()
-         */
-        void setDynamicMask(bool bEnabled);
-        /*! \brief
-         * Sets whether atom coordinates are allowed as reference positions.
-         *
-         * \param[in] bEnabled  If true, the option does not accept atom
-         *      coordinates as reference positions.
-         *
-         * TODO: This is not yet implemented.
-         *
-         * \see SelectionOption::dynamicOnlyWhole()
-         */
-        void setDynamicOnlyWhole(bool bEnabled);
-
-    private:
-        SelectionOptionStorage &option();
-        const SelectionOptionStorage &option() const;
-};
-
-/*! \brief
- * Set manager for all selection options.
- *
- * Recursively sets the manager to \p manager for all selection options in
- * \p options.
- * Must be called before value assignment starts for \p options.
- *
- * Does not throw.
- *
- * \inpublicapi
- */
-void setManagerForSelectionOptions(Options *options,
-                                   SelectionOptionManager *manager);
-
-} // namespace gmx
-
-#endif
index df78579a946a3e020d617847b6a5767d3f5add9e..49059000cfb71b5ec5b50ebd5300fb590347e7ee 100644 (file)
 
 #include <cstdio>
 
+#include "gromacs/options/optionsvisitor.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectioncollection.h"
+#include "gromacs/selection/selectionoption.h"
+#include "gromacs/selection/selectionfileoption.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/stringutil.h"
 
@@ -339,4 +342,60 @@ SelectionOptionManager::parseRequestedFromString(const std::string &str)
     impl_->placeSelectionsInRequests(selections);
 }
 
+/********************************************************************
+ * Global functions
+ */
+
+namespace
+{
+
+/*! \internal \brief
+ * Visitor that sets the manager for each selection option.
+ *
+ * \ingroup module_selection
+ */
+class SelectionOptionManagerSetter : public OptionsModifyingVisitor
+{
+    public:
+        //! Construct a visitor that sets given manager.
+        explicit SelectionOptionManagerSetter(SelectionOptionManager *manager)
+            : manager_(manager)
+        {
+        }
+
+        void visitSubSection(Options *section)
+        {
+            OptionsModifyingIterator iterator(section);
+            iterator.acceptSubSections(this);
+            iterator.acceptOptions(this);
+        }
+
+        void visitOption(OptionInfo *option)
+        {
+            SelectionOptionInfo *selOption
+                = option->toType<SelectionOptionInfo>();
+            if (selOption != NULL)
+            {
+                selOption->setManager(manager_);
+            }
+            SelectionFileOptionInfo *selFileOption
+                = option->toType<SelectionFileOptionInfo>();
+            if (selFileOption != NULL)
+            {
+                selFileOption->setManager(manager_);
+            }
+        }
+
+    private:
+        SelectionOptionManager *manager_;
+};
+
+} // namespace
+
+void setManagerForSelectionOptions(Options *options,
+                                   SelectionOptionManager *manager)
+{
+    SelectionOptionManagerSetter(manager).visitSubSection(options);
+}
+
 } // namespace gmx
index d09f799d8a18eea4560f1753d461a68b9eb0a2ed..9c984419374a92892ed09fd9ed68014cfe38e551 100644 (file)
@@ -46,6 +46,7 @@
 namespace gmx
 {
 
+class Options;
 class SelectionCollection;
 class SelectionOptionStorage;
 
@@ -201,6 +202,20 @@ class SelectionOptionManager
         friend class SelectionOptionStorage;
 };
 
+/*! \brief
+ * Set manager for all selection options.
+ *
+ * Recursively sets the manager to \p manager for all selection options in
+ * \p options.
+ * Must be called before value assignment starts for \p options.
+ *
+ * Does not throw.
+ *
+ * \inpublicapi
+ */
+void setManagerForSelectionOptions(Options *options,
+                                   SelectionOptionManager *manager);
+
 } // namespace gmx
 
 #endif
index e2a692a09d054a4f1d30ea78178448a5c0bca763..3fac92060ea6d453d7cdece496113283c74e354d 100644 (file)
@@ -41,7 +41,7 @@
 #include "../options/optionstoragetemplate.h"
 #include "selection.h"
 #include "selectionenums.h"
-#include "selectionoptioninfo.h"
+#include "selectionoption.h"
 
 namespace gmx
 {
index 6795041bb86b10c79caf77dea5695fc53f6ca111..3deb155dd6a49a0c77087b39987f906848dbe27f 100644 (file)
@@ -43,7 +43,6 @@
 #include "gromacs/selection/selectioncollection.h"
 #include "gromacs/selection/selectionfileoption.h"
 #include "gromacs/selection/selectionoption.h"
-#include "gromacs/selection/selectionoptioninfo.h"
 #include "gromacs/selection/selectionoptionmanager.h"
 #include "gromacs/utility/exceptions.h"
 
index ac6eb98df8abb4391a36b30bf8517e7195f5920d..bc68302588718395109239c90af70bf16d235f19 100644 (file)
@@ -50,7 +50,6 @@
 #include "gromacs/onlinehelp/helpwritercontext.h"
 #include "gromacs/options/options.h"
 #include "gromacs/selection/selectioncollection.h"
-#include "gromacs/selection/selectionoptioninfo.h"
 #include "gromacs/selection/selectionoptionmanager.h"
 #include "gromacs/trajectoryanalysis/analysismodule.h"
 #include "gromacs/trajectoryanalysis/analysissettings.h"
index be3ba86723ca09dc67f374769f94ebaaf7a340a2..68bb4b4c1d6ea6863b1037094413fde2a9752015 100644 (file)
@@ -51,7 +51,6 @@
 #include "gromacs/options/options.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/selection/selectionoption.h"
-#include "gromacs/selection/selectionoptioninfo.h"
 #include "gromacs/trajectoryanalysis/analysissettings.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"