Gromacs  2022.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
gmx::SelectionTreeElement Class Reference

#include <gromacs/selection/selelem.h>

+ Collaboration diagram for gmx::SelectionTreeElement:

Description

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 SelectionLocationlocation () 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_tmempool
 Memory pool to use for values, or NULL if standard memory handling.
 
t_compiler_datacdata
 Internal data for the selection compiler.
 
SelectionTreeElementPointer child
 The first child element. More...
 
SelectionTreeElementPointer next
 The next sibling element.
 

Constructor & Destructor Documentation

gmx::SelectionTreeElement::SelectionTreeElement ( e_selelem_t  type,
const SelectionLocation location 
)

Allocates memory and performs common initialization.

Parameters
[in]typeType of selection element to create.
[in]locationLocation 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.

Member Function Documentation

void gmx::SelectionTreeElement::checkIndexGroup ( int  natoms)

Checks that an index group has valid atom indices.

Parameters
[in]natomsMaximum number of atoms the selections can evaluate to.
Exceptions
std::bad_allocif out of memory.
InconsistentInputErrorif 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.

Parameters
[in]bUnsortedAllowedWhether this element's parents allow it to have unsorted atoms.
errorsObject for reporting any error messages.
Exceptions
std::bad_allocif 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.

Parameters
[in]selectionTextFull selection text to use as a fallback.
Exceptions
std::bad_allocif 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.

Parameters
[in]countNumber 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.

Returns
List of topology properties required 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.

Parameters
[in]grpsIndex groups to use to resolve the reference.
[in]natomsMaximum number of atoms the selections can evaluate to (zero if the topology/atom count is not set yet).
Exceptions
std::bad_allocif out of memory.
InconsistentInputErrorif the reference cannot be resolved.
void gmx::SelectionTreeElement::setName ( const char *  name)
inline

Sets the name of the element.

Parameters
[in]nameName to set (can be NULL).
Exceptions
std::bad_allocif out of memory.
void gmx::SelectionTreeElement::setName ( const std::string &  name)
inline

Sets the name of the element.

Parameters
[in]nameName to set (can be NULL).
Exceptions
std::bad_allocif out of memory.

Member Data Documentation

gmx_ana_index_t gmx::SelectionTreeElement::cgrp

Index group data for several element types.

  • SEL_CONST : if the value type is GROUP_VALUE, this field holds the unprocessed group value.
  • SEL_ROOT : holds the group value for which the selection subtree should be evaluated.
  • SEL_SUBEXPR : holds the group for which the subexpression has been evaluated.
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.


The documentation for this class was generated from the following files: