Source

Coin / src / fields / SoMFEngine.cpp

Full commit
Morten Eriksen 08431c9 
Marius Kintel 3ba6b41 




























Morten Eriksen 08431c9 

Morten Eriksen 3c21643 


Morten Eriksen 9f77b77 
Morten Eriksen 3c21643 
Morten Eriksen 08431c9 

Morten Eriksen a4f2421 
Morten Eriksen 08431c9 

Morten Eriksen a4f2421 








Morten Eriksen 08431c9 

Morten Eriksen 9f77b77 


Morten Eriksen 30c8f27 
Morten Eriksen 9f77b77 
Morten Eriksen 08431c9 
Lars J. Aas 251277c 
Tom Fredrik Blen… e73c0c5 

Morten Eriksen a4f2421 
Peder Blekken 7ef43f8 

Morten Eriksen 3c21643 
Morten Eriksen a4f2421 
Morten Eriksen 3c21643 
Morten Eriksen 08431c9 



Lars J. Aas 92263e4 

Morten Eriksen 30c8f27 



Morten Eriksen a4f2421 


Morten Eriksen 30c8f27 




Morten Eriksen 08431c9 

Morten Eriksen a4f2421 
Morten Eriksen 08431c9 


Morten Eriksen d87e67e 
Morten Eriksen 08431c9 

Morten Eriksen ca8c805 
Morten Eriksen a4f2421 


Morten Eriksen ca8c805 

Morten Eriksen a4f2421 






Morten Eriksen 08431c9 
Morten Eriksen a4f2421 
Morten Eriksen 08431c9 

Morten Eriksen a4f2421 


Tom Fredrik Blen… e73c0c5 
Morten Eriksen a4f2421 

Morten Eriksen 08431c9 
Morten Eriksen a4f2421 
Morten Eriksen 08431c9 
Morten Eriksen a4f2421 
Peder Blekken 2f2971d 


Tom Fredrik Blen… e73c0c5 
Morten Eriksen a4f2421 











Peder Blekken 519d4a9 
Morten Eriksen a4f2421 



Morten Eriksen 734998f 

Morten Eriksen a4f2421 


Peder Blekken 519d4a9 
Morten Eriksen a4f2421 

Peder Blekken 519d4a9 
Tom Fredrik Blen… e73c0c5 
Morten Eriksen a4f2421 

Peder Blekken 519d4a9 
Morten Eriksen a4f2421 


Tamer Fahmy 2510f24 
Morten Eriksen a4f2421 
Tamer Fahmy 619058a 
Morten Eriksen a4f2421 







Morten Eriksen 734998f 

Morten Eriksen a4f2421 
Peder Blekken 45f7b2e 
Lars J. Aas 02ec13b 
Peder Blekken 45f7b2e 

Morten Eriksen a4f2421 
Peder Blekken 45f7b2e 
Morten Eriksen 30c8f27 
Peder Blekken 45f7b2e 
Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 

Morten Eriksen a4f2421 
Peder Blekken 2f2971d 
Morten Eriksen 734998f 






Lars J. Aas 02ec13b 
Morten Eriksen 734998f 
Lars J. Aas 02ec13b 

Morten Eriksen 734998f 




Morten Eriksen a4f2421 
Morten Eriksen 734998f 


Morten Eriksen 30c8f27 
Morten Eriksen 734998f 

Lars J. Aas 02ec13b 

Morten Eriksen 734998f 

Morten Eriksen 3c21643 
Morten Eriksen a4f2421 
Tamer Fahmy 619058a 
Morten Eriksen 734998f 
Morten Eriksen 30c8f27 
Morten Eriksen 734998f 
Morten Eriksen 30c8f27 
Morten Eriksen a4f2421 




Tamer Fahmy 619058a 
Morten Eriksen a4f2421 
















Peder Blekken 519d4a9 
Morten Eriksen a4f2421 


Morten Eriksen 655ef2b 


Morten Eriksen a4f2421 


Lars J. Aas 02ec13b 

Peder Blekken 091a9f7 


Morten Eriksen a4f2421 

Morten Eriksen 03ff79a 
Morten Eriksen a4f2421 
Peder Blekken 519d4a9 
Morten Eriksen a4f2421 
Morten Eriksen 3b50feb 


Peder Blekken 519d4a9 

Morten Eriksen a4f2421 




Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 





Morten Eriksen 30c8f27 
Morten Eriksen a4f2421 

