Coin3D is Free Software,
published under the
BSD 3-clause license
.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoSubElement.h
1
#ifndef COIN_SOSUBELEMENT_H
2
#define COIN_SOSUBELEMENT_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
/*
37
* This file contains macro definitions with common declarations and
38
* definitions used in Coin elements.
39
*
40
* FIXME: document macros and how they are used to set up a new
41
* user-extension skeleton element class (or just point to the example
42
* code in examples/advanced/elements/). 19991209 mortene.
43
*
44
*/
45
46
// *************************************************************************
47
48
#include <Inventor/SbBasic.h>
// for SO__QUOTE() definition
49
#include <Inventor/SbName.h>
50
#include <Inventor/C/tidbits.h>
51
#include <cassert>
52
// Include SoElement.h to be Open Inventor compatible at compile-time.
53
#include <Inventor/elements/SoElement.h>
54
55
// *************************************************************************
56
57
#define SO_ELEMENT_ABSTRACT_HEADER(_class_) \
58
public: \
59
static SoType getClassTypeId(void); \
60
static int getClassStackIndex(void); \
61
protected: \
62
_class_(void); \
63
private: \
64
/* classStackIndex is protected in the OIV UNIX distribution in */
\
65
/* SoSubElement.h and private in the Win32 distribution. Since */
\
66
/* there is a getClassStackIndex() access method, it seems more */
\
67
/* sensible to keep it private. 20000808 mortene. */
\
68
static int classStackIndex; \
69
static SoType classTypeId; \
70
static void cleanupClass(void) { SoType::removeType(_class_::classTypeId.getName()); _class_::classTypeId STATIC_SOTYPE_INIT; }
71
72
// *************************************************************************
73
74
#define SO_ELEMENT_HEADER(_class_) \
75
SO_ELEMENT_ABSTRACT_HEADER(_class_); \
76
public: \
77
static void * createInstance(void)
78
79
// *************************************************************************
80
81
#define PRIVATE_SOELEMENT_VARIABLES(_class_) \
82
int _class_::classStackIndex; \
83
SoType _class_::classTypeId STATIC_SOTYPE_INIT; \
84
\
85
\
89
SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \
90
\
91
\
94
int _class_::getClassStackIndex(void) { return _class_::classStackIndex; }
95
96
97
#define SO_ELEMENT_ABSTRACT_SOURCE(_class_) \
98
PRIVATE_SOELEMENT_VARIABLES(_class_) \
99
_class_::_class_(void) { }
100
101
#define SO_ELEMENT_SOURCE(_class_) \
102
PRIVATE_SOELEMENT_VARIABLES(_class_) \
103
_class_::_class_(void) { this->setTypeId(_class_::classTypeId); \
104
this->setStackIndex(_class_::classStackIndex); } \
105
\
109
void * _class_::createInstance(void) { return new _class_; }
110
111
/*
112
Specific to Coin. Added 2003-10-27.
113
*/
114
#define SO_ELEMENT_CUSTOM_CONSTRUCTOR_SOURCE(_class_) \
115
PRIVATE_SOELEMENT_VARIABLES(_class_) \
116
\
120
void * _class_::createInstance(void) { return new _class_; }
121
122
// *************************************************************************
123
124
#define PRIVATE_SOELEMENT_INIT(_class_, _parent_, _instantiate_) \
125
do { \
126
assert(_class_::classTypeId == SoType::badType()); \
127
assert(_parent_::getClassTypeId() != SoType::badType()); \
128
_class_::classTypeId = SoType::createType(_parent_::getClassTypeId(), \
129
SO__QUOTE(_class_), \
130
_instantiate_); \
131
if (_parent_::getClassStackIndex() < 0) _class_::classStackIndex = _class_::createStackIndex(_class_::classTypeId); \
132
else _class_::classStackIndex = _parent_::getClassStackIndex(); \
133
cc_coin_atexit_static_internal(reinterpret_cast<coin_atexit_f*>(_class_::cleanupClass)); \
134
} WHILE_0
135
136
137
#define SO_ELEMENT_INIT_ABSTRACT_CLASS(_class_, _parent_) \
138
PRIVATE_SOELEMENT_INIT(_class_, _parent_, NULL)
139
140
#define SO_ELEMENT_INIT_CLASS(_class_, _parent_) \
141
PRIVATE_SOELEMENT_INIT(_class_, _parent_, &_class_::createInstance)
142
143
// *************************************************************************
144
145
#endif
// !COIN_SOSUBELEMENT_H
tmp
coin3d-20231204-7424-yacms8
coin-oldercompilers
include
Inventor
elements
SoSubElement.h
Generated on Sun Dec 3 2023 22:40:28 for Coin by
doxygen
1.9.8