Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
#include "gmxpre.h"
#include "selmethod.h"
#include <cctype>
#include <cstdarg>
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/stringutil.h"
#include "selmethod_impl.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...
 

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, -1 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.