Gromacs  5.1.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
#include "gmxpre.h"
#include "selmethod.h"
#include <ctype.h>
#include <stdarg.h>
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "symrec.h"
+ Include dependency graph for selmethod.cpp:

Description

Implements functions in selmethod.h.

Author
Teemu Murtola teemu.nosp@m..mur.nosp@m.tola@.nosp@m.gmai.nosp@m.l.com

Classes

struct  t_register_method
 Helper structure for defining selection methods. More...
 

Functions

static void report_error (FILE *fp, const char *name, const char *fmt,...)
 Convenience function for reporting errors found in selection methods.
 
static void report_param_error (FILE *fp, const char *mname, const char *pname, const char *fmt,...)
 Convenience function for reporting errors found in selection method parameters.
 
static bool check_params (FILE *fp, const char *name, int nparams, gmx_ana_selparam_t param[], const gmx::SelectionParserSymbolTable &symtab)
 Checks the validity of parameters. More...
 
static bool check_callbacks (FILE *fp, gmx_ana_selmethod_t *method)
 Checks the validity of selection method callback functions. More...
 
static bool check_method (FILE *fp, gmx_ana_selmethod_t *method, const gmx::SelectionParserSymbolTable &symtab)
 Checks the validity of a selection method. More...
 
static bool check_modifier (FILE *fp, gmx_ana_selmethod_t *method, const gmx::SelectionParserSymbolTable &symtab)
 Checks the validity of a selection modifier method. More...
 
int gmx_ana_selmethod_register (gmx::SelectionParserSymbolTable *symtab, const char *name, gmx_ana_selmethod_t *method)
 Registers a selection method. More...
 
int gmx_ana_selmethod_register_defaults (gmx::SelectionParserSymbolTable *symtab)
 Registers all selection methods in the library. More...
 
gmx_ana_selparam_tgmx_ana_selmethod_find_param (const char *name, gmx_ana_selmethod_t *method)
 Finds a parameter from a selection method by name. More...
 

Variables

gmx_ana_selmethod_t sm_cog
 Selection method data for the cog method. More...
 
gmx_ana_selmethod_t sm_com
 Selection method data for the com method. More...
 
gmx_ana_selmethod_t sm_all
 Selection method data for all selection keyword. More...
 
gmx_ana_selmethod_t sm_none
 Selection method data for none selection keyword. More...
 
gmx_ana_selmethod_t sm_atomnr
 Selection method data for atomnr selection keyword. More...
 
gmx_ana_selmethod_t sm_resnr
 Selection method data for resnr selection keyword. More...
 
gmx_ana_selmethod_t sm_resindex
 Selection method data for resindex selection keyword. More...
 
gmx_ana_selmethod_t sm_molindex
 Selection method data for molindex selection keyword. More...
 
gmx_ana_selmethod_t sm_atomname
 Selection method data for atomname selection keyword. More...
 
gmx_ana_selmethod_t sm_pdbatomname
 Selection method data for pdbatomname selection keyword. More...
 
gmx_ana_selmethod_t sm_atomtype
 Selection method data for atomtype selection keyword. More...
 
gmx_ana_selmethod_t sm_resname
 Selection method data for resname selection keyword. More...
 
gmx_ana_selmethod_t sm_insertcode
 Selection method data for chain selection keyword. More...
 
gmx_ana_selmethod_t sm_chain
 Selection method data for chain selection keyword. More...
 
gmx_ana_selmethod_t sm_mass
 Selection method data for mass selection keyword. More...
 
gmx_ana_selmethod_t sm_charge
 Selection method data for charge selection keyword. More...
 
gmx_ana_selmethod_t sm_altloc
 Selection method data for chain selection keyword. More...
 
gmx_ana_selmethod_t sm_occupancy
 Selection method data for occupancy selection keyword. More...
 
gmx_ana_selmethod_t sm_betafactor
 Selection method data for betafactor selection keyword. More...
 
gmx_ana_selmethod_t sm_x
 Selection method data for x selection keyword. More...
 
gmx_ana_selmethod_t sm_y
 Selection method data for y selection keyword. More...
 
gmx_ana_selmethod_t sm_z
 Selection method data for z selection keyword. More...
 
gmx_ana_selmethod_t sm_distance
 Selection method data for the distance method. More...
 
gmx_ana_selmethod_t sm_mindistance
 Selection method data for the distance method. More...
 
gmx_ana_selmethod_t sm_within
 Selection method data for the within method. More...
 
gmx_ana_selmethod_t sm_insolidangle
 Selection method data for the insolidangle method. More...
 
gmx_ana_selmethod_t sm_same
 Selection method data for the same method. More...
 
gmx_ana_selmethod_t sm_merge
 Selection method data for the plus modifier. More...
 
gmx_ana_selmethod_t sm_plus
 Selection method data for the plus modifier. More...
 
gmx_ana_selmethod_t sm_permute
 Selection method data for the permute modifier. More...
 
static const t_register_method smtable_def []
 Array of selection methods defined in the library. More...
 

Function Documentation

static bool check_callbacks ( FILE *  fp,
gmx_ana_selmethod_t method 
)
static

Checks the validity of selection method callback functions.

Parameters
[in]fpFile handle to use for diagnostic messages (can be NULL).
[in]methodThe method to check.
Returns
true if there are no problems, false otherwise.