Peder Blekken 519d4a9 
Morten Eriksen a4f2421 

Morten Eriksen 03ff79a 
Morten Eriksen a4f2421 
Peder Blekken 519d4a9 
Morten Eriksen a4f2421 



Morten Eriksen 734998f 

Morten Eriksen a4f2421 
Peder Blekken 519d4a9 

Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 
Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 

Morten Eriksen a4f2421 





Morten Eriksen 655ef2b 


Morten Eriksen a4f2421 


Peder Blekken e89bc09 
Morten Eriksen a4f2421 


















Peder Blekken 7ef43f8 


Tom Fredrik Blen… e73c0c5 
Peder Blekken 7ef43f8 

Tom Fredrik Blen… e73c0c5 
Peder Blekken 7ef43f8 


Tom Fredrik Blen… e73c0c5 
Peder Blekken 7ef43f8 

Tom Fredrik Blen… e73c0c5 
Peder Blekken 7ef43f8 




Morten Eriksen 08431c9 

Morten Eriksen ca8c805 


Morten Eriksen 71325b4 
Morten Eriksen a4f2421 
Morten Eriksen 71325b4 



Morten Eriksen a4f2421 
Peder Blekken 77654ea 






Tom Fredrik Blen… e73c0c5 
Peder Blekken 77654ea 

Tom Fredrik Blen… e73c0c5 
Peder Blekken 77654ea 


Tom Fredrik Blen… e73c0c5 
Peder Blekken 77654ea 

Morten Eriksen a4f2421 
Morten Eriksen 71325b4 
Morten Eriksen a4f2421 
Morten Eriksen 30c8f27 
















Morten Eriksen a4f2421 


Morten Eriksen 30c8f27 


Morten Eriksen 734998f 

Morten Eriksen 30c8f27 
Morten Eriksen a4f2421 


Peder Blekken 4f1cdfb 


Morten Eriksen 30c8f27 




Morten Eriksen a4f2421 
Peder Blekken 4f1cdfb 
Lars J. Aas 02ec13b 
Peder Blekken 4f1cdfb 
Tom Fredrik Blen… e73c0c5 
Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 
Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 
Morten Eriksen 30c8f27 
Morten Eriksen a4f2421 

Morten Eriksen 30c8f27 



Morten Eriksen a4f2421 








Morten Eriksen 0220454 

Morten Eriksen 30c8f27 
Tom Fredrik Blen… e73c0c5 
Morten Eriksen 30c8f27 

Morten Eriksen 0220454 
Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 
Morten Eriksen a4f2421 



Morten Eriksen 9f77b77 

Morten Eriksen 30c8f27 
Morten Eriksen 3c21643 
Lars J. Aas 251277c 











  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
/**************************************************************************\
 * Copyright (c) Kongsberg Oil & Gas Technologies AS
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * 
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of the copyright holder nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/

// Important note: this sourcefile was in full generated by the
// Coin/scripts/templant script from the code in MFNodeEnginePath.tpl.

//$ BEGIN TEMPLATE MFNodeEnginePath(ENGINE, Engine, engine)

/*!
  \class SoMFEngine SoMFEngine.h Inventor/fields/SoMFEngine.h
  \brief The SoMFEngine class is a container for engines.
  \ingroup fields

  This field container stores an array of pointers to engines. It takes
  care of the necessary functionality for handling copy, import and
  export operations.

  Note that engine pointers stored in field instances of this type may
  be \c NULL pointers.

  \sa SoEngine, SoSFEngine

*/

// Type-specific define to be able to do #ifdef tests on type.  (Note:
// used to check the header file wrapper define, but that doesn't work
// with --enable-compact build.)
#define COIN_INTERNAL_SOMFENGINE

#include <Inventor/fields/SoMFEngine.h>

#include "SbBasicP.h"

#include <Inventor/fields/SoSFEngine.h>
#include <Inventor/SoOutput.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/SoPath.h>
#include <Inventor/engines/SoEngine.h>
#include <Inventor/nodes/SoNode.h>
#if COIN_DEBUG
#include <Inventor/errors/SoDebugError.h>
#endif // COIN_DEBUG

#include "fields/SoSubFieldP.h"

