Source

Coin / src / scxml / ScXML.cpp

  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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/**************************************************************************\
 * 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.
\**************************************************************************/

#include <Inventor/scxml/ScXML.h>

/*!
  \class ScXML ScXML.h Inventor/scxml/ScXML.h
  \brief namespace for static ScXML-related functions.

  This is a static namespace class for ScXML-related functions.

  \since Coin 3.0
  \ingroup scxml
*/

#ifdef _MSC_VER
#pragma warning(disable:4786) // symbol truncated
#endif // _MSC_VER

#include <cassert>
#include <cstring>

#include <Inventor/SbName.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/C/XML/document.h>
#include <Inventor/C/XML/element.h>
#include <Inventor/C/XML/attribute.h>

#include <Inventor/misc/CoinResources.h>

#include <Inventor/scxml/ScXML.h>
#include <Inventor/scxml/ScXMLObject.h>
#include <Inventor/scxml/ScXMLEvent.h>
#include <Inventor/scxml/ScXMLEventTarget.h>
#include <Inventor/scxml/ScXMLStateMachine.h>
#include <Inventor/scxml/ScXMLDocument.h>

#include <Inventor/scxml/ScXMLElt.h>
#include <Inventor/scxml/ScXMLScxmlElt.h>
#include <Inventor/scxml/ScXMLInitialElt.h>
#include <Inventor/scxml/ScXMLAbstractStateElt.h>
#include <Inventor/scxml/ScXMLStateElt.h>
#include <Inventor/scxml/ScXMLParallelElt.h>
#include <Inventor/scxml/ScXMLFinalElt.h>
#include <Inventor/scxml/ScXMLOnEntryElt.h>
#include <Inventor/scxml/ScXMLOnExitElt.h>
#include <Inventor/scxml/ScXMLTransitionElt.h>
#include <Inventor/scxml/ScXMLHistoryElt.h>

#include <Inventor/scxml/ScXMLExecutableElt.h>
#include <Inventor/scxml/ScXMLEventElt.h>
#include <Inventor/scxml/ScXMLIfElt.h>
#include <Inventor/scxml/ScXMLElseIfElt.h>
#include <Inventor/scxml/ScXMLElseElt.h>
#include <Inventor/scxml/ScXMLLogElt.h>

#include <Inventor/scxml/ScXMLDataModelElt.h>
#include <Inventor/scxml/ScXMLDataElt.h>
#include <Inventor/scxml/ScXMLAssignElt.h>
#include <Inventor/scxml/ScXMLValidateElt.h>

#include <Inventor/scxml/ScXMLSendElt.h>
#include <Inventor/scxml/ScXMLInvokeElt.h>
#include <Inventor/scxml/ScXMLParamElt.h>
#include <Inventor/scxml/ScXMLFinalizeElt.h>
#include <Inventor/scxml/ScXMLContentElt.h>

#include <Inventor/scxml/ScXMLAnchorElt.h>

#include <Inventor/scxml/ScXMLEvaluator.h>
#include <Inventor/scxml/ScXMLMinimumEvaluator.h>
#include <Inventor/scxml/ScXMLXPathEvaluator.h>
#include <Inventor/scxml/ScXMLECMAScriptEvaluator.h>
#include <Inventor/scxml/ScXMLCoinEvaluator.h>

#include <Inventor/scxml/SoScXMLEvent.h>
#include <Inventor/scxml/SoScXMLStateMachine.h>

#include "tidbitsp.h"

#include "threads/threadsutilp.h"

#include "scxml/ScXMLP.h"

// *************************************************************************

