| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 | * |
| 40 | _______________________________________________________________________ |
| 41 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 | | |
| 43 | | $Revision: 1.1.1.1 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoUpgrader |
| 47 | | |
| 48 | | Author(s) : Gavin Bell |
| 49 | | |
| 50 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 | _______________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | #include <assert.h> |
| 55 | #include <Inventor/SoInput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoInput.h`/ |
| 56 | #include <Inventor/SbDict.h>cxx . . $ `<file>/lib/database/include/Inventor/SbDict.h`/ |
| 57 | #include <Inventor/misc/upgraders/SoUpgrader.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/upgraders/SoUpgrader.h`/ |
| 58 | |
| 59 | SO_NODE_ABSTRACT_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:245:9`!(SoUpgrader); |
| 60 | |
| 61 | // Static variables: |
| 62 | SbDictcxx . . $ SbDict# *SoUpgradercxx . . $ SoUpgrader#::upgradeDictV1cxx . . $ SoUpgrader#upgradeDictV1. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 63 | SbDictcxx . . $ SbDict# *SoUpgradercxx . . $ SoUpgrader#::upgradeDictV2cxx . . $ SoUpgrader#upgradeDictV2. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 64 | |
| 65 | //////////////////////////////////////////////////////////////////////// |
| 66 | // |
| 67 | // Description: |
| 68 | // Constructor |
| 69 | // |
| 70 | // Use: public |
| 71 | |
| 72 | SoUpgradercxx . . $ SoUpgrader#::SoUpgradercxx . . $ SoUpgrader#SoUpgrader(49f6e7a06ebc5aa8).() |
| 73 | // |
| 74 | //////////////////////////////////////////////////////////////////////// |
| 75 | { |
| 76 | SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoUpgrader); |
| 77 | |
| 78 | isGroupcxx . . $ SoUpgrader#isGroup. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 79 | } |
| 80 | |
| 81 | //////////////////////////////////////////////////////////////////////// |
| 82 | // |
| 83 | // Description: |
| 84 | // Destructor |
| 85 | // |
| 86 | // Use: private |
| 87 | |
| 88 | SoUpgradercxx . . $ SoUpgrader#::~cxx . . $ SoUpgrader#`~SoUpgrader`(49f6e7a06ebc5aa8).SoUpgradercxx . . $ SoUpgrader#() |
| 89 | // |
| 90 | //////////////////////////////////////////////////////////////////////// |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | //////////////////////////////////////////////////////////////////////// |
| 95 | // |
| 96 | // Return either the V1.0 or V2.0 dictionary |
| 97 | // |
| 98 | SbDictcxx . . $ SbDict# * |
| 99 | SoUpgradercxx . . $ SoUpgrader#::getUpgradeDictcxx . . $ SoUpgrader#getUpgradeDict(c1cadfa6032beada).(float version) |
| 100 | // |
| 101 | //////////////////////////////////////////////////////////////////////// |
| 102 | { |
| 103 | SbDictcxx . . $ SbDict# *upgradeDict = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 104 | if (version == 1.0) |
| 105 | upgradeDict = upgradeDictV1cxx . . $ SoUpgrader#upgradeDictV1.; |
| 106 | else if (version == 2.0) |
| 107 | upgradeDict = upgradeDictV2cxx . . $ SoUpgrader#upgradeDictV2.; |
| 108 | |
| 109 | return upgradeDict; |
| 110 | } |
| 111 | |
| 112 | //////////////////////////////////////////////////////////////////////// |
| 113 | // |
| 114 | // Description: |
| 115 | // Register a converter with the converter dictionary. |
| 116 | // |
| 117 | // Use: protected, static |
| 118 | |
| 119 | void |
| 120 | SoUpgradercxx . . $ SoUpgrader#::registerUpgradercxx . . $ SoUpgrader#registerUpgrader(731570c13392d3f).(const SoTypecxx . . $ SoType# &type, const SbNamecxx . . $ SbName# &className, |
| 121 | float version) |
| 122 | // |
| 123 | //////////////////////////////////////////////////////////////////////// |
| 124 | { |
| 125 | const char *str = className.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(); |
| 126 | |
| 127 | #ifdef DEBUG |
| 128 | // There are 1.0 and 2.0 upgraders right now... |
| 129 | if (version != 1.0 && version != 2.0) { |
| 130 | SoDebugError::post("SoUpgrader::register", "Cannot handle " |
| 131 | "converters from version %f, can only " |
| 132 | "handle converters from version 1.0 or 2.0", |
| 133 | version); |
| 134 | } |
| 135 | #endif |
| 136 | |
| 137 | SbDictcxx . . $ SbDict# *upgradeDict = getUpgradeDictcxx . . $ SoUpgrader#getUpgradeDict(c1cadfa6032beada).(version); |
| 138 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(upgradeDict != NULL); |
| 139 | |
| 140 | #ifdef DEBUG |
| 141 | void *t; |
| 142 | if (upgradeDict->find((unsigned long)str, t) != 0) { |
| 143 | SoDebugError::post("SoUpgrader::register", "Upgrader already " |
| 144 | "registered for class %s", str); |
| 145 | } |
| 146 | #endif |
| 147 | |
| 148 | upgradeDict->entercxx . . $ SbDict#enter(9b3d2d56e494888).((unsigned long)str, (void *)&type); |
| 149 | } |
| 150 | |
| 151 | //////////////////////////////////////////////////////////////////////// |
| 152 | // |
| 153 | // Description: |
| 154 | // Looks in the dictionary to figure out if a converter exists... |
| 155 | // |
| 156 | // Use: public, static |
| 157 | |
| 158 | SoUpgradercxx . . $ SoUpgrader# * |
| 159 | SoUpgradercxx . . $ SoUpgrader#::getUpgradercxx . . $ SoUpgrader#getUpgrader(a61b1fdfb87b2247).(const SbNamecxx . . $ SbName# &className, float version) |
| 160 | // |
| 161 | //////////////////////////////////////////////////////////////////////// |
| 162 | { |
| 163 | // There are 1.0 and 2.0 upgraders right now... |
| 164 | if (version != 1.0 && version != 2.0) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 165 | |
| 166 | // Look in dictionary for converter type: |
| 167 | void *t; |
| 168 | if (! getUpgradeDictcxx . . $ SoUpgrader#getUpgradeDict(c1cadfa6032beada).(version)->findcxx . . $ SbDict#find(a750591cf51bff5e).((unsigned long) className.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(), t)) |
| 169 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 170 | |
| 171 | SoTypecxx . . $ SoType# *type = (SoTypecxx . . $ SoType# *) t; |
| 172 | |
| 173 | return (SoUpgradercxx . . $ SoUpgrader# *)type->createInstancecxx . . $ SoType#createInstance(45a5c5ac6be858a8).(); |
| 174 | } |
| 175 | |
| 176 | //////////////////////////////////////////////////////////////////////// |
| 177 | // |
| 178 | // Description: |
| 179 | // Does the grunt work of reading in the old node-- relies on |
| 180 | // createNewNode() to actually create a node or scene graph that |
| 181 | // can be added to the scene. Returns TRUE if everything was |
| 182 | // successful. |
| 183 | // |
| 184 | // Use: extender, virtual |
| 185 | |
| 186 | SbBoolcxx . . $ SbBool# |
| 187 | SoUpgradercxx . . $ SoUpgrader#::upgradecxx . . $ SoUpgrader#upgrade(2025cb8b3a26f0e3).(SoInputcxx . . $ SoInput# *in, const SbNamecxx . . $ SbName# &refName, SoBasecxx . . $ SoBase# *&result) |
| 188 | // |
| 189 | //////////////////////////////////////////////////////////////////////// |
| 190 | { |
| 191 | SbBoolcxx . . $ SbBool# returnValue = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 192 | |
| 193 | // Read in fields: |
| 194 | const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoUpgrader#getFieldData(56e90abbfb485471).(); |
| 195 | SbBoolcxx . . $ SbBool# notBuiltIn; // Not used |
| 196 | if (! fieldData->readcxx . . $ SoFieldData#read(cc8228a617223129).(in, this, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!, notBuiltIn)) |
| 197 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 198 | |
| 199 | // Create instance: |
| 200 | result = createNewNodecxx . . $ SoUpgrader#createNewNode(37b0c20759e6fed3).(); |
| 201 | |
| 202 | // Oops, something wrong... |
| 203 | if (result == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 204 | |
| 205 | // Add to name dictionary: |
| 206 | if (! (!cxx . . $ SbName#`operator!`(455f465bc33b4cdf).refName)) |
| 207 | in->addReferencecxx . . $ SoInput#addReference(57b533c9263574b3).(refName, result); |
| 208 | |
| 209 | // And read children, if node being upgraded is derived from group: |
| 210 | if (isGroupcxx . . $ SoUpgrader#isGroup. && result->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).(SoGroupcxx . . $ SoGroup#::getClassTypeIdcxx . . $ SoGroup#getClassTypeId(c00c150378d2b968).())) { |
| 211 | returnValue = readChildrencxx . . $ SoGroup#readChildren(cfb31f743f00c8ca).(in); |
| 212 | if (returnValue) { |
| 213 | |
| 214 | SoGroupcxx . . $ SoGroup# *g = (SoGroupcxx . . $ SoGroup# *)result; |
| 215 | |
| 216 | // Turn off notification on result while we set it up: |
| 217 | SbBoolcxx . . $ SbBool# notifySave = g->enableNotifycxx . . $ SoFieldContainer#enableNotify(7864480464b09eea).(FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 218 | |
| 219 | for (int i = 0; i < getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++) { |
| 220 | g->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i)); |
| 221 | } |
| 222 | |
| 223 | // Re-enable notification. |
| 224 | g->enableNotifycxx . . $ SoFieldContainer#enableNotify(7864480464b09eea).(notifySave); |
| 225 | } |
| 226 | // No need to remove children, we're about to be unreffed |
| 227 | // anyway (by SoBase::readBaseInstance). |
| 228 | } |
| 229 | |
| 230 | return returnValue; |
| 231 | } |