Merge branch 'master' of git://git.gromacs.org/gromacs
[gromacs/adressmacs.git] / include / selvalue.h
blob8460fe89a34490ea9f3e9841fef2755bc707d0b9
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 /*! \file
32 * \brief Declaration of \c gmx_ana_selvalue_t.
34 * There should be no need to use the data structures in this file directly
35 * unless implementing a custom selection routine.
37 #ifndef SELVALUE_H
38 #define SELVALUE_H
40 #include "types/simple.h"
42 #ifdef __cplusplus
43 extern "C"
45 #endif
47 /** Defines the value type of a different selection objects. */
48 typedef enum
50 NO_VALUE, /**< No value; either an error condition or an gmx_boolean
51 parameter. */
52 INT_VALUE, /**< One or more integer values. */
53 REAL_VALUE, /**< One or more real values. */
54 STR_VALUE, /**< One or more string values. */
55 POS_VALUE, /**< One or more position values. */
56 GROUP_VALUE /**< One group of atoms. */
57 } e_selvalue_t;
59 /*! \brief
60 * Describes a value of a selection expression or of a selection method
61 * parameter.
63 * Which field in the union is used depends on the \p type.
65 typedef struct gmx_ana_selvalue_t
67 /** Type of the value. */
68 e_selvalue_t type;
69 /*! \brief
70 * Number of values in the array pointed by the union.
72 * Note that for position and group values, it is the number of
73 * data structures in the array, not the number of positions or
74 * the number of atoms in the group.
76 int nr;
77 /** Pointer to the value. */
78 union {
79 /*! \brief
80 * Generic pointer for operations that do not need type information.
82 * Needs to be the first member to be able to use initialized arrays.
84 void *ptr;
85 /** Integer value(s) (type \ref INT_VALUE). */
86 int *i;
87 /** Real value(s) (type \ref REAL_VALUE). */
88 real *r;
89 /** String value(s) (type \ref STR_VALUE). */
90 char **s;
91 /** Structure for the position value(s) (type \ref POS_VALUE). */
92 struct gmx_ana_pos_t *p;
93 /** Group value (type \ref GROUP_VALUE). */
94 struct gmx_ana_index_t *g;
95 /** Boolean value (only parameters of type \ref NO_VALUE); */
96 gmx_bool *b;
97 } u;
98 /*! \brief
99 * Number of elements allocated for the value array.
101 int nalloc;
102 } gmx_ana_selvalue_t;
104 /** Initializes an empty selection value structure. */
105 void
106 _gmx_selvalue_clear(gmx_ana_selvalue_t *val);
107 /** Reserve memory for storing selection values. */
109 _gmx_selvalue_reserve(gmx_ana_selvalue_t *val, int n);
110 /** Sets the memory for storing selection values. */
112 _gmx_selvalue_setstore(gmx_ana_selvalue_t *val, void *ptr);
113 /** Sets the memory for storing selection values and marks it for automatic freeing. */
115 _gmx_selvalue_setstore_alloc(gmx_ana_selvalue_t *val, void *ptr, int nalloc);
117 #ifdef __cplusplus
119 #endif
121 #endif