eb503a7e7e9d4350fc817b200e758a9445edd8c8
[alexxy/gromacs.git] / src / gromacs / selection / keywords.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2009,2010,2012,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \internal \file
36  * \brief Definitions of generic keyword evaluation structures.
37  *
38  * This is an implementation header: there should be no need to use it outside
39  * this directory.
40  *
41  * \author Teemu Murtola <teemu.murtola@gmail.com>
42  * \ingroup module_selection
43  */
44 #ifndef GMX_SELECTION_KEYWORDS_H
45 #define GMX_SELECTION_KEYWORDS_H
46
47 #include "parsetree.h"
48 #include "selelem.h"
49
50 struct gmx_ana_selmethod_t;
51
52 /** Selection method data for comparison expression evaluation. */
53 extern struct gmx_ana_selmethod_t sm_compare;
54
55 /** Selection method data for integer keyword evaluation. */
56 extern struct gmx_ana_selmethod_t sm_keyword_int;
57 /** Selection method data for real keyword evaluation. */
58 extern struct gmx_ana_selmethod_t sm_keyword_real;
59 /** Selection method data for string keyword evaluation. */
60 extern struct gmx_ana_selmethod_t sm_keyword_str;
61 /** Selection method data for position keyword evaluation. */
62 extern struct gmx_ana_selmethod_t sm_keyword_pos;
63
64 /** Prints information about a comparison expression. */
65 void
66 _gmx_selelem_print_compare_info(FILE *fp, void *data);
67
68 /** Sets the position type for position keyword evaluation. */
69 void
70 _gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type);
71 /** Sets the flags for position keyword evaluation. */
72 void
73 _gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement *sel, int flags);
74
75 /** Sets the string match type for string keyword evaluation. */
76 void
77 _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
78                                   gmx::SelectionStringMatchType           matchType);
79
80 /** Does custom processing for parameters of the \c same selection method. */
81 void
82 _gmx_selelem_custom_init_same(struct gmx_ana_selmethod_t                    **method,
83                               const gmx::SelectionParserParameterListPointer &params,
84                               void                                           *scanner);
85
86 /*! \brief
87  * Initializes a selection element for evaluating a keyword in a given group.
88  *
89  * \param[in]   method  Keyword selection method to evaluate.
90  * \param[in]   child   The group/positions to evaluate \p method in.
91  * \param[in]   scanner Scanner data structure.
92  * \returns     Pointer to the created selection element.
93  *
94  * Creates a \ref SEL_EXPRESSION selection element that evaluates the keyword
95  * method given by \p method in the group/positions given by \p child.
96  *
97  * \p child should be a selection tree that evaluates to \ref GROUP_VALUE or
98  * \ref POS_VALUE.
99  */
100 gmx::SelectionTreeElementPointer
101 _gmx_sel_init_keyword_evaluator(struct gmx_ana_selmethod_t              *method,
102                                 const gmx::SelectionTreeElementPointer  &child,
103                                 void                                    *scanner);
104
105 #endif