Gromacs
2020.4
|
#include <memory>
#include <string>
#include "gromacs/selection/indexutil.h"
#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/real.h"
#include "selvalue.h"
Declares gmx::SelectionTreeElement and related things.
The selection element trees constructed by the parser and the compiler are described on the respective pages: Selection parsing and Selection compilation.
This is an implementation header: there should be no need to use it outside this directory.
Classes | |
struct | gmx::SelectionLocation |
Stores the location of a selection element in the selection text. More... | |
class | gmx::SelectionTreeElement |
Represents an element of a selection expression. More... | |
Macros | |
Selection expression flags | |
#define | SEL_FLAGSSET 1 |
Selection value flags are set. More... | |
#define | SEL_SINGLEVAL 2 |
The element evaluates to a single value. More... | |
#define | SEL_ATOMVAL 4 |
The element evaluates to one value for each input atom. | |
#define | SEL_VARNUMVAL 8 |
The element evaluates to an arbitrary number of values. | |
#define | SEL_DYNAMIC 16 |
The element (or one of its children) is dynamic. | |
#define | SEL_UNSORTED 32 |
The element may contain atom indices in an unsorted order. | |
#define | SEL_VALTYPEMASK (SEL_SINGLEVAL | SEL_ATOMVAL | SEL_VARNUMVAL) |
Mask that covers the flags that describe the number of values. | |
#define | SEL_VALFLAGMASK (SEL_FLAGSSET | SEL_VALTYPEMASK | SEL_DYNAMIC) |
Mask that covers the flags that describe the value type. | |
#define | SEL_ALLOCVAL (1 << 8) |
Data has been allocated for the v.u union. More... | |
#define | SEL_ALLOCDATA (1 << 9) |
Data has been allocated for the group/position structure. More... | |
#define | SEL_INITFRAME (1 << 10) |
method->init_frame should be called for the frame. | |
#define | SEL_EVALFRAME (1 << 11) |
Parameter has been evaluated for the current frame. More... | |
#define | SEL_METHODINIT (1 << 12) |
method->init has been called. | |
#define | SEL_OUTINIT (1 << 13) |
method->outinit has been called. More... | |
Typedefs | |
typedef std::shared_ptr < SelectionTreeElement > | gmx::SelectionTreeElementPointer |
Smart pointer type for selection tree element pointers. | |
typedef void(* | gmx::sel_evalfunc )(struct gmx_sel_evaluate_t *data, const SelectionTreeElementPointer &sel, gmx_ana_index_t *g) |
Function pointer for evaluating a gmx::SelectionTreeElement. | |
Functions | |
Selection expression functions | |
void | _gmx_sel_print_evalfunc_name (FILE *fp, gmx::sel_evalfunc evalfunc) |
Writes out a human-readable name for an evaluation function. More... | |
void | _gmx_selelem_set_vtype (const gmx::SelectionTreeElementPointer &sel, e_selvalue_t vtype) |
Sets the value type of a gmx::SelectionTreeElement. More... | |
void | _gmx_selelem_free_param (struct gmx_ana_selparam_t *param) |
Frees the memory allocated for a selection method parameter. More... | |
void | _gmx_selelem_free_method (struct gmx_ana_selmethod_t *method, void *mdata) |
Frees the memory allocated for a selection method. More... | |
void | _gmx_selelem_print_tree (FILE *fp, const gmx::SelectionTreeElement &sel, bool bValues, int level) |
Prints a human-readable version of a selection element subtree. More... | |
void | _gmx_selelem_print_compiler_info (FILE *fp, const gmx::SelectionTreeElement &sel, int level) |
Prints a human-readable version of the internal compiler data structure. More... | |
bool | _gmx_selelem_can_estimate_cover (const gmx::SelectionTreeElement &sel) |
Returns true if the covered fraction of the selection can be calculated. More... | |
real | _gmx_selelem_estimate_coverfrac (const gmx::SelectionTreeElement &sel) |
Returns the covered fraction of the selection for the current frame. More... | |
#define SEL_ALLOCDATA (1 << 9) |
Data has been allocated for the group/position structure.
If not set, the memory allocated for fields in v.u.g
or v.u.p
is managed externally.
This field has no effect if the value type is not GROUP_VALUE or POS_VALUE, but should not be set.
#define SEL_ALLOCVAL (1 << 8) |
Data has been allocated for the v.u
union.
If not set, the v.u.ptr
points to data allocated externally. This is the case if the value of the element is used as a parameter for a selection method or if the element evaluates the final value of a selection.
Even if the flag is set, v.u.ptr
can be NULL during initialization.
v.nalloc
field, and could probably be removed, making memory management simpler. Currently, the v.nalloc
field is not kept up-to-date in all cases when this flag is changed and is used in places where this flag is not, so this would require a careful investigation of the selection code. #define SEL_EVALFRAME (1 << 11) |
Parameter has been evaluated for the current frame.
This flag is set for children of SEL_EXPRESSION elements (which describe method parameters) after the element has been evaluated for the current frame. It is not set for SEL_ATOMVAL elements, because they may need to be evaluated multiple times.
#define SEL_FLAGSSET 1 |
Selection value flags are set.
If this flag is set, the flags covered by SEL_VALFLAGMASK have been set properly for the element.
#define SEL_OUTINIT (1 << 13) |
method->outinit
has been called.
This flag is also used for SEL_SUBEXPRREF elements.
#define SEL_SINGLEVAL 2 |
The element evaluates to a single value.
This flag is always set for GROUP_VALUE elements.
enum e_arithmetic_t |
Defines the arithmetic operation of gmx::SelectionTreeElement objects with type SEL_ARITHMETIC.
Enumerator | |
---|---|
ARITH_PLUS |
Addition ( |
ARITH_MINUS |
Subtraction ( |
ARITH_NEG |
Unary |
ARITH_MULT |
Multiplication ( |
ARITH_DIV |
Division ( |
ARITH_EXP |
Power ( |
enum e_boolean_t |
Defines the boolean operation of gmx::SelectionTreeElement objects with type SEL_BOOLEAN.
Enumerator | |
---|---|
BOOL_NOT |
Not. |
BOOL_AND |
And. |
BOOL_OR |
Or. |
BOOL_XOR |
Xor (not implemented). |
enum e_selelem_t |
Defines the type of a gmx::SelectionTreeElement object.
void _gmx_sel_print_evalfunc_name | ( | FILE * | fp, |
gmx::sel_evalfunc | evalfunc | ||
) |
Writes out a human-readable name for an evaluation function.
[in] | fp | File handle to receive the output. |
[in] | evalfunc | Function pointer to print. |
const char* _gmx_sel_value_type_str | ( | const gmx_ana_selvalue_t * | val | ) |
Returns a string representation of the type of a gmx_ana_selvalue_t
.
[in] | val | Value structore for which the string is requested. |
val->type
, NULL if the type value is invalid.The return value points to a string constant and should not be free'd
.
const char* _gmx_selelem_boolean_type_str | ( | const gmx::SelectionTreeElement & | sel | ) |
Returns a string representation of the boolean type of a SEL_BOOLEAN gmx::SelectionTreeElement.
Returns a string representation of the boolean type of a SEL_BOOLEAN gmx::SelectionTreeElement.
[in] | sel | Selection for which the string is requested |
sel->type
.The return value points to a string constant and should not be free'd
.
The function returns NULL if sel->type
is not one of the valid values.
bool _gmx_selelem_can_estimate_cover | ( | const gmx::SelectionTreeElement & | sel | ) |
Returns true if the covered fraction of the selection can be calculated.
[in] | sel | Selection element to query. |
sel
with _gmx_selelem_estimate_coverfrac(), false otherwise. real _gmx_selelem_estimate_coverfrac | ( | const gmx::SelectionTreeElement & | sel | ) |
Returns the covered fraction of the selection for the current frame.
[in] | sel | Selection for which the fraction should be calculated. |
The return value is undefined if _gmx_selelem_can_estimate_cover() returns false. Should be called after gmx_ana_evaluate_selections() has been called for the frame.
void _gmx_selelem_free_method | ( | struct gmx_ana_selmethod_t * | method, |
void * | mdata | ||
) |
Frees the memory allocated for a selection method.
[in] | method | Method to free. |
[in] | mdata | Method data to free. |
void _gmx_selelem_free_param | ( | struct gmx_ana_selparam_t * | param | ) |
Frees the memory allocated for a selection method parameter.
[in] | param | Parameter to free. |
void _gmx_selelem_print_compiler_info | ( | FILE * | fp, |
const SelectionTreeElement & | sel, | ||
int | level | ||
) |
Prints a human-readable version of the internal compiler data structure.
[in] | fp | File handle to receive the output. |
[in] | sel | Selection element to print. |
[in] | level | Indentation level, starting from zero. |
void _gmx_selelem_print_tree | ( | FILE * | fp, |
const gmx::SelectionTreeElement & | sel, | ||
bool | bValues, | ||
int | level | ||
) |
Prints a human-readable version of a selection element subtree.
[in] | fp | File handle to receive the output. |
[in] | sel | Root of the selection subtree to print. |
[in] | bValues | If true, the evaluated values of selection elements are printed as well. |
[in] | level | Indentation level, starting from zero. |
void _gmx_selelem_set_vtype | ( | const gmx::SelectionTreeElementPointer & | sel, |
e_selvalue_t | vtype | ||
) |
Sets the value type of a gmx::SelectionTreeElement.
[in,out] | sel | Selection element to set the type for. |
[in] | vtype | Value type for the selection element. |
If the new type is GROUP_VALUE or POS_VALUE, the SEL_ALLOCDATA flag is also set.
This function should only be called at most once for each element, preferably right after calling _gmx_selelem_create().
const char* _gmx_selelem_type_str | ( | const gmx::SelectionTreeElement & | sel | ) |
Returns a string representation of the type of a gmx::SelectionTreeElement.
[in] | sel | Selection for which the string is requested |
sel->type
.The return value points to a string constant and should not be free'd
.
The function returns NULL if sel->type
is not one of the valid values.