Debian Codegraph @

src/bin/geomutil/vrml2oogl/lib/QvSFEnum.h

raw
1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21 #ifndef _QV_SF_ENUM_
22 #define _QV_SF_ENUM_
23
24 #include <QvString.h>
25 #include <QvSubField.h>
26
27 class QvSFEnum : public QvSField {
28 public:
29 int value;
30 QV_SFIELD_HEADER(QvSFEnum);
31
32 // Sets up value/name correspondances
33 void setEnums(int num, const int vals[], const QvName names[])
34 { numEnums = num; enumValues = vals; enumNames = names; }
35
36 int numEnums; // Number of enumeration values
37 const int *enumValues; // Enumeration values
38 const QvName *enumNames; // Mnemonic names of values
39
40 // Looks up enum name, returns value. Returns FALSE if not found.
41 QvBool findEnumValue(const QvName &name, int &val) const;
42 };
43
44 #define QV_NODE_SET_SF_ENUM_TYPE(fieldName, enumType) \
45 do { \
46 int _so_sf_enum_num; \
47 const int *_so_sf_enum_vals; \
48 const QvName *_so_sf_enum_names; \
49 fieldData->getEnumData(QV__QUOTE(enumType), \
50 _so_sf_enum_num, \
51 _so_sf_enum_vals, \
52 _so_sf_enum_names); \
53 fieldName.setEnums(_so_sf_enum_num, \
54 _so_sf_enum_vals, \
55 _so_sf_enum_names); \
56 } while (0)
57
58 #endif /* _QV_SF_ENUM_ */