Traj. analysis structure now passes oenv around.
[gromacs/adressmacs.git] / include / selmethod.h
blobf33c144a338090e7f5eeeaea30ebe8ee67fcd2e8
1 /*
3 * This source code is part of
5 * G R O M A C S
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
31 /*! \page selmethods Custom selection methods
33 * Custom selection methods are defined by creating a new instance of
34 * \c gmx_ana_selmethod_t and filling it with the necessary data for handling
35 * the selection.
36 * The structure contains callback pointers that define the actual behavior
37 * of the method.
38 * The following sections discuss how the structure should be filled and how
39 * to implement the callbacks.
42 * \section selmethods_define \c gmx_ana_selmethod_t data structure
44 * An example \c gmx_ana_selmethod_t definition could look like this:
46 * \code
47 * gmx_ana_selmethod_t sm_example = {
48 * "example", GROUP_VALUE, 0,
49 * asize(sm_params_example), sm_params_example,
50 * &init_data_example,
51 * NULL,
52 * &init_example,
53 * NULL,
54 * &free_data_example,
55 * &init_frame_example,
56 * &evaluate_example,
57 * NULL,
58 * };
59 * \endcode
61 * The first value defines the name of the method.
62 * It is used mostly for informational purposes; the actual name(s) recognized
63 * by the selection parser are defined by the call to
64 * gmx_ana_selmethod_register() (see \ref selmethods_register).
66 * The second value defines the type of the value the method returns.
67 * Possible values are
68 * - \ref NO_VALUE : This is allowed only for methods that have the flag
69 * \ref SMETH_MODIFIER set (see \ref selmethods_modifiers).
70 * - \ref INT_VALUE : The method returns one or more integer values.
71 * - \ref REAL_VALUE : The method returns one or more floating-point values.
72 * - \ref STR_VALUE : The method returns one or more strings.
73 * - \ref POS_VALUE : The method returns one or more 3D vectors.
74 * - \ref GROUP_VALUE : The method returns a single index group.
76 * The third value gives additional information about the method using
77 * a combination of flags.
78 * Possible flags are:
79 * - \ref SMETH_REQTOP : If set, the topology information is always loaded
80 * and the \p top pointer passed to the callbacks is guaranteed to be
81 * non-NULL. Should be set if the method requires topology information
82 * for evaluation.
83 * - \ref SMETH_DYNAMIC : If set, the method can only be evaluated dynamically,
84 * i.e., it requires data from the trajectory frame.
85 * - \ref SMETH_MODIFIER : If set, the method is a selection modifier and
86 * not an actual selection method.
87 * For more details, see \ref selmethods_modifiers.
89 * There are two additional flags that specify the number of values the
90 * method returns. Only one of them can be set at a time.
91 * If neither is set, the default behavior is to evaluate a value for each
92 * input atom (except for \ref GROUP_VALUE methods, which always return a
93 * single group).
94 * Other behaviors can be specified with these flags:
95 * - \ref SMETH_SINGLEVAL : If set, the method evaluates to a single value.
96 * This is automatically set if the type is \ref GROUP_VALUE.
97 * - \ref SMETH_VARNUMVAL : If set, the method evaluates to an arbitrary
98 * number of values.
99 * The number of values is determined based on the values given by the user
100 * to the method parameters (see \ref selmethods_params).
102 * Currently, the above flags only work (have been tested) for \ref POS_VALUE
103 * methods.
105 * There is one additional flag that can only be specified for \ref STR_VALUE
106 * methods: \ref SMETH_CHARVAL . It is meant for to ease implementation of
107 * methods that evaluate to strings consisting of single characters.
109 * The next two values determine the number of parameters and a pointer to
110 * the parameter array. The contents of the parameter array are described in
111 * \ref selmethods_params. If the method does not take parameters, the first
112 * value should be 0 and the second can be NULL.
113 * Currently, \ref STR_VALUE methods cannot take parameters, but this limitation
114 * should be easy to lift if required.
116 * The remaining values define the function callbacks that determine the
117 * actual behavior of the method. Any of these except the evaluation callback
118 * can be NULL (the evaluation callback can also be NULL if \ref NO_VALUE is
119 * specified for a selection modifier). However, the presence of parameters
120 * can require some of the callbacks to be implemented.
121 * The details are described in \ref selmethods_callbacks.
123 * The \c gmx_ana_selmethod_t variable should be declared as a global variable
124 * or it should be otherwise ensured that the structure is not freed: only a
125 * pointer to the structure is stored by the library.
128 * \section selmethods_params Defining parameters
130 * Parameters to selection methods are defined in a separate array of
131 * \c gmx_ana_selparam_t structures.
132 * The order of the parameters does not matter (except possibly for callback
133 * implementation), with one important exception:
134 * If the method evaluates to a \ref POS_VALUE, the first parameter should
135 * have \ref GROUP_VALUE and be the one that is used to calculate the
136 * positions.
138 * An example parameter definition:
139 * \code
140 * static gmx_ana_selparam_t sm_params_example[] = {
141 * {"cutoff", {REAL_VALUE, 1, {NULL}}, NULL, SPAR_OPTIONAL},
142 * {"from", {POS_VALUE, -1, {NULL}}, NULL, SPAR_DYNAMIC | SPAR_VARNUM},
143 * };
144 * \endcode
146 * The first value gives the name of the parameter.
147 * The first parameter can have a NULL name, which means that the value should
148 * immediately follow the method name. This can be used to specify methods
149 * of the type 'within 5 of ...'.
151 * The second value specifies the type of the value that the parameter accepts.
152 * \ref NO_VALUE can be used to specify a boolean parameter, other possibilities
153 * are the same as for the selection method type.
155 * The third value gives the number of values that the parameter accepts.
156 * For boolean parameters (\ref NO_VALUE), it should be 0.
157 * For parameters with \ref SPAR_VARNUM of \ref SPAR_ATOMVAL, it should be set
158 * to -1 for consistency (it is not used).
159 * If \ref SPAR_RANGES is specified, it should be either 1 (to accept a single
160 * continuous range) or -1 (if combined with \ref SPAR_VARNUM).
161 * In all other cases, it should be a positive integer; in most cases, it
162 * should be 1.
164 * The nest two pointers should always be NULL (they should be initialized in
165 * the callbacks).
167 * The final value gives additional information about the acceptable values
168 * for the parameter using a combination of flags.
169 * The possible flags are:
170 * - \ref SPAR_OPTIONAL : If set, the user does not need to provide a value
171 * for the parameter. If not set, an error is reported if the parameter
172 * is not specified by the user.
173 * - \ref SPAR_DYNAMIC : If set, the method can handle dynamic values for
174 * the parameter, i.e., the value(s) can be given by an expression that
175 * evaluates to different values for different frames.
176 * - \ref SPAR_RANGES : Can be set only for \ref INT_VALUE parameters,
177 * and cannot be combined with \ref SPAR_DYNAMIC.
178 * If set, the parameter accepts ranges of integer values.
179 * The ranges are automatically sorted and compacted such that a minimum
180 * amount of non-overlapping ranges are given for the method.
181 * - \ref SPAR_VARNUM : If set, the parameter can have a variable number
182 * of values. These can be provided by the user as a list of values, or
183 * using a single \ref SMETH_VARNUMVAL (or a single \ref SMETH_SINGLEVAL)
184 * method.
185 * - \ref SPAR_ATOMVAL : If set, the parameter accepts either a single value
186 * or an expression that evaluates to a value for each input atom.
187 * The single input value is treated as if the same value was returned for
188 * each atom.
189 * Cannot be combined with \ref SPAR_RANGES or \ref SPAR_VARNUM.
192 * \section selmethods_callbacks Implementing callbacks
194 * There are eight differen callback functions that can be implemented for
195 * selection methods: sel_datafunc(), sel_posfunc(), sel_initfunc(),
196 * sel_outinitfunc(), sel_freefunc(), sel_framefunc(), and two update functions.
197 * They are in this order in the \c gmx_ana_selmethod_t data structure.
198 * In general, any of the callbacks can be NULL, but the presence of
199 * parameters or other callbacks imposes some restrictions:
200 * - sel_datafunc() should be provided if the method takes parameters.
201 * - sel_initfunc() and sel_freefunc() should be provided if the method takes
202 * any parameters with the \ref SPAR_VARNUM or \ref SPAR_ATOMVAL flags,
203 * except if those parameters have a \ref POS_VALUE.
204 * - sel_outinitfunc() should be provided for \ref POS_VALUE methods
205 * and \ref SMETH_VARNUMVAL methods.
206 * - sel_freefunc() should be provided if sel_datafunc() and/or
207 * sel_initfunc() allocate any dynamic memory in addition to the data
208 * structure itself.
209 * - sel_framefunc() and sel_updatefunc_pos() only make sense for methods with
210 * \ref SMETH_DYNAMIC set.
211 * - At least one update function should be provided unless the method type is
212 * \ref NO_VALUE.
214 * The documentations for the function pointer types provide more information
215 * about how the callbacks should be implemented.
218 * \section selmethods_modifiers Selection modifiers
220 * Selection modifiers are a special kind of selection methods that can be
221 * appended to the end of a selection. They are specified by adding the
222 * \ref SMETH_MODIFIER flag to the \c gmx_ana_selmethod_t.
223 * They can have two different types:
224 * - \ref POS_VALUE : These modifiers are given the final positions
225 * as an input, and they can make modifications to the selection that are
226 * not possible otherwise (e.g., permute the atoms).
227 * The modifier should implement sel_updatefunc_pos() and also have
228 * one NULL parameter in the beginning of the parameter list that takes
229 * \ref POS_VALUE and is used to give the input positions.
230 * - \ref NO_VALUE : These modifiers do not modify the final selection, but
231 * can be used to implement per-selection options for analysis tools
232 * or to control the default behavior of the selection engine
233 * (currently, such a framework is not implemented, but should be easy to
234 * implement if required).
236 * In addition to restricting the type of the method, selection modifiers
237 * do not allow the flags \ref SMETH_SINGLEVAL and \ref SMETH_VARNUMVAL
238 * (they would not make sense).
240 * Parameters and callbacks should be implemented as with normal selection
241 * method, but beware that very little of the functionality has been tested.
243 * \todo
244 * The modifier handling could be made more flexible and more generic;
245 * the current implementation does not allow many things which would be
246 * possible with slight changes in the internals of the library.
249 * \section selmethods_register Registering the method
251 * After defining the method with \c gmx_ana_selmethod_t, it should be
252 * registered with the selection engine.
253 * In analysis programs, this can be done by calling
254 * gmx_ana_selmethod_register().
255 * If adding the method to the library, you should add a pointer to the new
256 * method structure into the \c smtable_def array (in \ref selmethod.c
257 * "selmethod.c"), and it is registered automatically.
258 * In both cases, gmx_ana_selmethod_register() does several checks on the
259 * structure and reports any errors or inconsistencies it finds.
261 /*! \file
262 * \brief API for handling selection methods.
264 * There should be no need to use the data structures or call the
265 * functions in this file directly unless implementing a custom selection
266 * method.
268 * Instructions for implementing custom selection methods can be found
269 * on a separate page: \ref selmethods
271 #ifndef SELMETHOD_H
272 #define SELMETHOD_H
274 #include <typedefs.h>
276 #include <indexutil.h>
277 #include <selparam.h>
278 #include <selvalue.h>
280 #ifdef __cplusplus
281 extern "C"
283 #endif
285 struct gmx_ana_pos_t;
286 struct gmx_ana_poscalc_coll_t;
287 struct gmx_ana_selcollection_t;
289 /*! \name Selection method flags
290 * \anchor selmethod_flags
292 /*@{*/
293 /*! \brief
294 * If set, the method requires topology information.
296 #define SMETH_REQTOP 1
297 /*! \brief
298 * If set, the method can only be evaluated dynamically.
300 #define SMETH_DYNAMIC 2
301 /*! \brief
302 * If set, the method evaluates to a single value.
304 * The default is that the method evaluates to a value for each input atom.
305 * Cannot be combined with \ref SMETH_VARNUMVAL.
307 #define SMETH_SINGLEVAL 4
308 /*! \brief
309 * If set, the method evaluates to an arbitrary number of values.
311 * The default is that the method evaluates to a value for each input atom.
312 * Cannot be combined with \ref SMETH_SINGLEVAL or with \ref GROUP_VALUE.
314 #define SMETH_VARNUMVAL 8
315 /*! \brief
316 * If set, the method evaluates to single-character strings.
318 * This flag can only be set for \ref STR_VALUE methods. If it is set, the
319 * selection engine automatically allocates and frees the required strings.
320 * The evaluation function should store the character values as the first
321 * character in the strings in the output data structure and should not change
322 * the string pointers.
324 #define SMETH_CHARVAL 64
325 /*! \brief
326 * If set, the method is a selection modifier.
328 * The method type should be \ref GROUP_VALUE or \ref NO_VALUE .
329 * Cannot be combined with \ref SMETH_SINGLEVAL or \ref SMETH_VARNUMVAL .
331 #define SMETH_MODIFIER 256
332 /*@}*/
334 /*! \brief
335 * Allocates and initializes internal data and parameter values.
337 * \param[in] npar Number of parameters in \p param.
338 * \param[in,out] param Pointer to (a copy of) the method's
339 * \c gmx_ana_selmethod_t::param.
340 * \returns Pointer to method-specific data structure.
341 * This pointer will be passed as the last parameter of all other function
342 * calls.
343 * Should return NULL on error (only error that should occur is out of
344 * memory).
346 * Should allocate and initialize any internal data required by the method.
347 * Should also initialize the value pointers (\c gmx_ana_selparam_t::val) in
348 * \p param to point to variables within the internal data structure,
349 * with the exception of parameters that specify the \ref SPAR_VARNUM or
350 * the \ref SPAR_ATOMVAL flag (these should be handled in sel_initfunc()).
351 * However, parameters with a position value should be initialized.
352 * The \c gmx_ana_selparam_t::nvalptr should also be initialized for
353 * non-position-valued parameters that have both \ref SPAR_VARNUM and
354 * \ref SPAR_DYNAMIC set (it can also be initialized for other parameters if
355 * desired, but the same information will be available through other means).
356 * For optional parameters, the default values can (and should) be initialized
357 * here, as the parameter values are not changed if the parameter is not
358 * provided.
360 * For boolean parameters (type equals \ref NO_VALUE), the default value
361 * should be set here. If the parameter is provided by the user, this default
362 * value is negated. The parameter should be named such that this makes
363 * sense.
365 * If the method takes any parameters, this function must be provided.
367 * \todo
368 * More flexible handling of boolean parameters.
370 typedef void *(*sel_datafunc)(int npar, gmx_ana_selparam_t *param);
371 /*! \brief
372 * Sets the position calculation collection for the method.
374 * \param[in] pcc Position calculation collection that the method should use
375 * for position calculations.
376 * \param data Internal data structure from sel_datafunc().
378 * This function should be provided if the method uses the routines from
379 * poscalc.h for calculating positions.
380 * The pointer \p pcc should then be stored and used for initialization for
381 * any position calculation structures.
383 typedef void (*sel_posfunc)(struct gmx_ana_poscalc_coll_t *pcc, void *data);
384 /*! \brief
385 * Does initialization based on topology and/or parameter values.
387 * \param[in] top Topology structure
388 * (can be NULL if \ref SMETH_REQTOP is not set).
389 * \param[in] npar Number of parameters in \p param.
390 * \param[in] param Pointer to (an initialized copy of) the method's
391 * \c gmx_ana_selmethod_t::param.
392 * \param data Internal data structure from sel_datafunc().
393 * \returns 0 on success, a non-zero error code on failure.
395 * This function is called after the parameters have been processed:
396 * the values of the parameters are stored at the locations set in
397 * sel_datafunc().
398 * The flags \ref SPAR_DYNAMIC and \ref SPAR_ATOMVAL are cleared before
399 * calling the function if the value is static or single-valued, respectively.
400 * If a parameter had the \ref SPAR_VARNUM or \ref SPAR_ATOMVAL flag (and
401 * is not \ref POS_VALUE), a pointer to the memory allocated for the values is
402 * found in \c gmx_ana_selparam_t::val.
403 * The pointer should be stored by this function, otherwise the memory
404 * (and the values) are lost.
405 * For \ref SPAR_VARNUM parameters, the number of values can be accessed
406 * through \c gmx_ana_selparam_t::val. For parameters with \ref SPAR_DYNAMIC,
407 * the number is the maximum number of values (the actual number can be
408 * accessed in sel_framefunc() and in the update callback through the value
409 * pointed by \c gmx_ana_selparam_t::nvalptr).
410 * For \ref SPAR_ATOMVAL parameters, \c gmx_ana_selparam_t::val::nr is set to
411 * 1 if a single value was provided, otherwise it is set to the maximum number
412 * of values possibly passed to the method.
413 * The value pointed by \c gmx_ana_selparam_t::nvalptr always contains the same
414 * value as \c gmx_ana_selparam_t::val::nr.
416 * For dynamic \ref GROUP_VALUE parameters (\ref SPAR_DYNAMIC set), the value
417 * will be the largest possible selection that may occur during the
418 * evaluation. For other types of dynamic parameters, the values are
419 * undefined.
421 * If the method takes any parameters with the \ref SPAR_VARNUM or
422 * \ref SPAR_ATOMVAL flags, this function must be provided, except if these
423 * parameters all have \ref POS_VALUE.
425 * This function may be called multiple times for the same method if the
426 * method takes parameters with \ref SPAR_ATOMVAL set.
428 typedef int (*sel_initfunc)(t_topology *top, int npar,
429 gmx_ana_selparam_t *param, void *data);
430 /*! \brief
431 * Initializes output data structure.
433 * \param[in] top Topology structure
434 * (can be NULL if \ref SMETH_REQTOP is not set).
435 * \param[in,out] out Output data structure.
436 * \param[in] data Internal data structure from sel_datafunc().
437 * \returns 0 on success, an error code on error.
439 * This function is called immediately after sel_initfunc().
441 * If the method evaluates to a position (\ref POS_VALUE), this function
442 * should be provided, and it should initialize the \c gmx_ana_pos_t data
443 * structure pointed by \p out.p (the pointer is guaranteed to be non-NULL).
444 * The \p out.p->g pointer should be initialized to the group that is used
445 * to evaluate positions in sel_updatefunc() or sel_updatefunc_pos().
447 * The function should also be provided for non-position-valued
448 * \ref SMETH_VARNUMVAL methods. For these methods, it suffices to set the
449 * \p out->nr field to reflect the maximum number of values returned by the
450 * method.
452 * Currently, this function is not needed for other types of methods.
454 * This function may be called multiple times for the same method if the
455 * method takes parameters with \ref SPAR_ATOMVAL set.
457 typedef int (*sel_outinitfunc)(t_topology *top, gmx_ana_selvalue_t *out,
458 void *data);
459 /*! \brief
460 * Frees the internal data.
462 * \param[in] data Internal data structure from sel_datafunc().
464 * This function should be provided if the internal data structure contains
465 * dynamically allocated data, and should free any such data.
466 * The data structure itself should not be freed; this is handled automatically.
467 * If there is no dynamically allocated data within the structure,
468 * this function is not needed.
469 * The value pointers for \ref SPAR_VARNUM and \ref SPAR_ATOMVAL parameters
470 * stored in sel_initfunc() should also be freed.
472 typedef void (*sel_freefunc)(void *data);
474 /*! \brief
475 * Initializes the evaluation for a new frame.
477 * \param[in] top Topology structure
478 * (can be NULL if \ref SMETH_REQTOP is not set).
479 * \param[in] fr Current frame.
480 * \param[in] pbc Initialized periodic boundary condition structure,
481 * or NULL if PBC should not be used.
482 * \param data Internal data structure from sel_datafunc().
483 * \returns 0 on success, a non-zero error code on failure.
485 * This function should be implemented if the selection method needs to
486 * do some preprocessing for each frame, and the preprocessing does not
487 * depend on the evaluation group.
488 * Because \p sel_updatefunc_* can be called more than once for a frame,
489 * it is inefficient do the preprocessing there.
490 * It is ensured that this function will be called before
491 * \p sel_updatefunc_* for each frame, and that it will be called at most
492 * once for each frame.
494 typedef int (*sel_framefunc)(t_topology *top, t_trxframe *fr, t_pbc *pbc,
495 void *data);
496 /*! \brief
497 * Evaluates a selection method.
499 * \param[in] top Topology structure
500 * (can be NULL if \ref SMETH_REQTOP is not set).
501 * \param[in] fr Current frame.
502 * \param[in] pbc Initialized periodic boundary condition structure,
503 * or NULL if PBC should not be used.
504 * \param[in] g Index group for which the method should be evaluated.
505 * \param[out] out Output data structure.
506 * \param data Internal data structure from sel_datafunc().
507 * \returns 0 on success, a non-zero error code on error.
509 * This function should evaluate the method for each atom included in \p g,
510 * and write the output to \p out. The pointer in the union \p out->u that
511 * corresponds to the type of the method should be used.
512 * Enough memory has been allocated to store the output values.
513 * The number of values in \p out should also be updated if necessary.
514 * However, \ref POS_VALUE or \ref GROUP_VALUE methods should not touch
515 * \p out->nr (it should be 1 anyways).
517 * For \ref STR_VALUE methods, the pointers stored in \p out->s are discarded
518 * without freeing; it is the responsibility of this function to provide
519 * pointers that can be discarded without memory leaks.
521 typedef int (*sel_updatefunc)(t_topology *top, t_trxframe *fr, t_pbc *pbc,
522 gmx_ana_index_t *g, gmx_ana_selvalue_t *out,
523 void *data);
524 /*! \brief
525 * Evaluates a selection method using positions.
527 * \param[in] top Topology structure
528 * (can be NULL if \ref SMETH_REQTOP is not set).
529 * \param[in] fr Current frame.
530 * \param[in] pbc Initialized periodic boundary condition structure,
531 * or NULL if PBC should not be used.
532 * \param[in] pos Positions for which the method should be evaluated.
533 * \param[out] out Output data structure.
534 * \param data Internal data structure from sel_datafunc().
535 * \returns 0 on success, a non-zero error code on error.
537 * This function should evaluate the method for each position in \p g,
538 * and write the output values to \p out. The pointer in the union \p out->u
539 * that corresponds to the type of the method should be used.
540 * Enough memory has been allocated to store the output values.
541 * The number of values in \p out should also be updated if necessary.
542 * However, \ref POS_VALUE or \ref GROUP_VALUE methods should not touch
543 * \p out->nr (it should be 1 anyways).
545 * For \ref STR_VALUE methods, the pointers stored in \p out->s are discarded
546 * without freeing; it is the responsibility of this function to provide
547 * pointers that can be discarded without memory leaks.
549 typedef int (*sel_updatefunc_pos)(t_topology *top, t_trxframe *fr, t_pbc *pbc,
550 struct gmx_ana_pos_t *pos,
551 gmx_ana_selvalue_t *out,
552 void *data);
554 /*! \brief
555 * Describes a selection method.
557 * Any of the function pointers except the update call can be NULL if the
558 * operation is not required or not supported. In this case,
559 * corresponding function calls are skipped.
561 * See the function pointer type documentation for details of how the
562 * functions should be implemented.
563 * More details on implementing new selection methods can be found on a
564 * separate page: \ref selmethods.
566 typedef struct gmx_ana_selmethod_t
568 /*! Name of the method.*/
569 const char *name;
570 /*! Type which the method returns.*/
571 e_selvalue_t type;
572 /*! \brief
573 * Flags to specify how the method should be handled.
575 * See \ref selmethod_flags for allowed values.
577 int flags;
578 /*! Number of parameters the method takes.*/
579 int nparams;
580 /*! Pointer to the array of parameter descriptions.*/
581 gmx_ana_selparam_t *param;
583 /*! Function for allocating and initializing internal data and parameters.*/
584 sel_datafunc init_data;
585 /*! Function to set the position calculation collection.*/
586 sel_posfunc set_poscoll;
587 /*! Function to do initialization based on topology and/or parameter
588 values.*/
589 sel_initfunc init;
590 /*! Function to initialize output data structure.*/
591 sel_outinitfunc outinit;
592 /*! Function to free the internal data.*/
593 sel_freefunc free;
595 /*! Function to initialize the calculation for a new frame.*/
596 sel_framefunc init_frame;
597 /*! Function to evaluate the value.*/
598 sel_updatefunc update;
599 /*! Function to evaluate the value using positions.*/
600 sel_updatefunc_pos pupdate;
601 } gmx_ana_selmethod_t;
603 /*! Registers a selection method.*/
604 extern int
605 gmx_ana_selmethod_register(struct gmx_ana_selcollection_t *sc,
606 const char *name, gmx_ana_selmethod_t *method);
607 /*! Registers all selection methods in the library.*/
608 extern int
609 gmx_ana_selmethod_register_defaults(struct gmx_ana_selcollection_t *sc);
611 /*! Finds a parameter from a selection method by name.*/
612 extern gmx_ana_selparam_t *
613 gmx_ana_selmethod_find_param(const char *name, gmx_ana_selmethod_t *method);
615 #ifdef __cplusplus
617 #endif
619 #endif