Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoSFEnum.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_SF_ENUM_
51#define _SO_SF_ENUM_
52
53#include <Inventor/SbString.h>
56
58//
59// SoSFEnum subclass of SoSField. This field holds enumerated types.
60// Each instance of the field must define enumeration mnemonics and
61// character strings. This stores the enumeration values as integers
62// (as allowed by C++).
63//
65
89class SoSFEnum : public SoSField {
90 // Use standard field stuff
92
93 public:
98 void setValue(const SbName &name);
99
104 void getEnums(int &num, int *&vals, SbName *&names);
105
106 private:
107
108 // Sets up value/name correspondances
109 void setEnums(int num, int *vals, SbName *names);
110
111
112 private:
113 static void initClass();
114 static void exitClass();
115
116 // Looks up enum name, returns value. Returns FALSE if not found.
117 virtual SbBool findEnumValue(const SbName &name, int &val);
118
119 private:
120 bool legalValuesSet; // TRUE if setEnums called
121 int numEnums; // Number of enumeration values
122 int *enumValues; // Enumeration values
123 SbName *enumNames; // Mnemonic names of values
124
125 // Looks up enum value, returns ptr to name. Returns FALSE if not found.
126 virtual SbBool findEnumName(int val, const SbName *&name) const;
127
128};
129
130
132//
133// Debugging macros (used by other macros in this file).
134// The container must have a field 'firstInstance'.
135//
136#if defined(_DEBUG)
137#define SO__SF_ENUM_CHECK_DATA(vals, typeName, fieldName, containerMacroName) { \
138 if (vals == NULL && firstInstance) \
139 SoDebugError::post("SO_SET_SF_ENUM_TYPE", \
140 "Field %s (%s, line %d): Did you forget to" \
141 " use SO_%s_DEFINE_ENUM_VALUE(%s, ...)?", \
142 fieldName, __FILE__, __LINE__, \
143 containerMacroName, typeName); \
144}
145#else
146#define SO__SF_ENUM_CHECK_DATA(vals, typeName, fieldName, containerMacroName) {}
147#endif
148
149
151//
152// This defines the specific type of enum expected by a particular
153// SoSFEnum field.
154//
155
156#define SO__SF_ENUM_SET_TYPE(fieldName, enumType, contMacroName, contData) { \
157 int _so_sf_enum_num; \
158 int *_so_sf_enum_vals; \
159 SbName *_so_sf_enum_names; \
160 contData->getEnumData((char *)SO__QUOTE(enumType), \
161 _so_sf_enum_num, \
162 _so_sf_enum_vals, \
163 _so_sf_enum_names); \
164 SO__SF_ENUM_CHECK_DATA(_so_sf_enum_vals, \
165 SO__QUOTE(enumType), \
166 SO__QUOTE(fieldName), \
167 contMacroName); \
168 fieldName.setEnums(_so_sf_enum_num, \
169 _so_sf_enum_vals, \
170 _so_sf_enum_names); \
171}
172
173#define SO_NODE_SET_SF_ENUM_TYPE(fieldName, enumType) \
174 SO__SF_ENUM_SET_TYPE(fieldName,enumType,"NODE",fieldData)
175
176#define SO_ENGINE_SET_SF_ENUM_TYPE(fieldName, enumType) \
177 SO__SF_ENUM_SET_TYPE(fieldName,enumType,"ENGINE",inputData)
178
179//
180// End of macros
181//
183
184
185#endif /* _SO_SF_ENUM_ */
186
#define SO_SFIELD_HEADER(className, valueType, valueRef)
Definition SoSubField.h:280
Character string stored in a hash table.
Definition SbName.h:162
Field containing an enumerated value.
Definition SoSFEnum.h:89
void getEnums(int &num, int *&vals, SbName *&names)
Gets value/name correspondances.
void setValue(const SbName &name)
Sets this field to contain the given mnemonic name, passed in as a name or string.
Abstract base class for all single-value fields.
Definition SoSField.h:93
int SbBool
Boolean type.
Definition SbBase.h:87