Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / selection / selelem.h
index 5971c051bf09ae2de3820a30a6b4b25ea13c920e..ddc429850f7f3e8d7d2a89a33a72afad46d54e37 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012, 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) 2009,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 <boost/shared_ptr.hpp>
 
-#include "gromacs/legacyheaders/types/simple.h"
+#include "gromacs/selection/indexutil.h"
 #include "gromacs/utility/common.h"
+#include "gromacs/utility/real.h"
 
-#include "indexutil.h"
 #include "selvalue.h"
 
 struct gmx_ana_poscalc_t;
@@ -116,12 +116,12 @@ typedef enum
 /** Defines the arithmetic operation of gmx::SelectionTreeElement objects with type \ref SEL_ARITHMETIC. */
 typedef enum
 {
-    ARITH_PLUS,         /**< + */
-    ARITH_MINUS,        /**< - */
-    ARITH_NEG,          /**< Unary - */
-    ARITH_MULT,         /**< * */
-    ARITH_DIV,          /**< / */
-    ARITH_EXP           /**< ^ (to power) */
+    ARITH_PLUS,         /**< Addition (`+`) */
+    ARITH_MINUS,        /**< Subtraction (`-`) */
+    ARITH_NEG,          /**< Unary `-` */
+    ARITH_MULT,         /**< Multiplication (`*`) */
+    ARITH_DIV,          /**< Division (`/`) */
+    ARITH_EXP           /**< Power (`^`) */
 } e_arithmetic_t;
 
 /** Returns a string representation of the type of a gmx::SelectionTreeElement. */
@@ -167,6 +167,10 @@ _gmx_sel_value_type_str(const gmx_ana_selvalue_t *val);
  * The element (or one of its children) is dynamic.
  */
 #define SEL_DYNAMIC     16
+/*! \brief
+ * The element may contain atom indices in an unsorted order.
+ */
+#define SEL_UNSORTED    32
 /*! \brief
  * Mask that covers the flags that describe the number of values.
  */
@@ -233,6 +237,8 @@ _gmx_sel_value_type_str(const gmx_ana_selvalue_t *val);
 namespace gmx
 {
 
+class ExceptionInitializer;
+
 /*! \brief
  * Function pointer for evaluating a gmx::SelectionTreeElement.
  */
@@ -306,6 +312,51 @@ class SelectionTreeElement
         void setName(const char *name) { name_ = (name != NULL ? name : ""); }
         //! \copydoc setName(const char *)
         void setName(const std::string &name) { name_ = name; }
+        /*! \brief
+         * Sets the name of a root element if it is missing.
+         *
+         * \param[in] selectionText  Full selection text to use as a fallback.
+         * \throws    std::bad_alloc if out of memory.
+         *
+         * If index groups have not yet been set and the selection is a result
+         * of a group reference, the name may still be empty after this call.
+         *
+         * Strong exception safety guarantee.
+         */
+        void fillNameIfMissing(const char *selectionText);
+
+        /*! \brief
+         * Checks that this element and its children do not contain unsupported
+         * elements with unsorted atoms.
+         *
+         * \param[in] bUnsortedAllowed Whether this element's parents allow it
+         *     to have unsorted atoms.
+         * \param     errors           Object for reporting any error messages.
+         * \throws    std::bad_alloc if out of memory.
+         *
+         * Errors are reported as nested exceptions in \p errors.
+         */
+        void checkUnsortedAtoms(bool                  bUnsortedAllowed,
+                                ExceptionInitializer *errors) const;
+        /*! \brief
+         * Resolves an unresolved reference to an index group.
+         *
+         * \param[in] grps   Index groups to use to resolve the reference.
+         * \param[in] natoms Maximum number of atoms the selections can evaluate to
+         *     (zero if the topology/atom count is not set yet).
+         * \throws    std::bad_alloc if out of memory.
+         * \throws    InconsistentInputError if the reference cannot be
+         *     resolved.
+         */
+        void resolveIndexGroupReference(gmx_ana_indexgrps_t *grps, int natoms);
+        /*! \brief
+         * Checks that an index group has valid atom indices.
+         *
+         * \param[in] natoms Maximum number of atoms the selections can evaluate to.
+         * \throws    std::bad_alloc if out of memory.
+         * \throws    InconsistentInputError if there are invalid atom indices.
+         */
+        void checkIndexGroup(int natoms);
 
         //! Type of the element.
         e_selelem_t                         type;