/*!
  \page scxml State Chart XML

  The ScXML part of Coin is a basic, non-conformant, partial
  implementation of State Chart XML, based on the W3C Working Draft
  16 May 2008 of SCXML <http://www.w3.org/TR/2008/WD-scxml-20080516/>.
  The latest version should be at <http://www.w3.org/TR/scxml/>.
  Read that document for a basic understanding how SCXML documents
  should be constructed.

  Coin uses SCXML for setting up its navigation systems, to be able to
  remove hardcoded logic for user navigation and externalize it into XML
  files.  This makes it easy for users to customize the navigation
  system for their own purposes.

  Unsupported Items:

  - The &lt;parallel&gt; element is not supported as intended with
    parallel states.  Coin will just treat it as an ordinary
    &lt;state&gt; element for now.  Parallel states is not high up on
    the priority list, so expect this to be handled after a lot of
    other functionality is in place.

  - The &lt;datamodel&gt;-related part of the specification is not
    fully supported.

  - The 'target' attribute in the &lt;transition&gt; element can only
    identify a single state currently, not multiple as you would have
    to when having support for &lt;parallel&gt; elements (which we
    don't have).

  - The virtual state elements like &lt;history&gt; and &lt;anchor&gt;
    are just implemented as dummy states for now and do not do
    anything in relation to what they should actually do.

  For learning more about how ScXML is implemented and used in Coin,
  take a look at $COINDIR/scxml/navigation/examiner.xml (or in the
  Coin source directory, data/scxml/navigation/examiner.xml) for an
  example of how an SCXML system for camera navigation looks,
  and look at the source files in src/navigation/ for the C++ counterparts
  to the same SCXML navigation system.

  \ingroup scxml
  \since Coin 3.0
*/

#define SCXML_DEFAULT_NS "default" // to be deprecated

// *************************************************************************

// private static variables
ScXMLP::NamespaceDict * ScXMLP::namespaces = NULL;
ScXMLP::TargettypeDict * ScXMLP::targettypes = NULL;
ScXMLP::TypeDict * ScXMLP::profileevaluators = NULL;

// *************************************************************************

extern "C" {
static void scxml_cleanup(void);
}

/*!
  Initializes the basic ScXML classes.
*/
void
ScXML::initClasses(void)
{
  ScXMLP::init();
  ScXMLObject::initClass();
  ScXMLEvent::initClass();
  ScXMLEventTarget::initClass();
  ScXMLStateMachine::initClass();
  ScXMLDocument::initClass();

  ScXMLElt::initClass();
  ScXMLScxmlElt::initClass();
  ScXMLInitialElt::initClass();
  ScXMLAbstractStateElt::initClass();
  ScXMLStateElt::initClass();
  ScXMLParallelElt::initClass();
  ScXMLFinalElt::initClass();
  ScXMLOnEntryElt::initClass();
  ScXMLOnExitElt::initClass();
  ScXMLTransitionElt::initClass();
  ScXMLHistoryElt::initClass();

  ScXMLExecutableElt::initClass();
  ScXMLEventElt::initClass();
  ScXMLIfElt::initClass();
  ScXMLElseIfElt::initClass();
  ScXMLElseElt::initClass();
  ScXMLLogElt::initClass();

  ScXMLDataModelElt::initClass();
  ScXMLDataElt::initClass();
  ScXMLAssignElt::initClass();
  ScXMLValidateElt::initClass();

  ScXMLSendElt::initClass();
  ScXMLInvokeElt::initClass();
  ScXMLParamElt::initClass();
  ScXMLFinalizeElt::initClass();
  ScXMLContentElt::initClass();

  ScXMLAnchorElt::initClass();

  // evaluators also inits data-objs
  ScXMLEvaluator::initClass();
  ScXMLMinimumEvaluator::initClass();
  ScXMLXPathEvaluator::initClass();
  ScXMLECMAScriptEvaluator::initClass();
  ScXMLCoinEvaluator::initClass();

  SoScXMLEvent::initClass();
  SoScXMLStateMachine::initClass();

  coin_atexit(scxml_cleanup, CC_ATEXIT_NORMAL);
}

void
scxml_cleanup(void)
{
  ScXML::cleanClasses();
}

