Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoSubEvent.h
1#ifndef COIN_SOSUBEVENT_H
2#define COIN_SOSUBEVENT_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/C/tidbits.h>
37
38// *************************************************************************
39
40#define SO_EVENT_HEADER() \
41private: \
42 static SoType classTypeId; \
43
45 \
46 static void cleanupClass(void) { classTypeId STATIC_SOTYPE_INIT; }; \
47 static void * createInstance(void); \
48public: \
49 static SoType getClassTypeId(void); \
50 virtual SoType getTypeId(void) const
51
52#define SO_EVENT_ABSTRACT_HEADER() \
53private: \
54 static SoType classTypeId; \
55
57 \
58 static void cleanupClass(void) { classTypeId STATIC_SOTYPE_INIT; }; \
59public: \
60 static SoType getClassTypeId(void); \
61 virtual SoType getTypeId(void) const
62
63// *************************************************************************
64
65#define SO_EVENT_ABSTRACT_SOURCE(_class_) \
66 \
67
70 \
71SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \
72 \
73
77 \
78SoType _class_::getTypeId(void) const { return _class_::classTypeId; } \
79SoType _class_::classTypeId STATIC_SOTYPE_INIT
80
81#define SO_EVENT_SOURCE(_class_) \
82 \
83
86 \
87SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \
88 \
89
93 \
94SoType _class_::getTypeId(void) const { return _class_::classTypeId; } \
95
98 \
99void * _class_::createInstance(void) { return new _class_; } \
100SoType _class_::classTypeId STATIC_SOTYPE_INIT
101
102// *************************************************************************
103
104#define SO_EVENT_INIT_ABSTRACT_CLASS(_class_, _parentclass_) \
105 do { \
106 /* Make sure we only initialize once. */ \
107 assert(_class_::classTypeId == SoType::badType()); \
108 /* Make sure superclass get initialized before subclass. */ \
109 assert(_parentclass_::getClassTypeId() != SoType::badType()); \
110 \
111 _class_::classTypeId = \
112 SoType::createType(_parentclass_::getClassTypeId(), SO__QUOTE(_class_)); \
113 /* FIXME: internal code should not use this function, but use the coin_atexit() function */ \
114 /* with priority set to CC_ATEXIT_NORMAL. As it is now, the clean-up functions for */ \
115 /* these classes will always be run before all other Coin at-exit clean-ups. 20070126 mortene */ \
116 cc_coin_atexit(reinterpret_cast<coin_atexit_f *>(cleanupClass)); \
117 } WHILE_0
118
119#define SO_EVENT_INIT_CLASS(_class_, _parentclass_) \
120 do { \
121 /* Make sure we only initialize once. */ \
122 assert(_class_::classTypeId == SoType::badType()); \
123 /* Make sure superclass get initialized before subclass. */ \
124 assert(_parentclass_::getClassTypeId() != SoType::badType()); \
125 \
126 _class_::classTypeId = \
127 SoType::createType(_parentclass_::getClassTypeId(), SO__QUOTE(_class_), _class_::createInstance); \
128 /* FIXME: internal code should not use this function, but use the coin_atexit() function */ \
129 /* with priority set to CC_ATEXIT_NORMAL. As it is now, the clean-up functions for */ \
130 /* these classes will always be run before all other Coin at-exit clean-ups. 20070126 mortene */ \
131 cc_coin_atexit(reinterpret_cast<coin_atexit_f *>(cleanupClass)); \
132 } WHILE_0
133
134// *************************************************************************
135
136#endif // !COIN_SOSUBEVENT_H