// These are the macros from SO_MFIELD_SOURCE_MALLOC we're
// using. What's missing is the SO_MFIELD_VALUE_SOURCE macro, which we
// need to implement "by hand" so reference counting and auditing
// comes out correctly.
SO_MFIELD_REQUIRED_SOURCE(SoMFEngine);
SO_MFIELD_CONSTRUCTOR_SOURCE(SoMFEngine);
SO_MFIELD_MALLOC_SOURCE(SoMFEngine, SoEngine *);
// Note that we're using the MALLOC versions (which just does
// bit-copying) of the macros, and not the the ALLOC versions (which
// allocates with "new", so constructors are run). The reason for this
// is that it's node/engine/path *pointers* that are simply bit-wise
// copied.


// Override from parent class.
void
SoMFEngine::initClass(void)
{
  SO_MFIELD_INTERNAL_INIT_CLASS(SoMFEngine);
}


// No need to document readValue() and writeValue() here, as the
// necessary information is provided by the documentation of the
// parent classes.
#ifndef DOXYGEN_SKIP_THIS

//// From the SO_MFIELD_VALUE_SOURCE macro, start. ///////////////////////////

// We can't use the macro invocation, as we need to take care of doing
// ref() and unref() on the engines in the array.

int
SoMFEngine::fieldSizeof(void) const
{
  return sizeof(SoEngine *);
}

void *
SoMFEngine::valuesPtr(void)
{
  return this->values;
}

void
SoMFEngine::setValuesPtr(void * ptr)
{
  // We don't get any ref()'ing done here, or any notification
  // mechanisms set up -- so this function should _only_ be used for
  // initial setup of array memory.  In Coin, it's only used from
  // SoMField::allocValues().
  this->values = static_cast<SoEngine **>(ptr);
}

int
SoMFEngine::find(SoEngine * value, SbBool addifnotfound)
{
  for (int i=0; i < this->num; i++) if ((*this)[i] == value) return i;

  if (addifnotfound) this->set1Value(this->num, value);
  return -1;
}

void
SoMFEngine::setValues(const int start, const int numarg, const SoEngine ** newvals)
{
  // Disable temporarily, so we under any circumstances will not send
  // more than one notification about the changes.
  SbBool notificstate = this->enableNotify(FALSE);
  // Important note: the notification state is reset at the end, so
  // this function should *not* have multiple return-points.

  // ref() new engines before unref()-ing old ones, in case there are
  // common engines (we don't want any premature destruction to happen).
  { for (int i=0; i < numarg; i++) if (newvals[i]) newvals[i]->ref(); }

  // We favor simplicity of code over performance here.
  { for (int i=0; i < numarg; i++)
    this->set1Value(start+i, const_cast<SoEngine *>(newvals[i])); }

  // unref() to match the initial ref().
  { for (int i=0; i < numarg; i++) if (newvals[i]) newvals[i]->unref(); }

  // Finally, send notification.
  (void)this->enableNotify(notificstate);
  this->setChangedIndices(start, numarg);
  if (notificstate) this->valueChanged();
  this->setChangedIndices();
}

void
SoMFEngine::set1Value(const int idx, SoEngine * newval)
{
  // Disable temporarily, so we under no circumstances will send more
  // than one notification about the change.
  SbBool notificstate = this->enableNotify(FALSE);
  // Important note: the notification state is reset at the end, so
  // this function should *not* have multiple return-points.

  // Don't use getNum(), getValues() or operator[] to find old values,
  // since this might trigger a recursive evaluation call if the field
  // is connected.

  // Expand array if necessary.
  if (idx >= this->num) {
#ifdef COIN_INTERNAL_SOMFPATH
    for (int i = this->num; i <= idx; i++) this->pathheads.append(NULL);
#endif // COIN_INTERNAL_SOMFPATH
    this->setNum(idx + 1);
  }

  SoEngine * oldptr = this->values[idx];
  if (oldptr != newval) {
    if (oldptr) {
#ifdef COIN_INTERNAL_SOMFPATH
      SoNode * h = oldptr->getHead();
      // The path should be audited by us at all times. So don't use
      // SoMFPath to wrap SoTempPath or SoLightPath, for instance.
      assert(h==this->pathheads[idx] &&
             "Path head changed without notification!");
      if (h) {
        h->removeAuditor(this, SoNotRec::FIELD);
        h->unref();
      }
#endif // COIN_INTERNAL_SOMFPATH
      oldptr->removeAuditor(this, SoNotRec::FIELD);
      oldptr->unref();
    }

    if (newval) {
      newval->addAuditor(this, SoNotRec::FIELD);
      newval->ref();
#ifdef COIN_INTERNAL_SOMFPATH
      SoNode * h = newval->getHead();
      if (h) {
        h->addAuditor(this, SoNotRec::FIELD);
        h->ref();
      }
#endif // COIN_INTERNAL_SOMFPATH
    }

    this->setChangedIndex(idx);
    this->values[idx] = newval;
#ifdef COIN_INTERNAL_SOMFPATH
    this->pathheads[idx] = newval ? newval->getHead() : NULL;
#endif // COIN_INTERNAL_SOMFPATH
  }

  // Finally, send notification.
  (void)this->enableNotify(notificstate);
  if (notificstate) this->valueChanged();
  this->setChangedIndices();
}

