Apply clang-format to source tree
[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,2015,2019, 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 _gmx_selelem_print_compare_info(FILE* fp, void* data);
66
67 /*! \brief
68  * Returns whether the selection element is a default position keyword.
69  *
70  * \param[in] sel   Selection element to query.
71  * \returns   ``true`` if ``sel`` represents a position keyword evaluation that
72  *     uses the default (implicit) position keyword.
73  *
74  * This method only works before the selection has been compiled.
75  */
76 bool _gmx_selelem_is_default_kwpos(const gmx::SelectionTreeElement& sel);
77 /** Sets the position type for position keyword evaluation. */
78 void _gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement* sel, const char* type);
79 /** Sets the flags for position keyword evaluation. */
80 void _gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement* sel, int flags);
81
82 /** Sets the string match type for string keyword evaluation. */
83 void _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer& sel,
84                                        gmx::SelectionStringMatchType           matchType);
85
86 /** Does custom processing for parameters of the \c same selection method. */
87 void _gmx_selelem_custom_init_same(struct gmx_ana_selmethod_t**                    method,
88                                    const gmx::SelectionParserParameterListPointer& params,
89                                    void*                                           scanner);
90
91 /*! \brief
92  * Initializes a selection element for evaluating a keyword in a given group.
93  *
94  * \param[in]   method  Keyword selection method to evaluate.
95  * \param[in]   child   The group/positions to evaluate \p method in.
96  * \param[in]   scanner Scanner data structure.
97  * \returns     Pointer to the created selection element.
98  *
99  * Creates a \ref SEL_EXPRESSION selection element that evaluates the keyword
100  * method given by \p method in the group/positions given by \p child.
101  *
102  * \p child should be a selection tree that evaluates to \ref GROUP_VALUE or
103  * \ref POS_VALUE.
104  */
105 gmx::SelectionTreeElementPointer _gmx_sel_init_keyword_evaluator(struct gmx_ana_selmethod_t* method,
106                                                                  const gmx::SelectionTreeElementPointer& child,
107                                                                  void* scanner);
108
109 #endif