Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / options / abstractoption.h
index e80ad0200e64a4c7a012e33076142ce79395ba7b..2793f2f0faa3e19a5fd99cc73b6937bbbab2a5da 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
 #include <string>
 #include <vector>
 
-#include "../utility/common.h"
-#include "../utility/uniqueptr.h"
-
-#include "optionflags.h"
+#include "gromacs/options/optionflags.h"
+#include "gromacs/utility/common.h"
 
 namespace gmx
 {
 
 class AbstractOptionStorage;
 template <typename T> class OptionStorageTemplate;
+class OptionManagerContainer;
 class Options;
 
-//! Smart pointer for managing an AbstractOptionStorage object.
-typedef gmx_unique_ptr<AbstractOptionStorage>::type
-    AbstractOptionStoragePointer;
-
 /*! \brief
  * Abstract base class for specifying option properties.
  *
@@ -108,8 +103,10 @@ class AbstractOption
         /*! \brief
          * Creates a default storage object for the option.
          *
-         * \returns The created storage object.
-         * \throws  APIError if invalid option settings have been provided.
+         * \param[in] managers  Manager container (unused if the option does
+         *     not use a manager).
+         * \returns   The created storage object.
+         * \throws    APIError if invalid option settings have been provided.
          *
          * This method is called by Options::addOption() when initializing an
          * option from the settings.
@@ -119,8 +116,16 @@ class AbstractOption
          * They should also throw APIError if they detect problems.
          *
          * Should only be called by Options::addOption().
+         *
+         * The ownership of the return value is passed, but is not using a
+         * smart pointer to avoid introducing such a dependency in an installed
+         * header.  The implementation will always consist of a single `new`
+         * call and returning that value, and the caller always immediately
+         * wraps the pointer in a smart pointer, so there is not exception
+         * safety issue.
          */
-        virtual AbstractOptionStoragePointer createStorage() const = 0;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const = 0;
 
         //! Sets the description for the option.
         void setDescription(const char *descr) { descr_ = descr; }
@@ -248,7 +253,8 @@ class OptionTemplate : public AbstractOption
         //! Requires exactly \p count values for the option.
         MyClass &valueCount(int count) { setValueCount(count); return me(); }
         //! Allows any number of values for the option.
-        MyClass &multiValue() { maxValueCount_ = -1; return me(); }
+        MyClass &multiValue(bool bMulti = true)
+        { if (bMulti) { maxValueCount_ = -1; } return me(); }
 
         /*! \brief
          * Sets a default value for the option.
@@ -441,16 +447,16 @@ class OptionInfo
         bool isHidden() const;
         //! Returns true if the option is required.
         bool isRequired() const;
+        //! Returns the minimum number of values that this option accepts.
+        int minValueCount() const;
+        //! Returns the maximum number of values that this option accepts.
+        int maxValueCount() 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;
+        std::string type() const;
+        //! Returns the description of the option.
+        std::string formatDescription() const;
         /*! \brief
          * Returns the default value if set for the option as a string.
          *
@@ -458,6 +464,11 @@ class OptionInfo
          */
         std::string formatDefaultValueIfSet() 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;
+
     protected:
         /*! \cond libapi */
         /*! \brief