Debian Codegraph @

lib/database/src/so/fields/SoMFPath.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 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.2 $
44 |
45 | Classes:
46 | SoMFPath
47 |
48 | Author(s) : Paul S. Strauss
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/
55 #include <Inventor/SoPath.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPath.h`/
56 #include <Inventor/actions/SoWriteAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoWriteAction.h`/
57 #include <Inventor/fields/SoMFPath.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoMFPath.h`/
58
59 //////////////////////////////////////////////////////////////////////////////
60 //
61 // SoMFPath class - contains pointers to SoPaths. This has to
62 // implement some extra path bookkeeping.
63 //
64 //////////////////////////////////////////////////////////////////////////////
65
66 // Use standard definitions of required methods, but we have to
67 // redefine the rest to keep track of references and auditors.
68
69 SO_MFIELD_REQUIRED_SOURCEcxx . . $ `lib/database/include/Inventor/fields/SoSubField.h:556:9`!(SoMFPath);
70
71 ////////////////////////////////////////////////////////////////////////
72 //
73 // Description:
74 // Constructor (standard stuff)
75 //
76 // Use: public
77
78 SoMFPathcxx . . $ SoMFPath#::SoMFPathcxx . . $ SoMFPath#SoMFPath(49f6e7a06ebc5aa8).()
79 //
80 ////////////////////////////////////////////////////////////////////////
81 {
82 valuescxx . . $ SoMFPath#values. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
83 headscxx . . $ SoMFPath#heads. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
84 }
85
86 ////////////////////////////////////////////////////////////////////////
87 //
88 // Description:
89 // Destructor
90 //
91 // Use: public
92
93 SoMFPathcxx . . $ SoMFPath#::~cxx . . $ SoMFPath#`~SoMFPath`(49f6e7a06ebc5aa8).SoMFPathcxx . . $ SoMFPath#()
94 //
95 ////////////////////////////////////////////////////////////////////////
96 {
97 deleteAllValuescxx . . $ SoMFPath#deleteAllValues(49f6e7a06ebc5aa8).();
98 }
99
100 ////////////////////////////////////////////////////////////////////////
101 //
102 // These all override the definitions in SO_MFIELD_VALUE_SOURCE() to
103 // keep track of references and auditors.
104 //
105 ////////////////////////////////////////////////////////////////////////
106
107 int
108 SoMFPathcxx . . $ SoMFPath#::findcxx . . $ SoMFPath#find(56d7d046453a74ca).(SoPathcxx . . $ SoPath# *targetValue, SbBoolcxx . . $ SbBool# addIfNotFound)
109 {
110 int i, num = getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
111
112 for (i = 0; i < num; i++)
113 if (valuescxx . . $ SoMFPath#values.[i] == targetValue)
114 return i;
115
116 if (addIfNotFound)
117 set1Valuecxx . . $ SoMFPath#set1Value(8aae8380b1580dc1).(num, targetValue);
118
119 return -1;
120 }
121
122 void
123 SoMFPathcxx . . $ SoMFPath#::setValuescxx . . $ SoMFPath#setValues(91dbfb08e0b82872).(int start, int num, const SoPathcxx . . $ SoPath# **newValues)
124 {
125 int newNum = start + num, i;
126
127 if (newNum > getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).())
128 makeRoomcxx . . $ SoMField#makeRoom(d4f767463ce0a6b3).(newNum);
129
130 for (i = 0; i < num; i++)
131 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(start + i, (SoPathcxx . . $ SoPath# *) newValues[i]);
132
133 valueChangedcxx . . $ SoField#valueChanged(d4f767463ce0a6b3).();
134 }
135
136 void
137 SoMFPathcxx . . $ SoMFPath#::set1Valuecxx . . $ SoMFPath#set1Value(8aae8380b1580dc1).(int index, SoPathcxx . . $ SoPath# *newValue)
138 {
139 if (index >= getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).())
140 makeRoomcxx . . $ SoMField#makeRoom(d4f767463ce0a6b3).(index + 1);
141 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(index, newValue);
142 valueChangedcxx . . $ SoField#valueChanged(d4f767463ce0a6b3).();
143 }
144
145 void
146 SoMFPathcxx . . $ SoMFPath#::setValuecxx . . $ SoMFPath#setValue(eed4dbbaf0eca0f1).(SoPathcxx . . $ SoPath# *newValue)
147 {
148 makeRoomcxx . . $ SoMField#makeRoom(d4f767463ce0a6b3).(1);
149 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(0, newValue);
150 valueChangedcxx . . $ SoField#valueChanged(d4f767463ce0a6b3).();
151 }
152
153 int
154 SoMFPathcxx . . $ SoMFPath#::operatorcxx . . $ SoMFPath#`operator==`(6cfb8d9031b5cedc). ==(const SoMFPathcxx . . $ SoMFPath# &f) const
155 {
156 int i, num = getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
157 const SoPathcxx . . $ SoPath# **myVals, **itsVals;
158
159 if (num != f.getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).())
160 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
161
162 myVals = getValuescxx . . $ SoMFPath#getValues(1ffe74a4254d9b23).(0);
163 itsVals = f.getValuescxx . . $ SoMFPath#getValues(1ffe74a4254d9b23).(0);
164
165 for (i = 0; i < num; i++)
166 if (! (myVals[i] == itsVals[i]))
167 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
168
169 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
170 }
171
172 void
173 SoMFPathcxx . . $ SoMFPath#::deleteAllValuescxx . . $ SoMFPath#deleteAllValues(49f6e7a06ebc5aa8).()
174 {
175 allocValuescxx . . $ SoMFPath#allocValues(d4f767463ce0a6b3).(0);
176 }
177
178 void
179 SoMFPathcxx . . $ SoMFPath#::copyValuecxx . . $ SoMFPath#copyValue(3e454b8ccf442868).(int to, int from)
180 {
181 if (to != from)
182 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(to, valuescxx . . $ SoMFPath#values.[from]);
183 }
184
185 ////////////////////////////////////////////////////////////////////////
186 //
187 // This overrides the definition in SO_MFIELD_ALLOC_SOURCE() to
188 // keep track of references and auditors.
189 //
190 ////////////////////////////////////////////////////////////////////////
191
192 void
193 SoMFPathcxx . . $ SoMFPath#::allocValuescxx . . $ SoMFPath#allocValues(d4f767463ce0a6b3).(int newNum)
194 {
195 int i;
196
197 if (valuescxx . . $ SoMFPath#values. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
198 if (newNum > 0) {
199 valuescxx . . $ SoMFPath#values. = new SoPathcxx . . $ SoPath# * [newNum];
200
201 // Make sure all pointers are initialized to NULL
202 for (i = 0; i < newNum; i++)
203 valuescxx . . $ SoMFPath#values.[i] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
204 }
205 }
206 else {
207 SoPathcxx . . $ SoPath# **oldValues = valuescxx . . $ SoMFPath#values.;
208
209 if (newNum > 0) {
210 valuescxx . . $ SoMFPath#values. = new SoPathcxx . . $ SoPath# * [newNum];
211 for (i = 0; i < numcxx . . $ SoMField#num. && i < newNum; i++)
212 valuescxx . . $ SoMFPath#values.[i] = oldValues[i];
213
214 // Initialize unused pointers to NULL
215 for (i = numcxx . . $ SoMField#num.; i < newNum; i++)
216 valuescxx . . $ SoMFPath#values.[i] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
217 }
218 else
219 valuescxx . . $ SoMFPath#values. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
220
221 // Free up any old stuff
222 if (oldValues != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
223
224 // Remove auditors and references on unused values
225 for (i = newNum; i < numcxx . . $ SoMField#num.; i++) {
226 SoPathcxx . . $ SoPath# *path = oldValues[i];
227 if (path != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
228 if (path->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).() != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
229 path->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).()->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
230 path->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
231 path->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
232 }
233 }
234
235 delete [] oldValues;
236 }
237 }
238
239 // Reallocate heads array and fill it in
240 if (headscxx . . $ SoMFPath#heads. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
241 delete [] headscxx . . $ SoMFPath#heads.;
242
243 if (newNum > 0) {
244 headscxx . . $ SoMFPath#heads. = new SoNodecxx . . $ SoNode# * [newNum];
245 for (i = 0; i < newNum; i++)
246 headscxx . . $ SoMFPath#heads.[i] = (valuescxx . . $ SoMFPath#values.[i] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! ? valuescxx . . $ SoMFPath#values.[i]->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).() : NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
247 }
248
249 numcxx . . $ SoMField#num. = maxNumcxx . . $ SoMField#maxNum. = newNum;
250 }
251
252 ////////////////////////////////////////////////////////////////////////
253 //
254 // Description:
255 // Propagates notification through the field. We have to override
256 // this to track changes to the paths we are watching. For example,
257 // if a path is truncated or its head node changes, we need to
258 // reset our head node auditor.
259 //
260 // NOTE: This code is essentially the same as the code in
261 // SoPathSensor::notify().
262 //
263 // Use: internal
264
265 void
266 SoMFPathcxx . . $ SoMFPath#::notifycxx . . $ SoMFPath#notify(f43de791d8d2eb5a).(SoNotListcxx . . $ SoNotList# *list)
267 //
268 ////////////////////////////////////////////////////////////////////////
269 {
270 // If there is nothing on the list, which would be the case if the
271 // field has been read from file, do the notify thing.
272 if (list->getFirstReccxx . . $ SoNotList#getFirstRec(a39986cdb7d7aef6).() == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
273 SoMFieldcxx . . $ SoMField#::notifycxx . . $ SoField#notify(f43de791d8d2eb5a).(list);
274 return;
275 }
276
277 SbBoolcxx . . $ SbBool# doNotify;
278 int i;
279 const SoBasecxx . . $ SoBase# *firstBase = list->getFirstReccxx . . $ SoNotList#getFirstRec(a39986cdb7d7aef6).()->getBasecxx . . $ SoNotRec#getBase(82e87c88e730ed63).();
280
281
282 // Find the path or path head node that started notification
283 for (i = 0; i < numcxx . . $ SoMField#num.; i++) {
284 if (firstBase == valuescxx . . $ SoMFPath#values.[i] || firstBase == headscxx . . $ SoMFPath#heads.[i])
285 break;
286 }
287
288 // This should never happen...
289 if (i == numcxx . . $ SoMField#num.)
290 return;
291
292 // If the path started notification:
293 if (firstBase == valuescxx . . $ SoMFPath#values.[i])
294 doNotify = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
295
296 // If the notification came through the head node
297 else if (firstBase == headscxx . . $ SoMFPath#heads.[i])
298 doNotify = valuescxx . . $ SoMFPath#values.[i]->isRelevantNotificationcxx . . $ SoPath#isRelevantNotification(50809eaab14a85d7).(list);
299
300 // If the head node of the path changed, detach from old head and
301 // attach to new:
302 if (valuescxx . . $ SoMFPath#values.[i]->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).() != headscxx . . $ SoMFPath#heads.[i]) {
303 // Detach from old:
304 if (headscxx . . $ SoMFPath#heads.[i] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
305 headscxx . . $ SoMFPath#heads.[i]->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
306 headscxx . . $ SoMFPath#heads.[i] = valuescxx . . $ SoMFPath#values.[i]->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).();
307 // Attach to new:
308 if (headscxx . . $ SoMFPath#heads.[i] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
309 headscxx . . $ SoMFPath#heads.[i]->addAuditorcxx . . $ SoBase#addAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
310 }
311
312 // Notify if we're supposed to...
313 if (doNotify)
314 SoMFieldcxx . . $ SoMField#::notifycxx . . $ SoField#notify(f43de791d8d2eb5a).(list);
315 }
316
317 ////////////////////////////////////////////////////////////////////////
318 //
319 // Description:
320 // Reads one (indexed) value from file. Returns FALSE on error.
321 //
322 // Use: private
323
324 SbBoolcxx . . $ SbBool#
325 SoMFPathcxx . . $ SoMFPath#::read1Valuecxx . . $ SoMFPath#read1Value(b57125c54eeea43).(SoInputcxx . . $ SoInput# *in, int index)
326 //
327 ////////////////////////////////////////////////////////////////////////
328 {
329 SbNamecxx . . $ SbName# namecxx . . $ SbName#SbName(49f6e7a06ebc5aa8).;
330 SoBasecxx . . $ SoBase# *base;
331
332 // See if it's a null pointer
333 if (in->readcxx . . $ SoInput#read(9a8a621633966675).(name)) {
334 if (name ==cxx . . $ `operator==`(1deca42c6f82b65f). "NULL") {
335 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(index, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
336 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
337 }
338 else
339 in->putBackcxx . . $ SoInput#putBack(85c52e162fed56f9).(name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).());
340 }
341
342 // Read path
343 if (! SoBasecxx . . $ SoBase#::readcxx . . $ SoBase#read(56c2a128ec952e80).(in, base, SoPathcxx . . $ SoPath#::getClassTypeIdcxx . . $ SoPath#getClassTypeId(c00c150378d2b968).())) {
344 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(index, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
345 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
346 }
347
348 // Set value (adds a reference to path)
349 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(index, (SoPathcxx . . $ SoPath# *) base);
350
351 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
352 }
353
354 ////////////////////////////////////////////////////////////////////////
355 //
356 // Description:
357 // Overrides SoField::countWriteRefs() to maintain write-references
358 // in paths.
359 //
360 // Use: private
361
362 void
363 SoMFPathcxx . . $ SoMFPath#::countWriteRefscxx . . $ SoMFPath#countWriteRefs(58762e0f79576b7c).(SoOutputcxx . . $ SoOutput# *out) const
364 //
365 ////////////////////////////////////////////////////////////////////////
366 {
367 // Do standard counting for field
368 SoFieldcxx . . $ SoField#::countWriteRefscxx . . $ SoField#countWriteRefs(58762e0f79576b7c).(out);
369
370 // Count paths
371 for (int i = 0; i < numcxx . . $ SoMField#num.; i++) {
372 SoPathcxx . . $ SoPath# *path = valuescxx . . $ SoMFPath#values.[i];
373
374 if (path != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
375 SoWriteActioncxx . . $ SoWriteAction# wacxx . . $ SoWriteAction#SoWriteAction(46d85c4d426f339d).(out);
376 wa.continueToApplycxx . . $ SoWriteAction#continueToApply(eed4dbbaf0eca0f1).(path);
377 }
378 }
379 }
380
381 ////////////////////////////////////////////////////////////////////////
382 //
383 // Description:
384 // Writes value of field to file.
385 //
386 // Use: private
387
388 void
389 SoMFPathcxx . . $ SoMFPath#::write1Valuecxx . . $ SoMFPath#write1Value(73cc401f7e0a390c).(SoOutputcxx . . $ SoOutput# *out, int index) const
390 //
391 ////////////////////////////////////////////////////////////////////////
392 {
393 if (valuescxx . . $ SoMFPath#values.[index] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
394 SoWriteActioncxx . . $ SoWriteAction# wacxx . . $ SoWriteAction#SoWriteAction(46d85c4d426f339d).(out);
395 wa.continueToApplycxx . . $ SoWriteAction#continueToApply(eed4dbbaf0eca0f1).(valuescxx . . $ SoMFPath#values.[index]);
396 }
397 else
398 out->writecxx . . $ SoOutput#write(85c52e162fed56f9).("NULL");
399 }
400
401 ////////////////////////////////////////////////////////////////////////
402 //
403 // Description:
404 // Changes value in field without doing other notification stuff.
405 // Keeps track of references and auditors.
406 //
407 // Use: private
408
409 void
410 SoMFPathcxx . . $ SoMFPath#::setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(int index, SoPathcxx . . $ SoPath# *newValue)
411 //
412 ////////////////////////////////////////////////////////////////////////
413 {
414 SoPathcxx . . $ SoPath# *value = valuescxx . . $ SoMFPath#values.[index];
415
416 // Play it safe if we are replacing one pointer with the same pointer
417 if (newValue != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
418 newValue->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
419
420 // Get rid of old path, if any
421 if (value != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
422
423 // Remove auditor on head node
424 if (headscxx . . $ SoMFPath#heads.[index] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
425 headscxx . . $ SoMFPath#heads.[index]->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
426
427 // Remove auditor on path itself
428 value->removeAuditorcxx . . $ SoBase#removeAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
429
430 value->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
431 }
432
433 value = valuescxx . . $ SoMFPath#values.[index] = newValue;
434
435 if (value != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
436
437 value->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
438
439 // Add auditor on path
440 value->addAuditorcxx . . $ SoBase#addAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
441
442 // Add auditor on head node. (For efficiency, a path does not
443 // audit its head node directly. Things that rely on this
444 // notification - e.g., this field and path sensors - have to
445 // do it themselves.)
446 headscxx . . $ SoMFPath#heads.[index] = value->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).();
447 if (headscxx . . $ SoMFPath#heads.[index] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
448 headscxx . . $ SoMFPath#heads.[index]->addAuditorcxx . . $ SoBase#addAuditor(83574029f67dcc4a).(this, SoNotReccxx . . $ SoNotRec#::FIELDcxx . . $ SoNotRec#FIELD.);
449 }
450
451 if (newValue != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
452 newValue->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
453 }
454
455 ////////////////////////////////////////////////////////////////////////
456 //
457 // Description:
458 // Update a copied field to use node copies if the head nodes have
459 // been copied.
460 //
461 // Use: internal
462
463 void
464 SoMFPathcxx . . $ SoMFPath#::fixCopycxx . . $ SoMFPath#fixCopy(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# copyConnections)
465 //
466 ////////////////////////////////////////////////////////////////////////
467 {
468 for (int i = 0; i < numcxx . . $ SoMField#num.; i++) {
469 if (valuescxx . . $ SoMFPath#values.[i] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
470
471 // If the head of the path has been copied, then each of
472 // the other nodes in the path must have been copied as
473 // well. Change the copied path to start at the copy and
474 // go through the copied nodes.
475
476 SoNodecxx . . $ SoNode# *headCopy = (SoNodecxx . . $ SoNode# *)
477 SoFieldContainercxx . . $ SoFieldContainer#::findCopycxx . . $ SoFieldContainer#findCopy(764c84fe9fa40e97).(valuescxx . . $ SoMFPath#values.[i]->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).(),
478 copyConnections);
479
480 if (headCopy != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
481
482 // Create a new path through the copied nodes
483 SoPathcxx . . $ SoPath# *pathCopy = new SoPathcxx . . $ SoPath#SoPath(da6c7544ccee32bd).(headCopy);
484 pathCopy->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
485 int len = ((SoFullPathcxx . . $ SoFullPath# *) valuescxx . . $ SoMFPath#values.[i])->getLengthcxx . . $ SoFullPath#getLength(455f465bc33b4cdf).();
486 for (int j = 1; j < len; j++)
487 pathCopy->appendcxx . . $ SoPath#append(d4f767463ce0a6b3).(valuescxx . . $ SoMFPath#values.[j]->getIndexcxx . . $ SoPath#getIndex(7ccb52b1bfe01045).(j));
488
489 setValcxx . . $ SoMFPath#setVal(8aae8380b1580dc1).(i, pathCopy);
490 pathCopy->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
491 }
492 }
493 }
494 }
495
496 ////////////////////////////////////////////////////////////////////////
497 //
498 // Description:
499 // Override this to also check the head of the stored path.
500 //
501 // Use: internal, virtual
502
503 SbBoolcxx . . $ SbBool#
504 SoMFPathcxx . . $ SoMFPath#::referencesCopycxx . . $ SoMFPath#referencesCopy(455f465bc33b4cdf).() const
505 //
506 ////////////////////////////////////////////////////////////////////////
507 {
508 // Do the normal test, and also see if the heads of the stored paths
509 // are copies
510 if (SoMFieldcxx . . $ SoMField#::referencesCopycxx . . $ SoField#referencesCopy(455f465bc33b4cdf).())
511 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
512
513 for (int i = 0; i < numcxx . . $ SoMField#num.; i++)
514 if (valuescxx . . $ SoMFPath#values.[i] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! &&
515 SoFieldContainercxx . . $ SoFieldContainer#::checkCopycxx . . $ SoFieldContainer#checkCopy(39a6da8fb59a7efc).(valuescxx . . $ SoMFPath#values.[i]->getHeadcxx . . $ SoPath#getHead(b794963b450d51b3).()) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
516 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
517
518 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
519 }