1 /**************************************************************************\
2  * Copyright (c) Kongsberg Oil & Gas Technologies AS
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32 
33 /*!
34   \class SoNodeKit SoNodeKit.h Inventor/nodekits/SoNodeKit.h
35   \brief The SoNodeKit class is used to initialize the nodekit classes.
36 
37   \ingroup nodekits
38 
39   The sole function of SoNodeKit is to be just a placeholder for the
40   toplevel initialization code for all nodekit-related classes.
41 
42   \sa SoBaseKit
43 */
44 
45 #include <Inventor/nodekits/SoNodeKit.h>
46 
47 #ifdef HAVE_CONFIG_H
48 #include "config.h"
49 #endif // HAVE_CONFIG_H
50 
51 #include <Inventor/SbBasic.h>
52 #include <Inventor/SoDB.h>
53 #include <Inventor/C/tidbits.h>
54 
55 #ifdef HAVE_NODEKITS
56 #include <Inventor/nodekits/SoAppearanceKit.h>
57 #include <Inventor/nodekits/SoCameraKit.h>
58 #include <Inventor/nodekits/SoLightKit.h>
59 #include <Inventor/nodekits/SoNodeKitListPart.h>
60 #include <Inventor/nodekits/SoSceneKit.h>
61 #include <Inventor/nodekits/SoShapeKit.h>
62 #include <Inventor/nodekits/SoWrapperKit.h>
63 #include <ForeignFiles/SoForeignFileKit.h>
64 #endif // HAVE_NODEKITS
65 
66 #include "tidbitsp.h"
67 
68 static SbBool nodekit_isinitialized = FALSE;
69 
nodekit_cleanup(void)70 static void nodekit_cleanup(void)
71 {
72   nodekit_isinitialized = FALSE;
73 }
74 
75 /*!
76   Initialize the nodekit system.
77 
78   Note that this method is \e not called implicitly from SoDB::init().
79   As a matter of fact, this method calls SoDB::init() itself to make
80   sure all the underlying classes for the nodekits classes have
81   been initialized.
82 
83   This method is also called from within SoInteraction::init(), as the
84   interaction functionality in Coin depends on the nodekit classes.
85  */
86 void
init(void)87 SoNodeKit::init(void)
88 {
89   if (nodekit_isinitialized) return;
90 
91   if (!SoDB::isInitialized()) SoDB::init();
92 
93 #ifdef HAVE_NODEKITS
94   SoNodeKitListPart::initClass();
95 
96   SoBaseKit::initClass();
97   SoAppearanceKit::initClass();
98   SoCameraKit::initClass();
99   SoLightKit::initClass();
100   SoSceneKit::initClass();
101   SoSeparatorKit::initClass();
102   SoShapeKit::initClass();
103   SoWrapperKit::initClass();
104   SoForeignFileKit::initClass();
105 #endif // HAVE_NODEKITS
106 
107   nodekit_isinitialized = TRUE;
108   cc_coin_atexit_static_internal((coin_atexit_f*) nodekit_cleanup);
109 }
110