Debian Codegraph @

lib/database/src/so/fields/SoFieldContainer.c++

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 // This may look like C code, but it is really -*- C++ -*-
38
39 /*
40 * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
41 *
42 _______________________________________________________________________
43 ______________ S I L I C O N G R A P H I C S I N C . ____________
44 |
45 | $Revision: 1.3 $
46 |
47 | Classes:
48 | SoFieldContainer
49 |
50 | Author(s) : Gavin Bell
51 |
52 ______________ S I L I C O N G R A P H I C S I N C . ____________
53 _______________________________________________________________________
54 */
55
56 #include <Inventor/SbDict.h>cxx . . $ `<file>/lib/database/include/Inventor/SbDict.h`/
57 #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/
58 #include <Inventor/SoInput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoInput.h`/
59 #include <Inventor/SoLists.h>cxx . . $ `<file>/lib/database/include/Inventor/SoLists.h`/
60 #include <Inventor/SoOutput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoOutput.h`/
61 #include <Inventor/errors/SoDebugError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoDebugError.h`/
62 #include <Inventor/errors/SoReadError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoReadError.h`/
63 #include <Inventor/fields/SoField.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoField.h`/
64 #include <Inventor/fields/SoFieldContainer.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoFieldContainer.h`/
65 #include <Inventor/fields/SoFieldData.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoFieldData.h`/
66 #include <Inventor/misc/SoNotification.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/SoNotification.h`/
67
68 #include <cstdlib>
69
70 // Syntax for reading/writing type information to files
71 #define OPEN_BRACE_CHARcxx . . $ `lib/database/src/so/fields/SoFieldContainer.c++:71:9`! '['
72 #define CLOSE_BRACE_CHARcxx . . $ `lib/database/src/so/fields/SoFieldContainer.c++:72:9`! ']'
73 #define VALUE_SEPARATOR_CHARcxx . . $ `lib/database/src/so/fields/SoFieldContainer.c++:73:9`! ','
74
75 // This is a list of SbDict instances used duting copy operations to
76 // keep track of instances. It is a list to allow recursive copying.
77 SbPListcxx . . $ SbPList# *SoFieldContainercxx . . $ SoFieldContainer#::copyDictListcxx . . $ SoFieldContainer#copyDictList. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
78
79 // These are used by SoFieldContainer::get() to hold the returned
80 // field string
81 // We rely on the compiler to initialize them to zero for us...
82 char *SoFieldContainercxx . . $ SoFieldContainer#::fieldBufcxx . . $ SoFieldContainer#fieldBuf.;
83 int SoFieldContainercxx . . $ SoFieldContainer#::fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize.;
84
85 SoTypecxx . . $ SoType# SoFieldContainercxx . . $ SoFieldContainer#::classTypeIdcxx . . $ SoFieldContainer#classTypeId.;
86
87 ////////////////////////////////////////////////////////////////////////
88 //
89 // Description:
90 // Set up type info.
91 //
92 // Use: internal
93
94 void
95 SoFieldContainercxx . . $ SoFieldContainer#::initClasscxx . . $ SoFieldContainer#initClass(49f6e7a06ebc5aa8).()
96 //
97 ////////////////////////////////////////////////////////////////////////
98 {
99 classTypeIdcxx . . $ SoFieldContainer#classTypeId. =cxx . . $ SoType#`operator=`(b492e65b06badd05). SoTypecxx . . $ SoType#::createTypecxx . . $ SoType#createType(66a643b20efb0062).(SoBasecxx . . $ SoBase#::getClassTypeIdcxx . . $ SoBase#getClassTypeId(c00c150378d2b968).(),
100 "FieldContainer"cxx . . $ SbName#SbName(78e67776a82c5be1).);
101 }
102
103 ////////////////////////////////////////////////////////////////////////
104 //
105 // Description:
106 // Constructor
107 //
108 // Use: protected
109
110 SoFieldContainercxx . . $ SoFieldContainer#::SoFieldContainercxx . . $ SoFieldContainer#SoFieldContainer(49f6e7a06ebc5aa8).()
111 //
112 ////////////////////////////////////////////////////////////////////////
113 {
114 notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
115 }
116
117 ////////////////////////////////////////////////////////////////////////
118 //
119 // Description:
120 // Destructor
121 //
122 // Use: protected
123
124 SoFieldContainercxx . . $ SoFieldContainer#::~cxx . . $ SoFieldContainer#`~SoFieldContainer`(49f6e7a06ebc5aa8).SoFieldContainercxx . . $ SoFieldContainer#()
125 //
126 ////////////////////////////////////////////////////////////////////////
127 {
128 // Fields must be disconnected when things are deleted. Backwards
129 // connections (feeding into my fields) are handled by the SoField
130 // destructor. Forward connections are handled in SoBase's
131 // destructor (it loops through the auditor list and calls
132 // disconnect for any field to field connections it finds).
133 }
134
135 ////////////////////////////////////////////////////////////////////////
136 //
137 // Description:
138 // Sets all fields to their default values and turns on their
139 // default flags.
140 //
141 // Use: public
142
143 void
144 SoFieldContainercxx . . $ SoFieldContainer#::setToDefaultscxx . . $ SoFieldContainer#setToDefaults(49f6e7a06ebc5aa8).()
145 //
146 ////////////////////////////////////////////////////////////////////////
147 {
148 // Create an instance of the same type - it will have default values
149 SoFieldContainercxx . . $ SoFieldContainer# *def = (SoFieldContainercxx . . $ SoFieldContainer# *) getTypeIdcxx . . $ SoBase#getTypeId(70775439ff16cb15).().createInstancecxx . . $ SoType#createInstance(45a5c5ac6be858a8).();
150 def->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
151
152 const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
153
154 if ((fieldData != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (def != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!))
155 fieldData->overlaycxx . . $ SoFieldData#overlay(e90e6198ca06d54b).(this, def, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!);
156
157 def->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
158 }
159
160 ////////////////////////////////////////////////////////////////////////
161 //
162 // Description:
163 // Returns TRUE if all fields have their default values (even if
164 // the isDefault() flags are not all set).
165 //
166 // Use: public
167
168 SbBoolcxx . . $ SbBool#
169 SoFieldContainercxx . . $ SoFieldContainer#::hasDefaultValuescxx . . $ SoFieldContainer#hasDefaultValues(455f465bc33b4cdf).() const
170 //
171 ////////////////////////////////////////////////////////////////////////
172 {
173 // Create an instance of the same type - it will have default values
174 SoFieldContainercxx . . $ SoFieldContainer# *def = (SoFieldContainercxx . . $ SoFieldContainer# *) getTypeIdcxx . . $ SoBase#getTypeId(70775439ff16cb15).().createInstancecxx . . $ SoType#createInstance(45a5c5ac6be858a8).();
175 def->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
176
177 // Compare with this instance
178 SbBoolcxx . . $ SbBool# sameValues = fieldsAreEqualcxx . . $ SoFieldContainer#fieldsAreEqual(9d2f1d89241ba859).(def);
179
180 // Get rid of default instance
181 def->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
182
183 return sameValues;
184 }
185
186 ////////////////////////////////////////////////////////////////////////
187 //
188 // Description:
189 // Returns TRUE if the field values match those of the passed
190 // instance, which is assumed to be of the same type as this.
191 //
192 // Use: public
193
194 SbBoolcxx . . $ SbBool#
195 SoFieldContainercxx . . $ SoFieldContainer#::fieldsAreEqualcxx . . $ SoFieldContainer#fieldsAreEqual(9d2f1d89241ba859).(const SoFieldContainercxx . . $ SoFieldContainer# *fc) const
196 //
197 ////////////////////////////////////////////////////////////////////////
198 {
199 #ifdef DEBUG
200 if (getTypeId() != fc->getTypeId()) {
201 SoDebugError::post("SoFieldContainer::fieldsAreEqual",
202 "Instances are of different types");
203 return FALSE;
204 }
205 #endif /* DEBUG */
206
207 // Compare fields in field data
208 return getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).()->isSamecxx . . $ SoFieldData#isSame(bc4590f7e5e2748c).(this, fc);
209 }
210
211 ////////////////////////////////////////////////////////////////////////
212 //
213 // Description:
214 // Copies field values from the passed instance, which is assumed
215 // to be of the same type as this. If the copyConnections flag is
216 // TRUE (it is FALSE by default), any connections to (but not from)
217 // fields of the instance are copied, as well.
218 //
219 // Use: public
220
221 void
222 SoFieldContainercxx . . $ SoFieldContainer#::copyFieldValuescxx . . $ SoFieldContainer#copyFieldValues(502fcadd2953076).(const SoFieldContainercxx . . $ SoFieldContainer# *fc,
223 SbBoolcxx . . $ SbBool# copyConnections)
224 //
225 ////////////////////////////////////////////////////////////////////////
226 {
227 #ifdef DEBUG
228 if (getTypeId() != fc->getTypeId()) {
229 SoDebugError::post("SoFieldContainer::copyFieldValues",
230 "Instances are of different types");
231 return;
232 }
233 #endif /* DEBUG */
234
235 // Copy fields in field data instances
236 const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
237 if (fieldData != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
238 fieldData->overlaycxx . . $ SoFieldData#overlay(e90e6198ca06d54b).(this, fc, copyConnections);
239 }
240
241 ////////////////////////////////////////////////////////////////////////
242 //
243 // Description:
244 // Sets fields in object from info in passed string. The format of
245 // the string is the same as the ASCII file format, i.e., the stuff
246 // that could appear between the '{' and '}' for the object in a file.
247 //
248 // The SoInput parameter is NULL in the public method and may be
249 // non-NULL in the internal one. If it is non-NULL, it specifies
250 // the SoInput from which to get the reference dictionary to use
251 // when reading from the string.
252 //
253 // Use: public/internal
254
255 SbBoolcxx . . $ SbBool#
256 SoFieldContainercxx . . $ SoFieldContainer#::setcxx . . $ SoFieldContainer#set(8109c297733af0bf).(const char *fieldDataString, SoInputcxx . . $ SoInput# *dictIn)
257 //
258 ////////////////////////////////////////////////////////////////////////
259 {
260 const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
261
262 if (fieldData != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
263 SoInputcxx . . $ SoInput# incxx . . $ SoInput#SoInput(b9bab9f733f78a27).(dictIn);
264 in.setBuffercxx . . $ SoInput#setBuffer(5500c4293b1bbef0).((void *) fieldDataString, strlen(fieldDataString));
265 SbBoolcxx . . $ SbBool# isBuiltIn; // Not used
266 return fieldData->readcxx . . $ SoFieldData#read(cc8228a617223129).(&in, this, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!, isBuiltIn);
267 }
268 else
269 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
270 }
271
272 ////////////////////////////////////////////////////////////////////////
273 //
274 // Description:
275 // Does opposite of "set()" - stores data from fields in passed
276 // SbString. The format of the string is the same as the ASCII file
277 // format, i.e., the stuff that could appear between the '{' and
278 // '}' for the object in a file.
279 //
280 // The SoOutput parameter is NULL in the public method and may be
281 // non-NULL in the internal one. If it is non-NULL, it specifies
282 // the SoOutput from which to get the reference dictionary to use
283 // when writing into the string.
284 //
285 // Use: public/internal
286
287 void
288 SoFieldContainercxx . . $ SoFieldContainer#::getcxx . . $ SoFieldContainer#get(d525908879ef079a).(SbStringcxx . . $ SbString# &fieldDataString, SoOutputcxx . . $ SoOutput# *dictOut)
289 //
290 ////////////////////////////////////////////////////////////////////////
291 {
292 const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
293
294 #ifdef DEBUG
295 if (fieldData == NULL) {
296 SoDebugError::post("SoFieldContainer::get",
297 "Field data is NULL!");
298 return;
299 }
300 #endif
301
302 SoOutputcxx . . $ SoOutput# outcxx . . $ SoOutput#SoOutput(46d85c4d426f339d).(dictOut);
303
304 // Prepare a character buffer and SoOutput for writing field strings
305 if (fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize. == 0) {
306 fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize. = 1028;
307 fieldBufcxx . . $ SoFieldContainer#fieldBuf. = (char *) malloc((unsigned) fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize.);
308 }
309
310 // Set up output into a string buffer
311 out.setBuffercxx . . $ SoOutput#setBuffer(61c86ae95e149a18).((void *) fieldBufcxx . . $ SoFieldContainer#fieldBuf., fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize.,
312 &SoFieldContainercxx . . $ SoFieldContainer#::reallocFieldBufcxx . . $ SoFieldContainer#reallocFieldBuf(417ab160f6baadc6).);
313
314 // Make sure that the file header and lots of white space will NOT
315 // be written into the string
316 out.setCompactcxx . . $ SoOutput#setCompact(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
317
318 // Prepare to begin writing by incrementing the
319 // current write counter in SoBase
320 SoBasecxx . . $ SoBase#::incrementCurrentWriteCountercxx . . $ SoBase#incrementCurrentWriteCounter(49f6e7a06ebc5aa8).();
321
322 // Count references first
323 out.setStagecxx . . $ SoOutput#setStage(1e2aade6511d3df6).(SoOutputcxx . . $ SoOutput#::COUNT_REFScxx . . $ SoOutput#COUNT_REFS.);
324 getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).()->writecxx . . $ SoFieldData#write(3c9bfc134c31f96e).(&out, this);
325
326 // Next, do actual writing
327 out.setStagecxx . . $ SoOutput#setStage(1e2aade6511d3df6).(SoOutputcxx . . $ SoOutput#::WRITEcxx . . $ SoOutput#WRITE.);
328 getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).()->writecxx . . $ SoFieldData#write(3c9bfc134c31f96e).(&out, this);
329
330 // Make sure the string is terminated
331 out.resetcxx . . $ SoOutput#reset(49f6e7a06ebc5aa8).();
332
333 // Store the result in the passed SbString
334 fieldDataString =cxx . . $ SbString#`operator=`(90e156a883234106). fieldBufcxx . . $ SoFieldContainer#fieldBuf.;
335 }
336
337 ////////////////////////////////////////////////////////////////////////
338 //
339 // Description:
340 // Reads stuff into instance of subclass of SoFieldContainer.
341 // Returns FALSE on error.
342 //
343 // Use: protected
344
345 SbBoolcxx . . $ SbBool#
346 SoFieldContainercxx . . $ SoFieldContainer#::readInstancecxx . . $ SoFieldContainer#readInstance(9e4ba99a4b4184f8).(SoInputcxx . . $ SoInput# *in,
347 unsigned short /* flags not used */)
348 //
349 ////////////////////////////////////////////////////////////////////////
350 {
351 SbBoolcxx . . $ SbBool# notBuiltIn; // Not used
352 return getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).()->readcxx . . $ SoFieldData#read(cc8228a617223129).(in, this, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, notBuiltIn);
353 }
354
355 ////////////////////////////////////////////////////////////////////////
356 //
357 // Description:
358 // Adds a reference to the instance when writing. isFromField
359 // indicates whether the reference is from a field-to-field
360 // connection.
361 //
362 // Use: internal, virtual
363
364 void
365 SoFieldContainercxx . . $ SoFieldContainer#::addWriteReferencecxx . . $ SoFieldContainer#addWriteReference(ef4b98cc8eef533a).(SoOutputcxx . . $ SoOutput# *out, SbBoolcxx . . $ SbBool# isFromField)
366 //
367 ////////////////////////////////////////////////////////////////////////
368 {
369 // Do standard stuff
370 SoBasecxx . . $ SoBase#::addWriteReferencecxx . . $ SoBase#addWriteReference(ef4b98cc8eef533a).(out, isFromField);
371
372 // If this is the first reference to this instance and we are not
373 // being referenced from a field-to-field connection, give fields
374 // a chance to do their thing
375 if (! isFromField && ! hasMultipleWriteRefscxx . . $ SoBase#hasMultipleWriteRefs(455f465bc33b4cdf).()) {
376 SoFieldDatacxx . . $ SoFieldData# *fieldData = (SoFieldDatacxx . . $ SoFieldData# *) getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
377
378 // Since the SoOutput is in the COUNT_REFS stage, this call to
379 // write() will just take care of counting references
380 if (fieldData != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
381 fieldData->writecxx . . $ SoFieldData#write(3c9bfc134c31f96e).(out, this);
382 }
383 }
384
385 ////////////////////////////////////////////////////////////////////////
386 //
387 // Description:
388 // Writes instance to SoOutput.
389 //
390 // Use: internal
391
392 void
393 SoFieldContainercxx . . $ SoFieldContainer#::writeInstancecxx . . $ SoFieldContainer#writeInstance(46d85c4d426f339d).(SoOutputcxx . . $ SoOutput# *out)
394 //
395 ////////////////////////////////////////////////////////////////////////
396 {
397 if (! writeHeadercxx . . $ SoBase#writeHeader(9b3bdbd0ec77c6f4).(out, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!)) {
398
399 getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).()->writecxx . . $ SoFieldData#write(3c9bfc134c31f96e).(out, this);
400
401 writeFootercxx . . $ SoBase#writeFooter(58762e0f79576b7c).(out);
402 }
403 }
404
405 ////////////////////////////////////////////////////////////////////////
406 //
407 // Description:
408 // Default method returns a NULL SoFieldData structure for the object.
409 //
410 // Use: internal
411
412 const SoFieldDatacxx . . $ SoFieldData# *
413 SoFieldContainercxx . . $ SoFieldContainer#::getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).() const
414 //
415 ////////////////////////////////////////////////////////////////////////
416 {
417 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
418 }
419
420 ////////////////////////////////////////////////////////////////////////
421 //
422 // Description:
423 // This is a callback function passed to SoOutput::setBuffer() by
424 // SoFieldContainer::get(). It is used to reallocate the buffer in which the
425 // returned field info string is stored. Since we need to keep
426 // track of the pointer to the buffer and its size, we can't just
427 // call realloc() instead.
428 //
429 // Use: private, static
430
431 void *
432 SoFieldContainercxx . . $ SoFieldContainer#::reallocFieldBufcxx . . $ SoFieldContainer#reallocFieldBuf(417ab160f6baadc6).(void *ptr, size_t newSize)
433 //
434 ////////////////////////////////////////////////////////////////////////
435 {
436 fieldBufcxx . . $ SoFieldContainer#fieldBuf. = (char *) realloc(ptr, newSize);
437 fieldBufSizecxx . . $ SoFieldContainer#fieldBufSize. = newSize;
438
439 return fieldBufcxx . . $ SoFieldContainer#fieldBuf.;
440 }
441
442 ////////////////////////////////////////////////////////////////////////
443 //
444 // Description:
445 // Return a list of my fields.
446 //
447 // Use: public
448
449 int
450 SoFieldContainercxx . . $ SoFieldContainer#::getFieldscxx . . $ SoFieldContainer#getFields(517625c0f7c00408).(SoFieldListcxx . . $ SoFieldList# &list) const
451 //
452 ////////////////////////////////////////////////////////////////////////
453 {
454 int i;
455 const SoFieldDatacxx . . $ SoFieldData# *fd = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
456
457 if (fd == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
458 return 0;
459
460 for (i = 0; i < fd->getNumFieldscxx . . $ SoFieldData#getNumFields(455f465bc33b4cdf).(); i++) {
461 list.appendcxx . . $ SoFieldList#append(6a35cc9f7090653f).(fd->getFieldcxx . . $ SoFieldData#getField(f4cd4e797bb371f6).(this, i));
462 }
463
464 return fd->getNumFieldscxx . . $ SoFieldData#getNumFields(455f465bc33b4cdf).();
465 }
466
467 ////////////////////////////////////////////////////////////////////////
468 //
469 // Description:
470 // Returns a pointer to the field with the given name. If no such
471 // field exists, NULL is returned.
472 //
473 // Use: public
474
475 SoFieldcxx . . $ SoField# *
476 SoFieldContainercxx . . $ SoFieldContainer#::getFieldcxx . . $ SoFieldContainer#getField(c5cb3b179879bcd).(const SbNamecxx . . $ SbName# &fieldName) const
477 //
478 ////////////////////////////////////////////////////////////////////////
479 {
480 int i;
481 const SoFieldDatacxx . . $ SoFieldData# *fd = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
482
483 if (fd == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
484 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
485
486 // Search fields for one with given name
487 for (i = 0; i < fd->getNumFieldscxx . . $ SoFieldData#getNumFields(455f465bc33b4cdf).(); i++)
488 if (fd->getFieldNamecxx . . $ SoFieldData#getFieldName(e603ed4d11f0a676).(i) ==cxx . . $ `operator==`(edde533be586f7a2). fieldName)
489 return fd->getFieldcxx . . $ SoFieldData#getField(f4cd4e797bb371f6).(this, i);
490
491 // Not found...
492 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
493 }
494
495 ////////////////////////////////////////////////////////////////////////
496 //
497 // Description:
498 // Returns (in fieldName) the name of the field pointed to. Returns
499 // FALSE if the field is not contained within the field container
500 // instance.
501 //
502 // Use: public
503
504 SbBoolcxx . . $ SbBool#
505 SoFieldContainercxx . . $ SoFieldContainer#::getFieldNamecxx . . $ SoFieldContainer#getFieldName(de53f3b873e9d1c7).(const SoFieldcxx . . $ SoField# *field, SbNamecxx . . $ SbName# &fieldName) const
506 //
507 ////////////////////////////////////////////////////////////////////////
508 {
509 int i;
510 const SoFieldDatacxx . . $ SoFieldData# *fd = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
511
512 if (fd == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
513 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
514
515 // Search fields for one with given pointer
516 for (i = 0; i < fd->getNumFieldscxx . . $ SoFieldData#getNumFields(455f465bc33b4cdf).(); i++) {
517 if (fd->getFieldcxx . . $ SoFieldData#getField(f4cd4e797bb371f6).(this, i) == field) {
518 fieldName =cxx . . $ SbName#`operator=`(8da52b6fc1e0f7c6). fd->getFieldNamecxx . . $ SoFieldData#getFieldName(e603ed4d11f0a676).(i);
519 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
520 }
521 }
522
523 // Not found...
524 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
525 }
526
527 ////////////////////////////////////////////////////////////////////////
528 //
529 // Description:
530 // Propagates notification.
531 //
532 // Use: internal
533
534 void
535 SoFieldContainercxx . . $ SoFieldContainer#::notifycxx . . $ SoFieldContainer#notify(f43de791d8d2eb5a).(SoNotListcxx . . $ SoNotList# *list)
536 //
537 ////////////////////////////////////////////////////////////////////////
538 {
539 #ifdef DEBUG
540 if (list == NULL) {
541 SoDebugError::post("SoFieldContainer::notify",
542 "Notification list pointer is NULL");
543 return;
544 }
545 #endif /* DEBUG */
546
547 // Don't notify if application has disabled notification for some reason
548 if (! isNotifyEnabledcxx . . $ SoFieldContainer#isNotifyEnabled(455f465bc33b4cdf).())
549 return;
550
551 // There are only 2 types of notification possible here: CONTAINER
552 // (a field notifying its container), or PARENT (a node notifying
553 // its parent). The other types are handled by the other classes.
554
555 switch (list->getLastReccxx . . $ SoNotList#getLastRec(a39986cdb7d7aef6).()->getTypecxx . . $ SoNotRec#getType(30fb18e4d3ac32aa).()) {
556 case SoNotReccxx . . $ SoNotRec#::CONTAINERcxx . . $ SoNotRec#CONTAINER.:
557 // We don't need to create a new record, since the last
558 // record's base is already set to this. Just notify all
559 // auditors.
560 SoBasecxx . . $ SoBase#::notifycxx . . $ SoBase#notify(f43de791d8d2eb5a).(list);
561 break;
562
563 case SoNotReccxx . . $ SoNotRec#::PARENTcxx . . $ SoNotRec#PARENT.:
564 // If we're notifying from a child node to a parent node,
565 // create a new record that contains the parent node as a
566 // base, then notify.
567 {
568 SoNotReccxx . . $ SoNotRec# reccxx . . $ SoNotRec#SoNotRec(2ca869ab50d3357c).(this);
569 list->appendcxx . . $ SoNotList#append(81b2425b64ed1ff7).(&rec);
570 SoBasecxx . . $ SoBase#::notifycxx . . $ SoBase#notify(f43de791d8d2eb5a).(list);
571 }
572 break;
573
574 default:
575 #ifdef DEBUG
576 SoDebugError::post("SoFieldContainer::notify (internal)",
577 "Got notification of type %d",
578 list->getLastRec()->getType());
579 #endif /* DEBUG */
580 break;
581 }
582 }
583
584 ////////////////////////////////////////////////////////////////////////
585 //
586 // Description:
587 // Initializes the copy dictionary. Returns FALSE if the dictionary
588 // already exists (probably indicating a recursive copy is taking
589 // place).
590 //
591 // Use: internal, static
592
593 void
594 SoFieldContainercxx . . $ SoFieldContainer#::initCopyDictcxx . . $ SoFieldContainer#initCopyDict(49f6e7a06ebc5aa8).()
595 //
596 ////////////////////////////////////////////////////////////////////////
597 {
598 if (copyDictListcxx . . $ SoFieldContainer#copyDictList. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
599 copyDictListcxx . . $ SoFieldContainer#copyDictList. = new SbPListcxx . . $ SbPList#;
600
601 SbDictcxx . . $ SbDict# *copyDict = new SbDictcxx . . $ SbDict#SbDict(d4f767463ce0a6b3).;
602
603 // Insert the new dictionary at the beginning. Since most copies
604 // are non-recursive, having to make room in the list won't happen
605 // too frequently. Accessing the list happens a lot, so using slot
606 // 0 will speed that up some.
607 copyDictListcxx . . $ SoFieldContainer#copyDictList.->insertcxx . . $ SbPList#insert(d0320739773070f2).(copyDict, 0);
608 }
609
610 ////////////////////////////////////////////////////////////////////////
611 //
612 // Description:
613 // Adds an entry to the copy dictionary.
614 //
615 // Use: internal, static
616
617 void
618 SoFieldContainercxx . . $ SoFieldContainer#::addCopycxx . . $ SoFieldContainer#addCopy(4708885bf4a3e61e).(const SoFieldContainercxx . . $ SoFieldContainer# *orig,
619 const SoFieldContainercxx . . $ SoFieldContainer# *copy)
620 //
621 ////////////////////////////////////////////////////////////////////////
622 {
623 SbDictcxx . . $ SbDict# *copyDict = (SbDictcxx . . $ SbDict# *) (*copyDictListcxx . . $ SoFieldContainer#copyDictList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).0];
624
625 // Add a reference when entering an instance into the
626 // dictionary. The references are removed before the dictionary is
627 // deleted.
628 copy->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
629
630 // ??? HACK ALERT: We use the notifyEnabled flag in the copy to
631 // indicate whether its contents have been copied yet. If the flag
632 // is FALSE, the copy has not yet been done. It's pretty safe to do
633 // this because the notifyEnabled flag is not copied between
634 // instances. When copyContents() is called for the first time on
635 // a copied instance, we reset the flag to TRUE.
636 ((SoFieldContainercxx . . $ SoFieldContainer# *) copy)->notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
637
638 copyDict->entercxx . . $ SbDict#enter(9b3d2d56e494888).((unsigned long) orig, (void *) copy);
639 }
640
641 ////////////////////////////////////////////////////////////////////////
642 //
643 // Description:
644 // If a copy of the given instance is in the dictionary, this
645 // returns it. Otherwise, it returns NULL. The copy is not changed
646 // in any way.
647 //
648 // Use: internal, static
649
650 SoFieldContainercxx . . $ SoFieldContainer# *
651 SoFieldContainercxx . . $ SoFieldContainer#::checkCopycxx . . $ SoFieldContainer#checkCopy(39a6da8fb59a7efc).(const SoFieldContainercxx . . $ SoFieldContainer# *orig)
652 //
653 ////////////////////////////////////////////////////////////////////////
654 {
655 SbDictcxx . . $ SbDict# *copyDict = (SbDictcxx . . $ SbDict# *) (*copyDictListcxx . . $ SoFieldContainer#copyDictList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).0];
656
657 void *copyPtr;
658 if (! copyDict->findcxx . . $ SbDict#find(a750591cf51bff5e).((unsigned long) orig, copyPtr))
659 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
660
661 return (SoFieldContainercxx . . $ SoFieldContainer# *) copyPtr;
662 }
663
664 ////////////////////////////////////////////////////////////////////////
665 //
666 // Description:
667 // If a copy of the given instance is not in the dictionary, this
668 // returns NULL. Otherwise, this copies the contents of the
669 // original into the copy (if not already done) and returns a
670 // pointer to the copy.
671 //
672 // Use: internal, static
673
674 SoFieldContainercxx . . $ SoFieldContainer# *
675 SoFieldContainercxx . . $ SoFieldContainer#::findCopycxx . . $ SoFieldContainer#findCopy(764c84fe9fa40e97).(const SoFieldContainercxx . . $ SoFieldContainer# *orig,
676 SbBoolcxx . . $ SbBool# copyConnections)
677 //
678 ////////////////////////////////////////////////////////////////////////
679 {
680 if (! copyDictListcxx . . $ SoFieldContainer#copyDictList. || ! (*copyDictListcxx . . $ SoFieldContainer#copyDictList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).0])
681 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
682
683 SbDictcxx . . $ SbDict# *copyDict = (SbDictcxx . . $ SbDict# *) (*copyDictListcxx . . $ SoFieldContainer#copyDictList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).0];
684
685 void *copyPtr;
686 if (! copyDict->findcxx . . $ SbDict#find(a750591cf51bff5e).((unsigned long) orig, copyPtr))
687 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
688
689 SoFieldContainercxx . . $ SoFieldContainer# *copyFC = (SoFieldContainercxx . . $ SoFieldContainer# *) copyPtr;
690
691 // ??? Copy the contents only if the notifyEnabled flag is FALSE,
692 // indicating that the copy has not yet been done. See the HACK
693 // ALERT above.
694 if (! copyFC->notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled.) {
695 copyFC->notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
696 copyFC->copyContentscxx . . $ SoFieldContainer#copyContents(502fcadd2953076).(orig, copyConnections);
697 }
698
699 return copyFC;
700 }
701
702 ////////////////////////////////////////////////////////////////////////
703 //
704 // Description:
705 // Cleans up the copy dictionary.
706 //
707 // Use: internal, static
708
709 void
710 SoFieldContainercxx . . $ SoFieldContainer#::copyDonecxx . . $ SoFieldContainer#copyDone(49f6e7a06ebc5aa8).()
711 //
712 ////////////////////////////////////////////////////////////////////////
713 {
714 #ifdef DEBUG
715 if (copyDictList->getLength() <= 0) {
716 SoDebugError::post("SoFieldContainer::copyDone",
717 "No dictionary left to get rid of");
718 return;
719 }
720 #endif /* DEBUG */
721
722 SbDictcxx . . $ SbDict# *copyDict = (SbDictcxx . . $ SbDict# *) (*copyDictListcxx . . $ SoFieldContainer#copyDictList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).0];
723
724 // Unref every instance in the copy dictionary
725 copyDict->applyToAllcxx . . $ SbDict#applyToAll(8677e4c43d34b2b5).(unrefCopycxx . . $ SoFieldContainer#unrefCopy(3bdecba87b0fe3d5).);
726
727 delete copyDict;
728
729 copyDictListcxx . . $ SoFieldContainer#copyDictList.->removecxx . . $ SbPList#remove(d4f767463ce0a6b3).(0);
730 }
731
732 ////////////////////////////////////////////////////////////////////////
733 //
734 // Description:
735 // This callback is used to unref() all instances in the
736 // copyDict when copyDone() is called.
737 //
738 // Use: private, static
739
740 void
741 SoFieldContainercxx . . $ SoFieldContainer#::unrefCopycxx . . $ SoFieldContainer#unrefCopy(3bdecba87b0fe3d5).(unsigned long, void *instPtr)
742 //
743 ////////////////////////////////////////////////////////////////////////
744 {
745 SoFieldContainercxx . . $ SoFieldContainer# *inst = (SoFieldContainercxx . . $ SoFieldContainer# *) instPtr;
746
747 // Set the notifyEnabled bit to TRUE if it wasn't already done
748 if (! inst->notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled.)
749 inst->notifyEnabledcxx . . $ SoFieldContainer#notifyEnabled. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
750
751 inst->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
752 }
753
754 ////////////////////////////////////////////////////////////////////////
755 //
756 // Description:
757 // Copies the contents of the given node into this instance. The
758 // default implementation copies just field values and the name.
759 //
760 // Use: internal, virtual
761
762 void
763 SoFieldContainercxx . . $ SoFieldContainer#::copyContentscxx . . $ SoFieldContainer#copyContents(502fcadd2953076).(const SoFieldContainercxx . . $ SoFieldContainer# *fromFC,
764 SbBoolcxx . . $ SbBool# copyConnections)
765 //
766 ////////////////////////////////////////////////////////////////////////
767 {
768 // Access the field data and overlay it
769 const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoFieldContainer#getFieldData(56e90abbfb485471).();
770 if (fieldData != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
771 fieldData->overlaycxx . . $ SoFieldData#overlay(e90e6198ca06d54b).(this, fromFC, copyConnections);
772
773 // Copy the name, if it has one
774 const SbNamecxx . . $ SbName# &name = fromFC->getNamecxx . . $ SoBase#getName(a4a84af177c3b6e7).();
775 if (! !cxx . . $ SbName#`operator!`(455f465bc33b4cdf). name)
776 setNamecxx . . $ SoBase#setName(78e67776a82c5be1).(name);
777 }
778
779 ////////////////////////////////////////////////////////////////////////
780 //
781 // Description:
782 // During a copy operation, this copies an instance that is
783 // encountered through a field connection. The default
784 // implementation just returns the original pointer - no copy is
785 // done. Subclasses such as nodes and engines handle this
786 // differently.
787 //
788 // Use: internal, virtual
789
790 SoFieldContainercxx . . $ SoFieldContainer# *
791 SoFieldContainercxx . . $ SoFieldContainer#::copyThroughConnectioncxx . . $ SoFieldContainer#copyThroughConnection(5859c5f6d4d84439).() const
792 //
793 ////////////////////////////////////////////////////////////////////////
794 {
795 return (SoFieldContainercxx . . $ SoFieldContainer# *) this;
796 }