1 #ifndef COIN_SOSUBNODEP_H 2 #define COIN_SOSUBNODEP_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 // The macro definitions in this file is used internally by Coin 37 // classes, and mirrors some of the public macros available in 38 // SoSubNode.h with a few modifications so they are suited for the 39 // builtin classes. 40 // 41 // The macros in this file are not made visible for use by the 42 // application programmer. 43 44 #ifndef COIN_INTERNAL 45 #error this is a private header file 46 #endif // !COIN_INTERNAL 47 48 // only internal nodes can use this macro and pass "inherited" as arg #4 49 #define PRIVATE_INTERNAL_COMMON_INIT_CODE(_class_, _classname_, _createfunc_, _parentclass_) \ 50 do { \ 51 /* Make sure we only initialize once. */ \ 52 assert(_class_::classTypeId == SoType::badType() && "don't init() twice!"); \ 53 /* Make sure superclass gets initialized before subclass. */ \ 54 assert(_parentclass_::getClassTypeId() != SoType::badType() && "you forgot init() on parentclass!"); \ 55 \ 56 /* Set up entry in the type system. */ \ 57 _class_::classTypeId = \ 58 SoType::createType(_parentclass_::getClassTypeId(), \ 59 _classname_, \ 60 _createfunc_, \ 61 SoNode::getNextActionMethodIndex()); \ 62 SoNode::incNextActionMethodIndex(); \ 63 \ 64 /* Store parent's fielddata pointer for later use in the constructor. */ \ 65 _class_::parentFieldData = _parentclass_::getFieldDataPtr(); \ 66 cc_coin_atexit_static_internal(reinterpret_cast<coin_atexit_f *>(_class_::atexit_cleanup)); \ 67 } while (0) 68 69 #define SO_NODE_INTERNAL_CONSTRUCTOR(_class_) \ 70 do { \ 71 SoBase::staticDataLock(); \ 72 SO_NODE_CONSTRUCTOR_NOLOCK(_class_); \ 73 /* Restore value of isBuiltIn flag (which is set to FALSE */ \ 74 /* in the SO_NODE_CONSTRUCTOR() macro. */ \ 75 this->isBuiltIn = TRUE; \ 76 SoBase::staticDataUnlock(); \ 77 } while (0) 78 79 80 #define SO_NODE_INTERNAL_INIT_CLASS(_class_, _fileformats_) \ 81 do { \ 82 const char * classname = SO__QUOTE(_class_); \ 83 PRIVATE_INTERNAL_COMMON_INIT_CODE(_class_, &classname[2], &_class_::createInstance, inherited); \ 84 SoNode::setCompatibilityTypes(_class_::getClassTypeId(), _fileformats_); \ 85 } while (0) 86 87 88 #define SO_NODE_INTERNAL_INIT_ABSTRACT_CLASS(_class_, _fileformats_) \ 89 do { \ 90 const char * classname = SO__QUOTE(_class_); \ 91 PRIVATE_INTERNAL_COMMON_INIT_CODE(_class_, &classname[2], NULL, inherited); \ 92 SoNode::setCompatibilityTypes(_class_::getClassTypeId(), _fileformats_); \ 93 } while (0) 94 95 96 // ************************************************************************* 97 98 // Convenience defines to use for the second parameter of the 99 // SO_NODE_INTERNAL_INIT_CLASS() macro (for internal node classes). 100 // 101 // It's is handy to use these defines instead of the enum flags 102 // directly, as these can be updated in this one central location, 103 // instead of having to update all node source files on each new Coin 104 // major release. 105 106 #define SO_FROM_COIN_4_0 \ 107 (SoNode::COIN_4_0) 108 109 #define SO_FROM_COIN_3_0 \ 110 (SoNode::COIN_3_0|SO_FROM_COIN_4_0) 111 112 #define SO_FROM_COIN_2_5 \ 113 (SoNode::COIN_2_5|SO_FROM_COIN_3_0) 114 115 #define SO_FROM_COIN_2_4 \ 116 (SoNode::COIN_2_4|SO_FROM_COIN_2_5) 117 118 #define SO_FROM_COIN_2_3 \ 119 (SoNode::COIN_2_3|SO_FROM_COIN_2_4) 120 121 #define SO_FROM_COIN_2_2 \ 122 (SoNode::COIN_2_2|SO_FROM_COIN_2_3) 123 124 #define SO_FROM_COIN_2_0 \ 125 (SoNode::COIN_2_0|SO_FROM_COIN_2_2) 126 127 #define SO_FROM_COIN_1_0 \ 128 (SoNode::COIN_1_0|SO_FROM_COIN_2_0) 129 130 // ************************************************************************* 131 132 #define SO_FROM_INVENTOR_6_0 \ 133 (SoNode::INVENTOR_6_0) 134 135 #define SO_FROM_INVENTOR_5_0 \ 136 (SoNode::INVENTOR_5_0) 137 138 // Several releases missing in-between here, but we don't seem to have 139 // any nodes from those yet... -mortene. 140 141 #define SO_FROM_INVENTOR_2_6 \ 142 (SoNode::INVENTOR_2_6|SO_FROM_INVENTOR_5_0) 143 144 #define SO_FROM_INVENTOR_2_5 \ 145 (SoNode::INVENTOR_2_5|SO_FROM_INVENTOR_2_6) 146 147 #define SO_FROM_INVENTOR_2_1 \ 148 (SoNode::INVENTOR_2_1|SO_FROM_INVENTOR_2_5|SO_FROM_COIN_1_0) 149 150 #define SO_FROM_INVENTOR_2_0 \ 151 (SoNode::INVENTOR_2_0|SO_FROM_INVENTOR_2_1) 152 153 #define SO_FROM_INVENTOR_1 \ 154 (SoNode::INVENTOR_1|SO_FROM_INVENTOR_2_0) 155 156 // ************************************************************************* 157 158 #endif // !COIN_SOSUBNODEP_H 159