Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / selection / selectionoption.h
index 7ade5a97752fb1d68bc267607c0bcef89f2f9704..0af37dddc73c36cb077d3446a9cbdc692321170a 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
 #ifndef GMX_SELECTION_SELECTIONOPTION_H
 #define GMX_SELECTION_SELECTIONOPTION_H
 
-#include "../options/abstractoption.h"
-
-#include "selection.h"
-#include "selectionenums.h"
+#include "gromacs/options/abstractoption.h"
+#include "gromacs/selection/selection.h"
+#include "gromacs/selection/selectionenums.h"
 
 namespace gmx
 {
@@ -60,6 +59,10 @@ class SelectionOptionStorage;
  *
  * Public methods in this class do not throw.
  *
+ * To use options of this type, SelectionOptionManager must first be added to
+ * the Options collection.  For trajectory analysis tools, the framework takes
+ * care of this.
+ *
  * \todo
  * Support for specifying that an option accepts, e.g., two to four selections.
  * Currently, only a fixed count or any number of selections is possible.
@@ -78,7 +81,11 @@ class SelectionOption : public OptionTemplate<Selection, SelectionOption>
         typedef SelectionOptionInfo InfoType;
 
         //! Initializes an option with the given name.
-        explicit SelectionOption(const char *name) : MyBase(name) { }
+        explicit SelectionOption(const char *name)
+            : MyBase(name), defaultText_(""),
+              selectionFlags_(efSelection_DisallowEmpty)
+        {
+        }
 
         /*! \brief
          * Request velocity evaluation for output positions.
@@ -112,6 +119,25 @@ class SelectionOption : public OptionTemplate<Selection, SelectionOption>
          */
         MyClass &dynamicMask()
         { selectionFlags_.set(efSelection_DynamicMask); return me(); }
+        /*! \brief
+         * Allow specifying an unconditionally empty selection for this option.
+         *
+         * If this option is not set, selections that are unconditionally empty
+         * (i.e., can never match any atoms) result in errors.
+         * Note that even without this option, it is still possible that a
+         * dynamic selection evaluates to zero atoms for some frames.
+         */
+        MyClass &allowEmpty()
+        { selectionFlags_.clear(efSelection_DisallowEmpty); return me(); }
+
+        /*! \brief
+         * Sets default selection text for the option.
+         *
+         * If the option is not set by the user, the provided text is parsed as
+         * the value of the selection.
+         */
+        MyClass &defaultSelectionText(const char *text)
+        { defaultText_ = text; return me(); }
 
     private:
         // Disable possibility to allow multiple occurrences, since it isn't
@@ -122,8 +148,10 @@ class SelectionOption : public OptionTemplate<Selection, SelectionOption>
         using MyBase::defaultValue;
         using MyBase::defaultValueIfSet;
 
-        virtual AbstractOptionStoragePointer createStorage() const;
+        virtual AbstractOptionStorage *createStorage(
+            const OptionManagerContainer &managers) const;
 
+        const char             *defaultText_;
         SelectionFlags          selectionFlags_;
 
         /*! \brief
@@ -187,22 +215,6 @@ class SelectionOptionInfo : public OptionInfo
          */
         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.
          *