909c8781473f0d0f1cca0e2dd4a19f7fd8a97b78
[alexxy/gromacs.git] / src / gmxlib / selection / selcollection.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 Definition of \c gmx_ana_selcollection_t.
33  *
34  * This is an implementation header: there should be no need to use it outside
35  * this directory.
36  */
37 #ifndef SELECTION_COLLECTION_H
38 #define SELECTION_COLLECTION_H
39
40 #include <typedefs.h>
41
42 #include <indexutil.h>
43
44 /*! \internal
45  * \brief
46  * Information for a collection of selections.
47  *
48  * The functions to deal with the structure are defined in selection.h.
49  * The structure is allocated with gmx_ana_selcollection_create() and
50  * freed with gmx_ana_selcollection_free().
51  * Some default values must then be set with
52  * gmx_ana_selcollection_set_refpostype() and
53  * gmx_ana_selcollection_set_outpostype().
54  *
55  * After setting the default values, one or more selections can be parsed
56  * with gmx_ana_selcollection_parse_*().
57  * At latest at this point, the topology must be set with
58  * gmx_ana_selcollection_set_topology() unless
59  * gmx_ana_selcollection_requires_top() returns FALSE.
60  * Once all selections are parsed, they must be compiled all at once using
61  * gmx_ana_selcollection_compile().
62  * After these calls, gmx_ana_selcollection_get_count() and 
63  * gmx_ana_selcollection_get_selections() can be used
64  * to get the compiled selections.
65  * gmx_ana_selcollection_evaluate() can be used to update the selections for a
66  * new frame.
67  * gmx_ana_selcollection_evaluate_fin() can be called after all the frames have
68  * been processed to restore the selection values back to the ones they were
69  * after gmx_ana_selcollection_compile(), i.e., dynamic selections have the
70  * maximal index group as their value.
71  *
72  * At any point, gmx_ana_selcollection_requires_top() can be called to see
73  * whether the information provided so far requires loading the topology.
74  * gmx_ana_selcollection_print_tree() can be used to print the internal
75  * representation of the selections (mostly useful for debugging).
76  */
77 struct gmx_ana_selcollection_t
78 {
79     /** Default reference position type for selections. */
80     const char                 *rpost;
81     /** Default output position type for selections. */
82     const char                 *spost;
83     /** TRUE if \ref POS_MASKONLY should be used for output position evaluation. */
84     gmx_bool                        bMaskOnly;
85     /** TRUE if velocities should be evaluated for output positions. */
86     gmx_bool                        bVelocities;
87     /** TRUE if forces should be evaluated for output positions. */
88     gmx_bool                        bForces;
89     /** TRUE if debugging output should be printed during compilation. */
90     gmx_bool                        bDebugCompile;
91
92     /** Root of the selection element tree. */
93     struct t_selelem           *root;
94     /** Number of selections in \p sel. */
95     int                         nr;
96     /** Array of compiled selections. */
97     struct gmx_ana_selection_t **sel;
98     /** Number of variables defined. */
99     int                            nvars;
100     /** Selection strings for variables. */
101     char                         **varstrs;
102
103     /** Topology for the collection. */
104     t_topology                    *top;
105     /** Index group that contains all the atoms. */
106     struct gmx_ana_index_t         gall;
107     /** Position calculation collection used for selection position evaluation. */
108     struct gmx_ana_poscalc_coll_t *pcc;
109     /** Memory pool used for selection evaluation. */
110     struct gmx_sel_mempool_t      *mempool;
111     /** Parser symbol table. */
112     struct gmx_sel_symtab_t     *symtab;
113 };
114
115 /** Clears the symbol table in the collection */
116 void
117 _gmx_selcollection_clear_symtab(struct gmx_ana_selcollection_t *sc);
118
119 #endif