void
ScXML::cleanClasses(void)
{
  SoScXMLStateMachine::cleanClass();
  SoScXMLEvent::cleanClass();

  ScXMLCoinEvaluator::cleanClass();
  ScXMLECMAScriptEvaluator::cleanClass();
  ScXMLXPathEvaluator::cleanClass();
  ScXMLMinimumEvaluator::cleanClass();
  ScXMLEvaluator::cleanClass();

  ScXMLAnchorElt::cleanClass();

  ScXMLContentElt::cleanClass();
  ScXMLFinalizeElt::cleanClass();
  ScXMLParamElt::cleanClass();
  ScXMLInvokeElt::cleanClass();
  ScXMLSendElt::cleanClass();

  ScXMLValidateElt::cleanClass();
  ScXMLAssignElt::cleanClass();
  ScXMLDataElt::cleanClass();
  ScXMLDataModelElt::cleanClass();

  ScXMLLogElt::cleanClass();
  ScXMLElseElt::cleanClass();
  ScXMLElseIfElt::cleanClass();
  ScXMLIfElt::cleanClass();
  ScXMLEventElt::cleanClass();
  ScXMLExecutableElt::cleanClass();

  ScXMLHistoryElt::cleanClass();
  ScXMLTransitionElt::cleanClass();
  ScXMLOnExitElt::cleanClass();
  ScXMLOnEntryElt::cleanClass();
  ScXMLFinalElt::cleanClass();
  ScXMLParallelElt::cleanClass();
  ScXMLStateElt::cleanClass();
  ScXMLAbstractStateElt::cleanClass();
  ScXMLInitialElt::cleanClass();
  ScXMLScxmlElt::cleanClass();
  ScXMLElt::cleanClass();

  ScXMLDocument::cleanClass();
  ScXMLStateMachine::cleanClass();
  ScXMLEventTarget::cleanClass();
  ScXMLEvent::cleanClass();
  ScXMLObject::cleanClass();
  ScXMLP::cleanup();
}

// *************************************************************************

SbBool
ScXML::registerEvaluatorType(SbName profilename, SoType evaluatortype)
{
  assert(!evaluatortype.isBad());
  assert(ScXMLP::profileevaluators);
  if (!evaluatortype.isDerivedFrom(ScXMLEvaluator::getClassTypeId())) {
    SoDebugError::post("ScXMLStateMachine::registerEvaluator",
                       "Evaluator type must be derived from ScXMLEvaluator");
    return FALSE;
  }
  ScXMLP::TypeDict::iterator it = ScXMLP::profileevaluators->find(profilename.getString());
  if (it != ScXMLP::profileevaluators->end()) {
    SoDebugError::post("ScXML::registerEvaluatorType",
                       "Evaluator for profile '%s' already registered.\n",
                       profilename.getString());
    return FALSE;
  }
  ScXMLP::TypeEntry entry(profilename.getString(), evaluatortype);
  ScXMLP::profileevaluators->insert(entry);
  return TRUE;
}

SbBool
ScXML::unregisterEvaluatorType(SbName profilename, SoType evaluatortype)
{
  assert(!evaluatortype.isBad());
  assert(ScXMLP::profileevaluators);

  ScXMLP::TypeDict::iterator it = ScXMLP::profileevaluators->find(profilename.getString());
  if (it == ScXMLP::profileevaluators->end()) {
    SoDebugError::post("ScXML::unregisterEvaluatorType",
                       "No evaluator type is registered for profile '%s'.\n",
                       profilename.getString());
    return FALSE;
  }
  if (it->second != evaluatortype) {
    SoDebugError::post("ScXML::unregisterEvaluatorType",
                       "Different evaluator type registered for profile '%s'.\n",
                       profilename.getString());
    return FALSE;
  }
  ScXMLP::profileevaluators->erase(it);
  return TRUE;
}

SoType
ScXML::getEvaluatorTypeForProfile(SbName profilename)
{
  assert(ScXMLP::profileevaluators);

  ScXMLP::TypeDict::iterator it = ScXMLP::profileevaluators->find(profilename.getString());
  if (it == ScXMLP::profileevaluators->end()) {
    // no type registered for profile
    return SoType::badType();
  }
  return it->second;
}

// *************************************************************************
// SCXML FILE INPUT
// *************************************************************************

/*!
  This function reads in an SCXML document from a file.

  \returns an ScXMLDocument-derived statemachine object hierarchy.
*/
ScXMLStateMachine *
ScXML::readFile(const char * filename)
{
  ScXMLDocument * doc = ScXMLDocument::readFile(filename);
  if (!doc) {
    return NULL;
  }

  ScXMLStateMachine * statemachine = new SoScXMLStateMachine;
  statemachine->setDescription(doc);
  statemachine->setName(filename);

  return statemachine;
}

