More consistent default handling for StringOption
[alexxy/gromacs.git] / src / gromacs / options / basicoptions.h
index bef6e44ccba5bc03992c6f52dff3a1d822c70cfc..67f14e31d9414018c57e06deef57e00da2c586fe 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+ * 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.
@@ -48,7 +48,7 @@
 
 #include <string>
 
-#include "../legacyheaders/types/simple.h"
+#include "../utility/basedefinitions.h"
 #include "../utility/gmxassert.h"
 
 #include "abstractoption.h"
@@ -98,7 +98,8 @@ class BooleanOption : public OptionTemplate<bool, BooleanOption>
 
     private:
         //! Creates a BooleanOptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 };
 
 /*! \brief
@@ -140,7 +141,8 @@ class IntegerOption : public OptionTemplate<int, IntegerOption>
 
     private:
         //! Creates an IntegerOptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
         /*! \brief
          * Needed to initialize IntegerOptionStorage from this class without
@@ -169,7 +171,8 @@ class Int64Option : public OptionTemplate<gmx_int64_t, Int64Option>
 
     private:
         //! Creates an Int64OptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
         /*! \brief
          * Needed to initialize Int64OptionStorage from this class without
@@ -214,7 +217,8 @@ class DoubleOption : public OptionTemplate<double, DoubleOption>
 
     private:
         //! Creates a DoubleOptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
         bool bTime_;
 
@@ -252,7 +256,8 @@ class FloatOption : public OptionTemplate<float, FloatOption>
 
     private:
         //! Creates a FloatOptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
         bool bTime_;
 
@@ -359,7 +364,10 @@ class StringOption : public OptionTemplate<std::string, StringOption>
          * The index (zero-based) of the selected value in the array \p values
          * provided to enumValues() is written into \p *store after the
          * option gets its value.  If the option has not been provided,
-         * and there is no default value, -1 is stored.
+         * and there is no default value, -1 is stored.  If store(),
+         * storeVector() or defaultEnumIndex() is not present, the value in
+         * \p *store is kept as a default value, otherwise it is always
+         * overwritten.
          *
          * Cannot be specified without enumValue().
          *
@@ -372,7 +380,8 @@ class StringOption : public OptionTemplate<std::string, StringOption>
 
     private:
         //! Creates a StringOptionStorage object.
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
         const char *const      *enumValues_;
         int                     enumValuesCount_;
@@ -396,6 +405,12 @@ class BooleanOptionInfo : public OptionInfo
     public:
         //! Creates an option info object for the given option.
         explicit BooleanOptionInfo(BooleanOptionStorage *option);
+
+        //! Returns the default value for this option.
+        bool defaultValue() const;
+
+    private:
+        const BooleanOptionStorage &option() const;
 };
 
 /*! \brief