#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"
#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"
#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"
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}
#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"
*/
/*! \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"
#include <string>
#include <vector>
+#include "../utility/common.h"
#include "../utility/uniqueptr.h"
#include "optionflags.h"
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
+++ /dev/null
-/*
- *
- * 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
*/
/*! \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
{
*/
/*! \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
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
#include <vector>
#include "basicoptions.h"
-#include "basicoptioninfo.h"
#include "optionstoragetemplate.h"
namespace gmx
*/
/*! \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
{
*/
/*! \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
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
+++ /dev/null
-/*
- *
- * 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
#include <string>
#include "filenameoption.h"
-#include "filenameoptioninfo.h"
#include "optionfiletype.h"
#include "optionstoragetemplate.h"
+++ /dev/null
-/*
- *
- * 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
#include "../utility/common.h"
#include "../utility/gmxassert.h"
-#include "optioninfo.h"
+#include "abstractoption.h"
namespace gmx
{
#include "../utility/common.h"
-#include "optioninfo.h"
+#include "abstractoption.h"
namespace gmx
{
#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"
*/
#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"
#include "selection/selection.h"
#include "selection/selectioncollection.h"
#include "selection/selectionoption.h"
-#include "selection/selectionoptioninfo.h"
#include "selection/selectionoptionmanager.h"
#endif
selectioncollection.h
selectionenums.h
selectionoption.h
- selectionoptioninfo.h
selectionoptionmanager.h)
install(FILES ${SELECTION_PUBLIC_HEADERS}
DESTINATION ${INCL_INSTALL_DIR}/gromacs/selection
*/
/*! \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.
*
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);
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
+++ /dev/null
-/*
- *
- * 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
#define GMX_SELECTION_SELECTIONFILEOPTIONSTORAGE_H
#include "../options/abstractoptionstorage.h"
-#include "selectionfileoptioninfo.h"
+#include "selectionfileoption.h"
namespace gmx
{
* \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
{
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
*/
/*! \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
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
+++ /dev/null
-/*
- *
- * 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
#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"
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
namespace gmx
{
+class Options;
class SelectionCollection;
class SelectionOptionStorage;
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
#include "../options/optionstoragetemplate.h"
#include "selection.h"
#include "selectionenums.h"
-#include "selectionoptioninfo.h"
+#include "selectionoption.h"
namespace gmx
{
#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"
#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"
#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"