/*!
  This function reads in an SCXML document residing in memory.

  \returns an ScXMLDocument-derived statemachine object hierarchy.
*/
ScXMLStateMachine *
ScXML::readBuffer(const SbByteBuffer & bufferdata)
{
  ScXMLDocument * doc = ScXMLDocument::readBuffer(bufferdata);
  if (!doc) {
    return NULL;
  }

  ScXMLStateMachine * statemachine = new SoScXMLStateMachine;
  statemachine->setDescription(doc);
  statemachine->setName("<memory buffer>");

  return statemachine;
}

// *************************************************************************
// TYPE SYSTEM REGISTERING AND LOOKUP
// *************************************************************************

/*
*/
void
ScXMLP::registerClassType(const char * xmlns, const char * classname, SoType type)
{
  assert(!type.isBad());
  ScXMLP::registerClassType(ScXMLP::namespaces, xmlns, classname, type);
}

/*
*/
void
ScXMLP::registerInvokeClassType(const char * xmlns, const char * targettype, const char * source, SoType type)
{
  assert(!type.isBad());
  assert(xmlns);

  // Note that we actually split on targettype on the top of the
  // hierarchy/tree here, and not on xml-namespace as one might think
  // at first, but this is intentional. This is because the namespace
  // logic should fall through to the default namespace if you don't
  // find the type you are looking for in the specified namespace, and
  // because of that, it is most convenient to split on namespace at
  // the next-to-bottom level to be able to share code when looking up
  // types.

  ScXMLP::NamespaceDict * nsdict = ScXMLP::getNamespaceDict(ScXMLP::targettypes, targettype);
  assert(nsdict);

  ScXMLP::registerClassType(nsdict, xmlns, source, type);
}

/*
*/
void
ScXMLP::registerClassType(NamespaceDict * nsdict, const char * xmlns, const char * classname, SoType type)
{
  assert(xmlns);

  TypeDict * typedict = ScXMLP::getTypeDict(nsdict, xmlns);
  assert(typedict);

  SbName classnamename(classname);
  const char * key = classnamename.getString();
  TypeDict::iterator it = typedict->find(key);
  if (it != typedict->end()) {
    it->second = type;
  } else {
    typedict->insert(TypeEntry(key, type));
  }
}

/*
*/
ScXMLP::TypeDict *
ScXMLP::getTypeDict(NamespaceDict * nsdict, const char * xmlns)
{
  SbName xmlnsname(xmlns); // uniqify on string pointer
  const char * key = xmlnsname.getString();
  NamespaceDict::iterator it = nsdict->find(key);
  if (it != nsdict->end()) {
    return it->second;
  } else {
    TypeDict * dict = new TypeDict;
    nsdict->insert(NamespaceEntry(key, dict));
    return dict;
  }
}

// *************************************************************************
/*
*/
SoType
ScXMLP::getClassType(NamespaceDict * nsdict, const char * xmlns, const char * classname)
{
  assert(xmlns && classname);

  const SbName classnamename(classname);
  const char * key = classnamename.getString();

  ScXMLP::TypeDict * typedict = NULL;

  typedict = ScXMLP::getTypeDict(nsdict, xmlns);
  if (typedict) {
    TypeDict::iterator it = typedict->find(key);
    if (it != typedict->end()) {
      return it->second;
    }
  }

  typedict = ScXMLP::getTypeDict(nsdict, SCXML_DEFAULT_NS);
  if (typedict) {
    TypeDict::iterator it = typedict->find(key);
    if (it != typedict->end()) {
      return it->second;
    }
  }

  return SoType::badType();
}

/*
*/
ScXMLP::NamespaceDict *
ScXMLP::getNamespaceDict(TargettypeDict * ttdict, const char * targettype)
{
  SbName targettypename(targettype); // uniqify on string pointer
  const char * key = targettypename.getString();
  TargettypeDict::iterator it = ttdict->find(key);
  if (it != ttdict->end()) {
    return it->second;
  } else {
    NamespaceDict * dict = new NamespaceDict;
    ttdict->insert(TargettypeEntry(key, dict));
    return dict;
  }
}

