Gromacs
2022.2
|
#include <gromacs/selection/selelem.h>
Represents an element of a selection expression.
Public Member Functions | |
SelectionTreeElement (e_selelem_t type, const SelectionLocation &location) | |
Allocates memory and performs common initialization. More... | |
void | freeValues () |
Frees the memory allocated for the v union. | |
void | freeExpressionData () |
Frees the memory allocated for the u union. | |
void | freeCompilerData () |
Frees the memory allocated for the selection compiler. More... | |
void | mempoolReserve (int count) |
Reserves memory for value from a memory pool. More... | |
void | mempoolRelease () |
Releases memory pool used for value. More... | |
const std::string & | name () const |
Returns the name of the element. | |
const SelectionLocation & | location () const |
Returns the location of the element. | |
void | setName (const char *name) |
Sets the name of the element. More... | |
void | setName (const std::string &name) |
Sets the name of the element. More... | |
void | fillNameIfMissing (const char *selectionText) |
Sets the name of a root element if it is missing. More... | |
SelectionTopologyProperties | requiredTopologyProperties () const |
Returns which topology properties the selection element subtree requires for evaluation. More... | |
void | checkUnsortedAtoms (bool bUnsortedAllowed, ExceptionInitializer *errors) const |
Checks that this element and its children do not contain unsupported elements with unsorted atoms. More... | |
bool | requiresIndexGroups () const |
Checks whether the element or its children have unresolved index group references. More... | |
void | resolveIndexGroupReference (gmx_ana_indexgrps_t *grps, int natoms) |
Resolves an unresolved reference to an index group. More... | |
void | checkIndexGroup (int natoms) |
Checks that an index group has valid atom indices. More... | |
Public Attributes | |
e_selelem_t | type |
Type of the element. | |
gmx_ana_selvalue_t | v |
Value storage of the element. More... | |
sel_evalfunc | evaluate |
Evaluation function for the element. More... | |
int | flags |
Information flags about the element. More... | |
union { | |
gmx_ana_index_t cgrp | |
Index group data for several element types. More... | |
struct { | |
struct gmx_ana_selmethod_t * method | |
Pointer the method used in this expression. | |
void * mdata | |
Pointer to the data allocated by the method's init_data (see sel_datafunc()). | |
struct gmx_ana_pos_t * pos | |
Pointer to the position data passed to the method. | |
struct gmx_ana_poscalc_t * pc | |
Pointer to the evaluation data for pos . | |
} expr | |
Data for SEL_EXPRESSION and SEL_MODIFIER elements. | |
e_boolean_t boolt | |
Operation type for SEL_BOOLEAN elements. | |
struct { | |
e_arithmetic_t type | |
Operation type. | |
char * opstr | |
String representation. | |
} arith | |
Operation type for SEL_ARITHMETIC elements. | |
struct gmx_ana_selparam_t * param | |
Associated selection parameter for SEL_SUBEXPRREF elements. | |
struct { | |
char * name | |
Name of the referenced external group. | |
int id | |
If name is NULL, the index number of the referenced group. | |
} gref | |
The string/number used to reference the group. | |
} | u |
Data required by the evaluation function. | |
struct gmx_sel_mempool_t * | mempool |
Memory pool to use for values, or NULL if standard memory handling. | |
t_compiler_data * | cdata |
Internal data for the selection compiler. | |
SelectionTreeElementPointer | child |
The first child element. More... | |
SelectionTreeElementPointer | next |
The next sibling element. | |
gmx::SelectionTreeElement::SelectionTreeElement | ( | e_selelem_t | type, |
const SelectionLocation & | location | ||
) |
Allocates memory and performs common initialization.
[in] | type | Type of selection element to create. |
[in] | location | Location of the element. |
type is set to type
, v::type is set to GROUP_VALUE for boolean and comparison expressions and NO_VALUE for others, and SEL_ALLOCVAL is set for non-root elements (SEL_ALLOCDATA is also set for SEL_BOOLEAN elements). All the pointers are set to NULL.
void gmx::SelectionTreeElement::checkIndexGroup | ( | int | natoms | ) |
Checks that an index group has valid atom indices.
[in] | natoms | Maximum number of atoms the selections can evaluate to. |
std::bad_alloc | if out of memory. |
InconsistentInputError | if there are invalid atom indices. |
void gmx::SelectionTreeElement::checkUnsortedAtoms | ( | bool | bUnsortedAllowed, |
ExceptionInitializer * | errors | ||
) | const |
Checks that this element and its children do not contain unsupported elements with unsorted atoms.
[in] | bUnsortedAllowed | Whether this element's parents allow it to have unsorted atoms. |
errors | Object for reporting any error messages. |
std::bad_alloc | if out of memory. |
Errors are reported as nested exceptions in errors
.
void gmx::SelectionTreeElement::fillNameIfMissing | ( | const char * | selectionText | ) |
Sets the name of a root element if it is missing.
[in] | selectionText | Full selection text to use as a fallback. |
std::bad_alloc | if out of memory. |
If index groups have not yet been set and the selection is a result of a group reference, the name may still be empty after this call.
Strong exception safety guarantee.
void gmx::SelectionTreeElement::freeCompilerData | ( | ) |
Frees the memory allocated for the selection compiler.
This function only frees the data for the given selection, not its children. It is safe to call the function when compiler data has not been allocated or has already been freed; in such a case, nothing is done.
void gmx::SelectionTreeElement::mempoolRelease | ( | ) |
Releases memory pool used for value.
Releases the memory allocated for the values of this element from the mempool memory pool. If no memory pool is set, nothing is done.
void gmx::SelectionTreeElement::mempoolReserve | ( | int | count | ) |
Reserves memory for value from a memory pool.
[in] | count | Number of values to reserve memory for. |
Reserves memory for the values of this element from the mempool memory pool. If no memory pool is set, nothing is done.
SelectionTopologyProperties gmx::SelectionTreeElement::requiredTopologyProperties | ( | ) | const |
Returns which topology properties the selection element subtree requires for evaluation.
bool gmx::SelectionTreeElement::requiresIndexGroups | ( | ) | const |
Checks whether the element or its children have unresolved index group references.
Does not throw.
void gmx::SelectionTreeElement::resolveIndexGroupReference | ( | gmx_ana_indexgrps_t * | grps, |
int | natoms | ||
) |
Resolves an unresolved reference to an index group.
[in] | grps | Index groups to use to resolve the reference. |
[in] | natoms | Maximum number of atoms the selections can evaluate to (zero if the topology/atom count is not set yet). |
std::bad_alloc | if out of memory. |
InconsistentInputError | if the reference cannot be resolved. |
|
inline |
Sets the name of the element.
[in] | name | Name to set (can be NULL). |
std::bad_alloc | if out of memory. |
|
inline |
Sets the name of the element.
[in] | name | Name to set (can be NULL). |
std::bad_alloc | if out of memory. |
gmx_ana_index_t gmx::SelectionTreeElement::cgrp |
Index group data for several element types.
SelectionTreeElementPointer gmx::SelectionTreeElement::child |
The first child element.
Other children can be accessed through the next
field of child
.
sel_evalfunc gmx::SelectionTreeElement::evaluate |
Evaluation function for the element.
Can be either NULL (if the expression is a constant and does not require evaluation) or point to one of the functions defined in evaluate.h.
int gmx::SelectionTreeElement::flags |
Information flags about the element.
Allowed flags are listed here: flags for gmx::SelectionTreeElement.
gmx_ana_selvalue_t gmx::SelectionTreeElement::v |
Value storage of the element.
This field contains the evaluated value of the element, as well as the output value type.