This function performs some checks common to both check_method() and check_modifier(). This function checks that all the required callbacks are defined, i.e., not NULL, to find programming errors.

static bool check_method ( FILE *  fp,
gmx_ana_selmethod_t method,
const gmx::SelectionParserSymbolTable symtab 
)
static

Checks the validity of a selection method.

Parameters
[in]fpFile handle to use for diagnostic messages (can be NULL).
[in,out]methodMethod to check.
[in]symtabSymbol table (used for checking overlaps).

Checks the validity of the given selection method data structure that does not have SMETH_MODIFIER set. If you remove a check, please make sure that the selection parser, compiler, and evaluation functions can deal with the method.

static bool check_modifier ( FILE *  fp,
gmx_ana_selmethod_t method,
const gmx::SelectionParserSymbolTable symtab 
)
static

Checks the validity of a selection modifier method.

Parameters
[in]fpFile handle to use for diagnostic messages (can be NULL).
[in,out]methodMethod to check.
[in]symtabSymbol table (used for checking overlaps).

Checks the validity of the given selection method data structure that has SMETH_MODIFIER set. If you remove a check, please make sure that the selection parser, compiler, and evaluation functions can deal with the method.

static bool check_params ( FILE *  fp,
const char *  name,
int  nparams,
gmx_ana_selparam_t  param[],
const gmx::SelectionParserSymbolTable symtab 
)
static

Checks the validity of parameters.

Parameters
[in]fpFile handle to use for diagnostic messages (can be NULL).
[in]nameName of the method (used for error messages).
[in]nparamsNumber of parameters in param.
[in,out]paramParameter array (only the flags field of boolean parameters may be modified).
[in]symtabSymbol table (used for checking overlaps).
Returns
true if there are no problems with the parameters, false otherwise.

This function performs some checks common to both check_method() and check_modifier(). The purpose of these checks is to ensure that the selection parser does not need to check for the validity of the parameters at each turn, and to report programming errors as early as possible. If you remove a check, make sure that the parameter parser can handle the resulting parameters.

gmx_ana_selparam_t* gmx_ana_selmethod_find_param ( const char *  name,
gmx_ana_selmethod_t method 
)

Finds a parameter from a selection method by name.

Parameters
[in]nameName of the parameter to search.
[in]methodMethod to search for the parameter.
Returns
Pointer to the parameter in the method->param array, or NULL if no parameter with name name was found.

This is a simple wrapper for gmx_ana_selparam_find().

int gmx_ana_selmethod_register ( gmx::SelectionParserSymbolTable symtab,
const char *  name,
gmx_ana_selmethod_t method 
)

Registers a selection method.

Parameters
[in,out]symtabSymbol table to register the method to.
[in]nameName under which the method should be registered.
[in]methodMethod to register.
Returns
0 on success, EINVAL if there was something wrong with the method.

name does not need to match the name of the method, and the same method can be registered multiple times under different names. If name equals some previously registered name, an error message is printed and the method is not registered.

The function also performs some sanity checking on the input method, and refuses to register it if there are problems. Some problems only generate warnings. All problems are described to stderr.

int gmx_ana_selmethod_register_defaults ( gmx::SelectionParserSymbolTable symtab)

Registers all selection methods in the library.

Parameters
[in,out]symtabSymbol table to register the methods to.
Returns
0 on success, -1 if any of the default methods could not be registered.

Variable Documentation

Selection method data for all selection keyword.

Selection method data for chain selection keyword.

gmx_ana_selmethod_t sm_atomname

Selection method data for atomname selection keyword.

Selection method data for atomnr selection keyword.

gmx_ana_selmethod_t sm_atomtype

Selection method data for atomtype selection keyword.

gmx_ana_selmethod_t sm_betafactor

Selection method data for betafactor selection keyword.

Selection method data for chain selection keyword.

Selection method data for charge selection keyword.

Selection method data for the cog method.

Selection method data for the com method.

gmx_ana_selmethod_t sm_distance

Selection method data for the distance method.

gmx_ana_selmethod_t sm_insertcode

Selection method data for chain selection keyword.

gmx_ana_selmethod_t sm_insolidangle

Selection method data for the insolidangle method.

Selection method data for mass selection keyword.

Selection method data for the plus modifier.

gmx_ana_selmethod_t sm_mindistance

Selection method data for the distance method.

gmx_ana_selmethod_t sm_molindex

Selection method data for molindex selection keyword.

Selection method data for none selection keyword.

gmx_ana_selmethod_t sm_occupancy

Selection method data for occupancy selection keyword.

gmx_ana_selmethod_t sm_pdbatomname

Selection method data for pdbatomname selection keyword.

gmx_ana_selmethod_t sm_permute

Selection method data for the permute modifier.

Selection method data for the plus modifier.

gmx_ana_selmethod_t sm_resindex

Selection method data for resindex selection keyword.

gmx_ana_selmethod_t sm_resname

Selection method data for resname selection keyword.

Selection method data for resnr selection keyword.

Selection method data for the same method.

Selection method data for the within method.

Selection method data for x selection keyword.

Selection method data for y selection keyword.

Selection method data for z selection keyword.

const t_register_method smtable_def[]
static

Array of selection methods defined in the library.