/*
*/
SoType
ScXMLP::getClassType(const char * xmlns, const char * classname)
{
  return ScXMLP::getClassType(ScXMLP::namespaces, xmlns, classname);
}

SoType
ScXMLP::getInvokeClassType(const char * xmlns, const char * targettype, const char * source)
{
  NamespaceDict * nsdict = ScXMLP::getNamespaceDict(ScXMLP::targettypes, targettype);
  assert(nsdict);

  SoType invoketype = ScXMLP::getClassType(nsdict, xmlns, source);

#if 0
  if (invoketype == SoType::badType()) {
    return ScXMLFallbackInvoke::getClassTypeId();
  }
#endif

  return invoketype;
}

// *************************************************************************

// internal implementation
ScXMLStateMachine *
ScXMLP::readXMLData(cc_xml_doc * doc)
{
  const char * xmlns = SCXML_DEFAULT_NS;

  // get a handle on the root element
  cc_xml_elt * root = cc_xml_doc_get_root(doc);
  if (strcmp(cc_xml_elt_get_type(root), "scxml") != 0) {
    return NULL;
  }

  // peek at xmlns attribute to get the correct object types instantiated
  const cc_xml_attr * nsattr = cc_xml_elt_get_attribute(root, "xmlns");
  if (nsattr) {
    xmlns = cc_xml_attr_get_value(nsattr);
    assert(xmlns);
  }

  SoType statemachinetype = ScXMLP::getClassType(xmlns, "statemachine");
  assert(statemachinetype.canCreateInstance());
  ScXMLStateMachine * statemachine =
    static_cast<ScXMLStateMachine *>(statemachinetype.createInstance());
  assert(statemachine && statemachine->isOfType(ScXMLStateMachine::getClassTypeId()));

  // FIXME
  ScXMLObject * documentobj = NULL;
  // ScXMLObject * documentobj = ScXMLP::readScXMLDocument(statemachine, root, xmlns);
  assert(documentobj && documentobj->isOfType(ScXMLDocument::getClassTypeId()));
  ScXMLDocument * document = static_cast<ScXMLDocument *>(documentobj);

  statemachine->setDescription(document);

  return statemachine;
}

// *************************************************************************

void * ScXMLP::mutex = NULL;

void
ScXMLP::init(void)
{
  ScXMLP::namespaces = new ScXMLP::NamespaceDict;
  ScXMLP::targettypes = new ScXMLP::TargettypeDict;
  ScXMLP::profileevaluators = new ScXMLP::TypeDict;
  CC_MUTEX_CONSTRUCT(ScXMLP::mutex);
}

void
ScXMLP::cleanup(void)
{
  cleanup_namespacedict(ScXMLP::namespaces);
  delete ScXMLP::namespaces;
  ScXMLP::namespaces = NULL;
  delete ScXMLP::profileevaluators;
  ScXMLP::profileevaluators = NULL;
  cleanup_targettypes();
  CC_MUTEX_DESTRUCT(ScXMLP::mutex);
}

void
ScXMLP::lock(void)
{
  assert(ScXMLP::mutex);
  CC_MUTEX_LOCK(ScXMLP::mutex);
}

void
ScXMLP::unlock(void)
{
  assert(ScXMLP::mutex);
  CC_MUTEX_UNLOCK(ScXMLP::mutex);
}


void
ScXMLP::cleanup_namespacedict(NamespaceDict * dict)
{
  assert(dict);
  NamespaceDict::iterator it = dict->begin();
  while (it != dict->end()) {
    delete it->second;
    it++;
  }
}

void
ScXMLP::cleanup_targettypes(void)
{
  assert(ScXMLP::targettypes);
  TargettypeDict::iterator it = ScXMLP::targettypes->begin();
  while (it != ScXMLP::targettypes->end()) {
    ScXMLP::NamespaceDict * dict = it->second;
    cleanup_namespacedict(dict);
    delete dict;
    it++;
  }
  delete ScXMLP::targettypes;
  ScXMLP::targettypes = NULL;
}

// *************************************************************************