Coin3D is Free Software,
published under the
BSD 3-clause license
.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoSubKit.h
1
#ifndef COIN_SOSUBKIT_H
2
#define COIN_SOSUBKIT_H
3
4
/**************************************************************************\
5
* Copyright (c) Kongsberg Oil & Gas Technologies AS
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions are
10
* met:
11
*
12
* Redistributions of source code must retain the above copyright notice,
13
* this list of conditions and the following disclaimer.
14
*
15
* Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
*
19
* Neither the name of the copyright holder nor the names of its
20
* contributors may be used to endorse or promote products derived from
21
* this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
\**************************************************************************/
35
36
#include <Inventor/nodes/SoSubNode.h>
37
#include <Inventor/fields/SoSFNode.h>
38
#include <Inventor/nodekits/SoNodekitCatalog.h>
39
#include <
Inventor/C/tidbits.h
>
40
41
#ifndef COIN_INTERNAL
42
// Include this header file for better Open Inventor compatibility.
43
#include <Inventor/nodekits/SoNodeKitListPart.h>
44
#endif // !COIN_INTERNAL
45
46
47
// FIXME: document all the macros, as they are part of the public
48
// API. 20011024 mortene.
49
50
#define PRIVATE_KIT_HEADER(_kitclass_) \
51
public: \
52
static const SoNodekitCatalog * getClassNodekitCatalog(void); \
53
virtual const SoNodekitCatalog * getNodekitCatalog(void) const; \
54
\
55
protected: \
56
static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void); \
57
\
58
private: \
59
static SoNodekitCatalog * classcatalog; \
60
static const SoNodekitCatalog ** parentcatalogptr; \
61
static void atexit_cleanupkit(void)
62
63
#define SO_KIT_HEADER(_kitclass_) \
64
SO_NODE_HEADER(_kitclass_); \
65
PRIVATE_KIT_HEADER(_kitclass_)
66
67
#define SO_KIT_ABSTRACT_HEADER(_kitclass_) \
68
SO_NODE_ABSTRACT_HEADER(_kitclass_); \
69
PRIVATE_KIT_HEADER(_kitclass_)
70
71
#define SO_KIT_CATALOG_ENTRY_HEADER(_entry_) \
72
protected: SoSFNode _entry_
73
74
75
#define PRIVATE_KIT_SOURCE(_class_) \
76
SoNodekitCatalog * _class_::classcatalog = NULL; \
77
const SoNodekitCatalog ** _class_::parentcatalogptr = NULL; \
78
\
79
const SoNodekitCatalog * \
80
_class_::getClassNodekitCatalog(void) \
81
{ \
82
return _class_::classcatalog; \
83
} \
84
\
85
const SoNodekitCatalog * \
86
_class_::getNodekitCatalog(void) const \
87
{ \
88
return _class_::classcatalog; \
89
} \
90
\
91
const SoNodekitCatalog ** \
92
_class_::getClassNodekitCatalogPtr(void) \
93
{ \
94
return const_cast<const class SoNodekitCatalog **>(&_class_::classcatalog); \
95
} \
96
\
97
void \
98
_class_::atexit_cleanupkit(void) \
99
{ \
100
delete _class_::classcatalog; \
101
_class_::classcatalog = NULL; \
102
_class_::parentcatalogptr = NULL; \
103
}
104
105
#define SO_KIT_SOURCE(_class_) \
106
SO_NODE_SOURCE(_class_) \
107
PRIVATE_KIT_SOURCE(_class_)
108
109
#define SO_KIT_ABSTRACT_SOURCE(_class_) \
110
SO_NODE_ABSTRACT_SOURCE(_class_); \
111
PRIVATE_KIT_SOURCE(_class_)
112
113
#define SO_KIT_IS_FIRST_INSTANCE() \
114
SO_NODE_IS_FIRST_INSTANCE()
115
116
#define SO_KIT_INIT_CLASS(_class_, _parentclass_, _parentname_) \
117
do { \
118
SO_NODE_INIT_CLASS(_class_, _parentclass_, _parentname_); \
119
_class_::parentcatalogptr = _parentclass_::getClassNodekitCatalogPtr(); \
120
} WHILE_0
121
122
#define SO_KIT_INIT_ABSTRACT_CLASS(_class_, _parentclass_, _parentname_) \
123
do { \
124
SO_NODE_INIT_ABSTRACT_CLASS(_class_, _parentclass_, _parentname_); \
125
_class_::parentcatalogptr = _parentclass_::getClassNodekitCatalogPtr(); \
126
} WHILE_0
127
128
129
#define SO_KIT_CONSTRUCTOR(_class_) \
130
do { \
131
SO_NODE_CONSTRUCTOR(_class_); \
132
SoBase::staticDataLock(); \
133
if (_class_::classcatalog == NULL) { \
134
SoType mytype = SoType::fromName(SO__QUOTE(_class_)); \
135
_class_::classcatalog = (*_class_::parentcatalogptr)->clone(mytype); \
136
cc_coin_atexit_static_internal(_class_::atexit_cleanupkit); \
137
} \
138
SoBase::staticDataUnlock(); \
139
} WHILE_0
140
141
142
143
#define SO_KIT_ADD_CATALOG_ENTRY(_part_, _partclass_, _isdefnull_ , _parent_, _sibling_, _ispublic_) \
144
do { \
145
classcatalog->addEntry(SO__QUOTE(_part_), \
146
SoType::fromName(SO__QUOTE(_partclass_)), \
147
SoType::fromName(SO__QUOTE(_partclass_)), \
148
_isdefnull_, \
149
SO__QUOTE(_parent_), \
150
SO__QUOTE(_sibling_), \
151
FALSE, \
152
SoType::badType(), \
153
SoType::badType(), \
154
_ispublic_); \
155
SO_NODE_ADD_FIELD(_part_,(NULL)); \
156
} WHILE_0
157
158
159
160
#define SO_KIT_ADD_CATALOG_LIST_ENTRY(_part_, _containertype_, _isdefnull_, _parent_, _sibling_, _itemtype_, _ispublic_) \
161
do { \
162
classcatalog->addEntry(SO__QUOTE(_part_), \
163
SoNodeKitListPart::getClassTypeId(), \
164
SoNodeKitListPart::getClassTypeId(), \
165
_isdefnull_, \
166
SO__QUOTE(_parent_), \
167
SO__QUOTE(_sibling_), \
168
TRUE, \
169
_containertype_::getClassTypeId(), \
170
_itemtype_::getClassTypeId(), \
171
_ispublic_); \
172
SO_NODE_ADD_FIELD(_part_,(NULL)); \
173
} WHILE_0
174
175
176
177
#define SO_KIT_ADD_CATALOG_ABSTRACT_ENTRY(_part_, _class_, _defaultclass_, _isdefnull_, _parent_, _sibling_, _ispublic_) \
178
do { \
179
classcatalog->addEntry(SO__QUOTE(_part_), \
180
_class_::getClassTypeId(), \
181
_defaultclass_::getClassTypeId(), \
182
_isdefnull_, \
183
SO__QUOTE(_parent_), \
184
SO__QUOTE(_sibling_), \
185
FALSE, \
186
SoType::badType(), \
187
SoType::badType(), \
188
_ispublic_); \
189
SO_NODE_ADD_FIELD(_part_,(NULL)); \
190
} WHILE_0
191
192
193
194
#define SO_KIT_ADD_LIST_ITEM_TYPE(_part_, _listitemtype_) \
195
do { \
196
classcatalog->addListItemType(SO__QUOTE(_part_), \
197
_listitemtype_::getClassTypeId()); \
198
} WHILE_0
199
200
201
#define SO_KIT_INIT_INSTANCE() \
202
this->createFieldList(); \
203
this->createDefaultParts()
204
205
#define SO_KIT_ADD_FIELD(_fieldname_, _defvalue_) \
206
SO_NODE_ADD_FIELD(_fieldname_, _defvalue_)
207
208
// New for Coin-3
209
#define SO_KIT_ADD_EMPTY_MFIELD(_fieldname_) \
210
SO_NODE_ADD_EMPTY_MFIELD(_fieldname_)
211
212
#define SO_KIT_DEFINE_ENUM_VALUE(_enumtype_, _enumvalue_) \
213
SO_NODE_DEFINE_ENUM_VALUE(_enumtype_, _enumvalue_)
214
215
#define SO_KIT_SET_MF_ENUM_TYPE(_fieldname_, _enumtype_) \
216
SO_NODE_SET_MF_ENUM_TYPE(_fieldname_, _enumtype_)
217
218
#define SO_KIT_SET_SF_ENUM_TYPE(_fieldname_, _enumtype_) \
219
SO_NODE_SET_SF_ENUM_TYPE(_fieldname_, _enumtype_)
220
221
#define SO_KIT_CHANGE_ENTRY_TYPE(_part_, _newpartclassname_, _newdefaultpartclassname_) \
222
do { \
223
classcatalog->narrowTypes(SO__QUOTE(_part_), \
224
SoType::fromName(SO__QUOTE(_newpartclassname_)), \
225
SoType::fromName(SO__QUOTE(_newdefaultpartclassname_))); \
226
} WHILE_0
227
228
229
#define SO_KIT_CHANGE_NULL_BY_DEFAULT(_part_, _newnullbydefault_) \
230
do { \
231
classcatalog->setNullByDefault(SO__QUOTE(_part_), _newnullbydefault_); \
232
} WHILE_0
233
234
#endif // !COIN_SOSUBKIT_H
tidbits.h
include
Inventor
nodekits
SoSubKit.h
Generated on Thu Oct 18 2018 20:22:52 for Coin by
doxygen
1.8.14