Remove Options::isSet()
[alexxy/gromacs.git] / src / gromacs / options / abstractoption.h
index 563c3621f68dd9a9ea0ce53083def578bbd2a186..47276f214b459a6ee20e595ddbfec4f9fb9fe5dc 100644 (file)
@@ -101,7 +101,7 @@ class AbstractOption
         //! Initializes the name and default values for an option.
         explicit AbstractOption(const char *name)
             : minValueCount_(1), maxValueCount_(1),
-              name_(name), descr_(NULL)
+              name_(name), descr_(NULL), storeIsSet_(NULL)
         { }
 
         /*! \brief
@@ -133,6 +133,8 @@ class AbstractOption
 
         //! Sets the description for the option.
         void setDescription(const char *descr) { descr_ = descr; }
+        //! Sets the storage location for whether the option is set.
+        void setStoreIsSet(bool *store) { storeIsSet_ = store; }
         //! Sets a flag for the option.
         void setFlag(OptionFlag flag) { flags_.set(flag); }
         //! Clears a flag for the option.
@@ -188,6 +190,7 @@ class AbstractOption
         //! Pointer to description of the option.
         const char             *descr_;
         OptionFlags             flags_;
+        bool                   *storeIsSet_;
 
         /*! \brief
          * Needed to initialize an AbstractOptionStorage object from this class
@@ -332,6 +335,21 @@ class OptionTemplate : public AbstractOption
          */
         MyClass &storeVector(std::vector<T> *store)
         { storeVector_ = store; return me(); }
+        /*! \brief
+         * Stores whether the option was explicitly set.
+         *
+         * \param[in] store  Variable to store the flag in.
+         *
+         * The value is set to `false` on creation of the option, and to `true`
+         * as soon as a value is assigned to the option.  A default value does
+         * not set the flag to `true`, but assignment that uses
+         * defaultValueIfSet() does.
+         *
+         * The pointer provided should remain valid as long as the associated
+         * Options object exists.
+         */
+        MyClass &storeIsSet(bool *store)
+        { setStoreIsSet(store); return me(); }
 
     protected:
         /*! \cond libapi */