99c15c71698cc8caacfb5ba1b5ea61d3edc01179
[alexxy/gromacs.git] / src / gmxlib / selection / evaluate.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \internal \file
32  * \brief Evaluation functions for sel_evalfunc().
33  *
34  * This is an implementation header: there should be no need to use it outside
35  * this directory.
36  * Users should only use gmx_ana_selcollection_evaluate() declared in
37  * \ref selection.h to evaluate selections.
38  *
39  * The functions defined in this header file are all the possible values
40  * for the \c t_selelem::evaluate field (in addition to NULL).
41  */
42 #ifndef SELECTION_EVALUATE_H
43 #define SELECTION_EVALUATE_H
44
45 #include <typedefs.h>
46
47 #include <indexutil.h>
48
49 #include "selelem.h"
50
51 struct gmx_sel_mempool_t;
52
53 /*! \internal \brief
54  * Data structure for passing information required during evaluation.
55  */
56 typedef struct gmx_sel_evaluate_t
57 {
58     /** Memory pool for intermediate values. */
59     struct gmx_sel_mempool_t *mp;
60     /** Index group that contains all the atoms. */
61     gmx_ana_index_t         *gall;
62     /** Topology information. */
63     t_topology              *top;
64     /** Current frame. */
65     t_trxframe              *fr;
66     /** PBC data. */
67     t_pbc                   *pbc;
68 } gmx_sel_evaluate_t;
69
70 /*! \name Utility functions
71  */
72 /*@{*/
73 /** Initializes an evaluation data structure. */
74 void
75 _gmx_sel_evaluate_init(gmx_sel_evaluate_t *data,
76                        struct gmx_sel_mempool_t *mp, gmx_ana_index_t *gall,
77                        t_topology *top, t_trxframe *fr, t_pbc *pbc);
78 /** Evaluates the children of a general selection element. */
79 int
80 _gmx_sel_evaluate_children(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
81 /** Evaluates the children of a \ref SEL_EXPRESSION element. */
82 int
83 _gmx_sel_evaluate_method_params(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
84 /*@}*/
85
86 /*! \name Misc. evaluation functions
87  */
88 /*@{*/
89 /** Evaluates a root selection element. */
90 int
91 _gmx_sel_evaluate_root(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
92 /** Evaluates a static group selection element. */
93 int
94 _gmx_sel_evaluate_static(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
95 /** Evaluates an arithmetic expression element. */
96 int
97 _gmx_sel_evaluate_arithmetic(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
98 /*@}*/
99
100 /*! \name Subexpression evaluation functions
101  */
102 /*@{*/
103 /** Evaluates a subexpression when there is only one reference. */
104 int
105 _gmx_sel_evaluate_subexpr_simple(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
106 /** Evaluates a subexpression when the evaluation group is static. */
107 int
108 _gmx_sel_evaluate_subexpr_staticeval(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
109 /** Evaluates a subexpression. */
110 int
111 _gmx_sel_evaluate_subexpr(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
112 /** Evaluates a subexpression reference when there are no other references. */
113 int
114 _gmx_sel_evaluate_subexprref_simple(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
115 /** Evaluates a subexpression reference. */
116 int
117 _gmx_sel_evaluate_subexprref(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
118 /*@}*/
119
120 /*! \name Method evaluation functions
121  */
122 /*@{*/
123
124 /** Evaluates a method expression. */
125 int
126 _gmx_sel_evaluate_method(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
127 /** Evaluates a modifier expression. */
128 int
129 _gmx_sel_evaluate_modifier(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
130 /*@}*/
131
132 /*! \name Boolean evaluation functions
133  */
134 /*@{*/
135 /** Evaluates a boolean NOT element. */
136 int
137 _gmx_sel_evaluate_not(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
138 /** Evaluates a boolean AND element with short-circuiting. */
139 int
140 _gmx_sel_evaluate_and(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
141 /** Evaluates a boolean OR element with short-circuiting. */
142 int
143 _gmx_sel_evaluate_or(gmx_sel_evaluate_t *data, t_selelem *sel, gmx_ana_index_t *g);
144 /*@}*/
145
146 #endif