void
SoMFEngine::setValue(SoEngine * value)
{
  this->deleteAllValues();
  this->set1Value(0, value);
}

SbBool
SoMFEngine::operator==(const SoMFEngine & field) const
{
  if (this == &field) return TRUE;
  if (this->getNum() != field.getNum()) return FALSE;

  const SoEngine ** const lhs = this->getValues(0);
  const SoEngine ** const rhs = field.getValues(0);
  for (int i = 0; i < this->num; i++) if (lhs[i] != rhs[i]) return FALSE;
  return TRUE;
}

/*!
  \copydoc SoMFFloat::deleteAllValues()
*/
void
SoMFEngine::deleteAllValues(void)
{
  // Don't use getNum(), but use this->num directly, since getNum()
  // might trigger a recursive evaluation call if the field
  // is connected.

  if (this->num) this->deleteValues(0);
}

// Overridden to handle unref() and removeAuditor().
void
SoMFEngine::deleteValues(int start, int numarg)
{
  // Note: this function overrides the one in SoMField, so if you do
  // any changes here, take a look at that method aswell.

  if (numarg == -1) numarg = this->num - start;
  for (int i=start; i < start+numarg; i++) {
    SoEngine * n = this->values[i];
    if (n) {
      n->removeAuditor(this, SoNotRec::FIELD);
      n->unref();
    }
#ifdef COIN_INTERNAL_SOMFPATH
    SoNode * h = this->pathheads[start];
    this->pathheads.remove(start);
    if (h) {
      h->removeAuditor(this, SoNotRec::FIELD);
      h->unref();
    }
#endif // COIN_INTERNAL_SOMFPATH
  }

  inherited::deleteValues(start, numarg);
}

// Overridden to insert NULL pointers in new array slots.
void
SoMFEngine::insertSpace(int start, int numarg)
{
  // Disable temporarily so we don't send notification prematurely
  // from inherited::insertSpace().
  SbBool notificstate = this->enableNotify(FALSE);
  // Important note: the notification state is reset at the end, so
  // this function should *not* have multiple return-points.

  inherited::insertSpace(start, numarg);
  for (int i=start; i < start+numarg; i++) {
#ifdef COIN_INTERNAL_SOMFPATH
    this->pathheads.insert(NULL, start);
#endif // COIN_INTERNAL_SOMFPATH
    this->values[i] = NULL;
  }

  // Initialization done, now send notification.
  (void)this->enableNotify(notificstate);
  if (notificstate) this->valueChanged();
}

/*!
  \copydoc SoMFFloat::copyValue()
*/
void
SoMFEngine::copyValue(int to, int from)
{
  this->values[to] = this->values[from];
}

//// From the SO_MFIELD_VALUE_SOURCE macro, end. /////////////////////////////


// Import a single engine.
SbBool
SoMFEngine::read1Value(SoInput * in, int index)
{
  SoSFEngine sfengine;
  SbBool result = sfengine.readValue(in);
  if (result) this->set1Value(index, sfengine.getValue());
  return result;
}

// Export a single engine.
void
SoMFEngine::write1Value(SoOutput * out, int idx) const
{
  // NB: This code is common for SoMFNode, SoMFPath and SoMFEngine.
  // That's why we check for the base type before writing.

  SoBase * base = this->values[idx];
  if (base) {
    if (base->isOfType(SoNode::getClassTypeId())) {
      coin_assert_cast<SoNode *>(base)->writeInstance(out);
    }
    else if (base->isOfType(SoPath::getClassTypeId())) {
      SoWriteAction wa(out);
      wa.continueToApply(coin_assert_cast<SoPath*>(base));
    }
    else if (base->isOfType(SoEngine::getClassTypeId())) {
      coin_assert_cast<SoEngine *>(base)->writeInstance(out);
    }
  }
  else {
    out->write("NULL");
  }
}

#endif // DOXYGEN_SKIP_THIS


// Overridden from parent to propagate write reference counting to
// engine.
void
SoMFEngine::countWriteRefs(SoOutput * out) const
{
  inherited::countWriteRefs(out);

  for (int i = 0; i < this->getNum(); i++) {
    SoBase * base = this->values[i];
    if (base) {
      // NB: This code is common for SoMFNode, SoMFPath and SoMFEngine.
      // That's why we check the base type before writing/counting

      if (base->isOfType(SoNode::getClassTypeId())) {
        coin_assert_cast<SoNode *>(base)->writeInstance(out);
      }
      else if (base->isOfType(SoEngine::getClassTypeId())) {
        coin_assert_cast<SoEngine *>(base)->addWriteReference(out);
      }
      else if (base->isOfType(SoPath::getClassTypeId())) {
        SoWriteAction wa(out);
        wa.continueToApply(coin_assert_cast<SoPath *>(base));
      }
    }
  }
}

// Override from parent to update our engine pointer
// references. This is necessary so we do the Right Thing with regard
// to the copyconnections flag.
//
// Note that we have to unplug auditing and the reference counter
// addition we made during the copy process.
//
// For reference for future debugging sessions, copying of this field
// goes like this:
//
//    - copyFrom() is called (typically from SoFieldData::overlay())
//    - copyFrom() calls operator=()
//    - operator=() calls setValues()
//    - we have a local copy (ie not from SoSubField.h) of setValues()
//      that sets up auditing and references the array items
//
// <mortene@sim.no>
void
SoMFEngine::fixCopy(SbBool copyconnections)
{
  // Disable temporarily, so we under no circumstances will send more
  // than one notification about the changes.
  SbBool notificstate = this->enableNotify(FALSE);
  // Important note: the notification state is reset at the end, so
  // this function should *not* have multiple return-points.

  for (int i=0; i < this->getNum(); i++) {
    SoEngine * n = (*this)[i];
    if (n) {
#if COIN_DEBUG
      n->assertAlive();
#endif // COIN_DEBUG
      // The set1Value() call below will automatically de-audit and
      // un-ref the old pointer value node reference we have in the
      // array, *before* re-inserting a copy.

#if defined(COIN_INTERNAL_SOMFNODE) || defined(COIN_INTERNAL_SOMFENGINE)
      SoFieldContainer * fc = SoFieldContainer::findCopy(n, copyconnections);
#if COIN_DEBUG
      if (fc) fc->assertAlive();
#endif // COIN_DEBUG
      if (fc) this->set1Value(i, coin_assert_cast<SoEngine *>(fc));
#endif // COIN_INTERNAL_SOMFNODE || COIN_INTERNAL_SOMFENGINE

#ifdef COIN_INTERNAL_SOMFPATH
      this->set1Value(i, n->copy());
#endif // COIN_INTERNAL_SOMFPATH
    }
  }

  // Finally, send notification.
  (void)this->enableNotify(notificstate);
  if (notificstate) this->valueChanged();
}

// Override from SoField to check engine pointer.
SbBool
SoMFEngine::referencesCopy(void) const
{
  if (inherited::referencesCopy()) return TRUE;

  for (int i=0; i < this->getNum(); i++) {
    SoEngine * item = (*this)[i];
    if (item) {
#if defined(COIN_INTERNAL_SOMFNODE) || defined(COIN_INTERNAL_SOMFENGINE)
      if (SoFieldContainer::checkCopy(coin_assert_cast<SoFieldContainer *>(item))) return TRUE;
#endif // COIN_INTERNAL_SOMFNODE || COIN_INTERNAL_SOMFENGINE
#ifdef COIN_INTERNAL_SOMFPATH
      if (item->getHead() && SoFieldContainer::checkCopy(item->getHead())) return TRUE;
#endif // COIN_INTERNAL_SOMFPATH
    }
  }

  return FALSE;
}

// Kill the type-specific define.
#undef COIN_INTERNAL_SOMFENGINE
//$ END TEMPLATE MFNodeEnginePath


#ifdef COIN_TEST_SUITE

BOOST_AUTO_TEST_CASE(initialized)
{
  SoMFEngine field;
  BOOST_CHECK_MESSAGE(field.getTypeId() != SoType::badType(),
                      "missing class initialization");
  BOOST_CHECK_EQUAL(field.getNum(), 0);
}

#endif // COIN_TEST_SUITE