| 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,92 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 | | SoGlobalField |
| 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 | ////////////////////////////////////////////////////////////////////////////// |
| 55 | // |
| 56 | // Class: SoGlobalField |
| 57 | // |
| 58 | // There is an instance of this class for every global field |
| 59 | // created. This class also maintains the dictionary associating |
| 60 | // global field names with global field containers. |
| 61 | // |
| 62 | // This entire class is private. |
| 63 | // |
| 64 | ////////////////////////////////////////////////////////////////////////////// |
| 65 | |
| 66 | #include <Inventor/errors/SoDebugError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoDebugError.h`/ |
| 67 | #include <Inventor/errors/SoReadError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoReadError.h`/ |
| 68 | #include "SoGlobalField.h"cxx . . $ `<file>/lib/database/src/so/fields/SoGlobalField.h`/ |
| 69 | |
| 70 | // SbName to SoGlobalField* dictionary. Keyed by the name. |
| 71 | SbDictcxx . . $ SbDict# *SoGlobalFieldcxx . . $ SoGlobalField#::nameDictcxx . . $ SoGlobalField#nameDict.; |
| 72 | |
| 73 | // The GlobalFieldContainer type (the name is simply GlobalField) |
| 74 | SoTypecxx . . $ SoType# SoGlobalFieldcxx . . $ SoGlobalField#::classTypeIdcxx . . $ SoGlobalField#classTypeId.; |
| 75 | |
| 76 | ////////////////////////////////////////////////////////////////////////////// |
| 77 | // |
| 78 | // Description: |
| 79 | // Setup type information. Called by SoDB::init() |
| 80 | // |
| 81 | // Use: internal |
| 82 | |
| 83 | void |
| 84 | SoGlobalFieldcxx . . $ SoGlobalField#::initClasscxx . . $ SoGlobalField#initClass(49f6e7a06ebc5aa8).() |
| 85 | // |
| 86 | ////////////////////////////////////////////////////////////////////////////// |
| 87 | { |
| 88 | classTypeIdcxx . . $ SoGlobalField#classTypeId. =cxx . . $ SoType#`operator=`(b492e65b06badd05). SoTypecxx . . $ SoType#::createTypecxx . . $ SoType#createType(66a643b20efb0062).(SoFieldContainercxx . . $ SoFieldContainer#::getClassTypeIdcxx . . $ SoFieldContainer#getClassTypeId(c00c150378d2b968).(), |
| 89 | "GlobalField"cxx . . $ SbName#SbName(78e67776a82c5be1)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 90 | nameDictcxx . . $ SoGlobalField#nameDict. = new SbDictcxx . . $ SbDict#SbDict(d4f767463ce0a6b3).(20); // Assume small number of global fields |
| 91 | } |
| 92 | |
| 93 | ////////////////////////////////////////////////////////////////////////////// |
| 94 | // |
| 95 | // Description: |
| 96 | // This either creates a new globalField (if name hasn't been found |
| 97 | // before) or returns the globalField with the given name and type. |
| 98 | // It will return NULL if there is an error. "alreadyExists" will be |
| 99 | // set to TRUE if a global field of the same name and type already |
| 100 | // exists. |
| 101 | // |
| 102 | // Use: internal |
| 103 | |
| 104 | SoGlobalFieldcxx . . $ SoGlobalField# * |
| 105 | SoGlobalFieldcxx . . $ SoGlobalField#::createcxx . . $ SoGlobalField#create(3c4b190a35f7fc8a).(const SbNamecxx . . $ SbName# &name, SoTypecxx . . $ SoType# type, SbBoolcxx . . $ SbBool# &alreadyExists) |
| 106 | // |
| 107 | ////////////////////////////////////////////////////////////////////////////// |
| 108 | { |
| 109 | // Look for an existing field of the same name/type: |
| 110 | SoGlobalFieldcxx . . $ SoGlobalField# *result = SoGlobalFieldcxx . . $ SoGlobalField#::findcxx . . $ SoGlobalField#find(ed4497bb7a61ae73).(name); |
| 111 | if (result != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 112 | if (! result->getTypecxx . . $ SoGlobalField#getType(70775439ff16cb15).().isDerivedFromcxx . . $ SoType#isDerivedFrom(1fd66475a268b64e).(type)) { |
| 113 | const char *resName = result->getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(); |
| 114 | const char *resTypeName = result->getTypecxx . . $ SoGlobalField#getType(70775439ff16cb15).().getNamecxx . . $ SoType#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(); |
| 115 | SoDebugErrorcxx . . $ SoDebugError#::postcxx . . $ SoDebugError#post(fb6d009da02ec724).("SoGlobalField::create", |
| 116 | "Global field %s has two types (%s, %s)", |
| 117 | resName, resTypeName, |
| 118 | type.getNamecxx . . $ SoType#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 119 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 120 | } |
| 121 | else { |
| 122 | alreadyExists = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 123 | return result; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | alreadyExists = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 128 | |
| 129 | // Make sure field is a proper field type |
| 130 | |
| 131 | if (! type.isDerivedFromcxx . . $ SoType#isDerivedFrom(1fd66475a268b64e).(SoFieldcxx . . $ SoField#::getClassTypeIdcxx . . $ SoField#getClassTypeId(c00c150378d2b968).())) { |
| 132 | const char *resName = result->getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(); |
| 133 | SoDebugErrorcxx . . $ SoDebugError#::postcxx . . $ SoDebugError#post(fb6d009da02ec724).("SoGlobalField::create", |
| 134 | "(field %s) Type %s is not a field type", |
| 135 | resName, type.getNamecxx . . $ SoType#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 136 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 137 | } |
| 138 | SoFieldcxx . . $ SoField# *field = (SoFieldcxx . . $ SoField# *)type.createInstancecxx . . $ SoType#createInstance(45a5c5ac6be858a8).(); |
| 139 | |
| 140 | // Make sure it isn't an abstract field type... |
| 141 | |
| 142 | if (field == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 143 | const char *typeName = type.getNamecxx . . $ SoType#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(); |
| 144 | SoDebugErrorcxx . . $ SoDebugError#::postcxx . . $ SoDebugError#post(fb6d009da02ec724).("SoGlobalField::create", |
| 145 | "Cannot create field %s of type %s", |
| 146 | name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(), typeName); |
| 147 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 148 | } |
| 149 | |
| 150 | return new SoGlobalFieldcxx . . $ SoGlobalField#(name, field); |
| 151 | } |
| 152 | |
| 153 | ////////////////////////////////////////////////////////////////////////////// |
| 154 | // |
| 155 | // Description: |
| 156 | // GlobalField constructor. It creates a globalField, given the name |
| 157 | // of the field and a pointer to the field to use. This is private; |
| 158 | // the create() method is the public interface to creating new global |
| 159 | // fields. |
| 160 | // |
| 161 | // Use: private |
| 162 | |
| 163 | SoGlobalFieldcxx . . $ SoGlobalField#::SoGlobalFieldcxx . . $ SoGlobalField#SoGlobalField(a43693cb395358d7).(const SbNamecxx . . $ SbName# &name, SoFieldcxx . . $ SoField# *field) |
| 164 | // |
| 165 | ////////////////////////////////////////////////////////////////////////////// |
| 166 | { |
| 167 | typeFieldcxx . . $ SoGlobalField#typeField..setValuecxx . . $ SoSFName#setValue(78e67776a82c5be1).(field->getTypeIdcxx . . $ SoField#getTypeId(70775439ff16cb15).().getNamecxx . . $ SoType#getName(a4a84af177c3b6e7).()); |
| 168 | valuecxx . . $ SoGlobalField#value. = field; |
| 169 | #ifdef DEBUG |
| 170 | if (field->getContainer()) |
| 171 | SoDebugError::post("SoGlobalField::SoGlobalField", |
| 172 | "Field already has container!"); |
| 173 | |
| 174 | #endif /* DEBUG */ |
| 175 | field->setContainercxx . . $ SoField#setContainer(1c5659d1d94c054f).(this); |
| 176 | field->setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 177 | |
| 178 | unsigned long key = (unsigned long)(name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 179 | #ifdef DEBUG |
| 180 | void *junk; |
| 181 | if (nameDict->find(key, junk) != FALSE) |
| 182 | SoDebugError::post("SoGlobalField::SoGlobalField", |
| 183 | "There is already a global field named %s", |
| 184 | name.getString()); |
| 185 | #endif |
| 186 | nameDictcxx . . $ SoGlobalField#nameDict.->entercxx . . $ SbDict#enter(9b3d2d56e494888).(key, this); |
| 187 | |
| 188 | fieldDatacxx . . $ SoGlobalField#fieldData. = new SoFieldDatacxx . . $ SoFieldData#SoFieldData(49f6e7a06ebc5aa8).; |
| 189 | fieldDatacxx . . $ SoGlobalField#fieldData.->addFieldcxx . . $ SoFieldData#addField(62ec4b1f920ec561).(this, name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(), field); |
| 190 | |
| 191 | refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 192 | } |
| 193 | |
| 194 | ////////////////////////////////////////////////////////////////////////////// |
| 195 | // |
| 196 | // Description: |
| 197 | // Destructor. It is responsible for deleting the globalField from |
| 198 | // the dictionary. |
| 199 | // |
| 200 | // Use: private |
| 201 | |
| 202 | SoGlobalFieldcxx . . $ SoGlobalField#::~cxx . . $ SoGlobalField#`~SoGlobalField`(49f6e7a06ebc5aa8).SoGlobalFieldcxx . . $ SoGlobalField#() |
| 203 | // |
| 204 | ////////////////////////////////////////////////////////////////////////////// |
| 205 | |
| 206 | { |
| 207 | // If fieldData is NULL, don't delete the entry. This happens only |
| 208 | // for the "dummy" instance that is created to read in a real |
| 209 | // instance of a global field. |
| 210 | if (fieldDatacxx . . $ SoGlobalField#fieldData. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 211 | return; |
| 212 | |
| 213 | unsigned long key = (unsigned long)(getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 214 | nameDictcxx . . $ SoGlobalField#nameDict.->removecxx . . $ SbDict#remove(15f694ef3c96d230).(key); |
| 215 | |
| 216 | delete valuecxx . . $ SoGlobalField#value.; |
| 217 | } |
| 218 | |
| 219 | ////////////////////////////////////////////////////////////////////////////// |
| 220 | // |
| 221 | // Description: |
| 222 | // Find a globalField with the given name in the dictionary. Returns |
| 223 | // NULL if it there is none. |
| 224 | // |
| 225 | // Use: internal |
| 226 | |
| 227 | SoGlobalFieldcxx . . $ SoGlobalField# * |
| 228 | SoGlobalFieldcxx . . $ SoGlobalField#::findcxx . . $ SoGlobalField#find(ed4497bb7a61ae73).(const SbNamecxx . . $ SbName# &name) |
| 229 | // |
| 230 | ////////////////////////////////////////////////////////////////////////////// |
| 231 | { |
| 232 | unsigned long key = (unsigned long)(name.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 233 | void *result; |
| 234 | if (nameDictcxx . . $ SoGlobalField#nameDict.->findcxx . . $ SbDict#find(a750591cf51bff5e).(key, result) == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 235 | return (SoGlobalFieldcxx . . $ SoGlobalField# *)result; |
| 236 | } |
| 237 | |
| 238 | ////////////////////////////////////////////////////////////////////////////// |
| 239 | // |
| 240 | // Description: |
| 241 | // Change the name of a global field. |
| 242 | // |
| 243 | // Use: internal |
| 244 | |
| 245 | void |
| 246 | SoGlobalFieldcxx . . $ SoGlobalField#::changeNamecxx . . $ SoGlobalField#changeName(78e67776a82c5be1).(const SbNamecxx . . $ SbName# &newName) |
| 247 | // |
| 248 | ////////////////////////////////////////////////////////////////////////////// |
| 249 | |
| 250 | { |
| 251 | // Remove old entry from dictionary |
| 252 | unsigned long key = (unsigned long)(getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 253 | nameDictcxx . . $ SoGlobalField#nameDict.->removecxx . . $ SbDict#remove(15f694ef3c96d230).(key); |
| 254 | |
| 255 | // Create a new fieldData with the correct name for the field: |
| 256 | SoFieldcxx . . $ SoField# *field = valuecxx . . $ SoGlobalField#value.; |
| 257 | delete fieldDatacxx . . $ SoGlobalField#fieldData.; |
| 258 | fieldDatacxx . . $ SoGlobalField#fieldData. = new SoFieldDatacxx . . $ SoFieldData#SoFieldData(49f6e7a06ebc5aa8).; |
| 259 | fieldDatacxx . . $ SoGlobalField#fieldData.->addFieldcxx . . $ SoFieldData#addField(62ec4b1f920ec561).(this, newName.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).(), field); |
| 260 | key = (unsigned long)(getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).().getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 261 | |
| 262 | // If there is already an entry with the new name... |
| 263 | void *oldGlobalField; |
| 264 | if (nameDictcxx . . $ SoGlobalField#nameDict.->findcxx . . $ SbDict#find(a750591cf51bff5e).(key, oldGlobalField) == TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!) { |
| 265 | // Delete the old one |
| 266 | ((SoGlobalFieldcxx . . $ SoGlobalField# *)oldGlobalField)->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).(); |
| 267 | nameDictcxx . . $ SoGlobalField#nameDict.->removecxx . . $ SbDict#remove(15f694ef3c96d230).(key); |
| 268 | } |
| 269 | |
| 270 | // Enter this node under the new name |
| 271 | nameDictcxx . . $ SoGlobalField#nameDict.->entercxx . . $ SbDict#enter(9b3d2d56e494888).(key, this); |
| 272 | } |
| 273 | |
| 274 | ////////////////////////////////////////////////////////////////////////////// |
| 275 | // |
| 276 | // Description: |
| 277 | // This is a virtual function used by the database so notification and |
| 278 | // field to field connections work. The fieldData for globalFields |
| 279 | // contains only the value field; the other are hidden from the |
| 280 | // database and are used only when reading or writing. |
| 281 | // |
| 282 | |
| 283 | const SoFieldDatacxx . . $ SoFieldData# * |
| 284 | SoGlobalFieldcxx . . $ SoGlobalField#::getFieldDatacxx . . $ SoGlobalField#getFieldData(56e90abbfb485471).() const |
| 285 | // |
| 286 | ////////////////////////////////////////////////////////////////////////////// |
| 287 | { |
| 288 | return fieldDatacxx . . $ SoGlobalField#fieldData.; |
| 289 | } |
| 290 | |
| 291 | ////////////////////////////////////////////////////////////////////////////// |
| 292 | // |
| 293 | // Description: |
| 294 | // Returns typeid. |
| 295 | // |
| 296 | // Use: internal |
| 297 | // |
| 298 | SoTypecxx . . $ SoType# |
| 299 | SoGlobalFieldcxx . . $ SoGlobalField#::getTypeIdcxx . . $ SoGlobalField#getTypeId(70775439ff16cb15).() const |
| 300 | // |
| 301 | ////////////////////////////////////////////////////////////////////////////// |
| 302 | { |
| 303 | return classTypeIdcxx . . $ SoGlobalField#classTypeId.; |
| 304 | } |
| 305 | |
| 306 | ////////////////////////////////////////////////////////////////////////////// |
| 307 | // |
| 308 | // Description: |
| 309 | // Write out an instance of a GlobalField. |
| 310 | // Called by SoBase::write() during a writeAction. |
| 311 | // |
| 312 | // Use: internal |
| 313 | |
| 314 | void |
| 315 | SoGlobalFieldcxx . . $ SoGlobalField#::writeInstancecxx . . $ SoGlobalField#writeInstance(46d85c4d426f339d).(SoOutputcxx . . $ SoOutput# *out) |
| 316 | // |
| 317 | ////////////////////////////////////////////////////////////////////////////// |
| 318 | { |
| 319 | if (! writeHeadercxx . . $ SoBase#writeHeader(9b3bdbd0ec77c6f4).(out, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!)) { |
| 320 | typeFieldcxx . . $ SoGlobalField#typeField..writecxx . . $ SoField#write(5afc3f6978105403).(out, "type"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 321 | valuecxx . . $ SoGlobalField#value.->writecxx . . $ SoField#write(5afc3f6978105403).(out, getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).()); |
| 322 | writeFootercxx . . $ SoBase#writeFooter(58762e0f79576b7c).(out); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | ////////////////////////////////////////////////////////////////////////////// |
| 327 | // |
| 328 | // Description: |
| 329 | // Special method used by SoBase::read to read in a global field. |
| 330 | // The regular reading method can't be used because there can be |
| 331 | // only one global field with a given name, so SoBase can't just |
| 332 | // immediately create a new instance when it reads the |
| 333 | // "GlobalField {" string from the file. So, it calls this |
| 334 | // routine instead. This returns NULL if there was a read error. |
| 335 | // |
| 336 | // Use: internal, static |
| 337 | |
| 338 | SoGlobalFieldcxx . . $ SoGlobalField# * |
| 339 | SoGlobalFieldcxx . . $ SoGlobalField#::readcxx . . $ SoGlobalField#read(48e4bf6ca0a29779).(SoInputcxx . . $ SoInput# *in) |
| 340 | // |
| 341 | ////////////////////////////////////////////////////////////////////////////// |
| 342 | { |
| 343 | // Read in "type SFFloat": |
| 344 | SbNamecxx . . $ SbName# typeNamecxx . . $ SbName#SbName(49f6e7a06ebc5aa8).; |
| 345 | if (!in->readcxx . . $ SoInput#read(9a8a621633966675).(typeName, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!) || typeName !=cxx . . $ `operator!=`(edde533be586f7a2). SbNamecxx . . $ SbName#SbName(85c52e162fed56f9).("type")) |
| 346 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 347 | |
| 348 | // Read the value of this private "type" field, which is the name |
| 349 | // of this globalField. It has to be read as a field, since that's |
| 350 | // how it's written. (The binary version depends on this!) |
| 351 | SoSFNamecxx . . $ SoSFName# typeFieldcxx . . $ SoSFName#SoSFName(49f6e7a06ebc5aa8).; |
| 352 | if (! typeField.readcxx . . $ SoField#read(82f62b5975549baa).(in, "type"cxx . . $ SbName#SbName(85c52e162fed56f9).)) |
| 353 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 354 | typeName =cxx . . $ SbName#`operator=`(8da52b6fc1e0f7c6). typeField.getValuecxx . . $ SoSFName#getValue(96f83ea34e3884f5).(); |
| 355 | |
| 356 | SoTypecxx . . $ SoType# type = SoTypecxx . . $ SoType#::fromNamecxx . . $ SoType#fromName(9c5a3237ca15d417).(typeNamecxx . . $ SbName#SbName(78e67776a82c5be1).); |
| 357 | if (! type.isDerivedFromcxx . . $ SoType#isDerivedFrom(1fd66475a268b64e).(SoFieldcxx . . $ SoField#::getClassTypeIdcxx . . $ SoField#getClassTypeId(c00c150378d2b968).())) { |
| 358 | SoReadErrorcxx . . $ SoReadError#::postcxx . . $ SoReadError#post(a08c53ae8c2fb13c).(in, "\"%s\" is not a type of field", |
| 359 | typeName.getStringcxx . . $ SbName#getString(a9f41ea0e82d88cf).()); |
| 360 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 361 | } |
| 362 | |
| 363 | // Now, get the name of the next field, which is the name of this |
| 364 | // globalField: |
| 365 | SbNamecxx . . $ SbName# myNamecxx . . $ SbName#SbName(49f6e7a06ebc5aa8).; |
| 366 | if (! in->readcxx . . $ SoInput#read(9a8a621633966675).(myName)) |
| 367 | return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 368 | |
| 369 | // Try to create/get an appropriate global field: |
| 370 | SbBoolcxx . . $ SbBool# alreadyExists; |
| 371 | SoGlobalFieldcxx . . $ SoGlobalField# *result = createcxx . . $ SoGlobalField#create(3c4b190a35f7fc8a).(myName, type, alreadyExists); |
| 372 | |
| 373 | // If there already was one with the same name and a different type |
| 374 | if (result == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 375 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 376 | |
| 377 | if (alreadyExists) { |
| 378 | // We need to read and throw away the value... |
| 379 | SoFieldcxx . . $ SoField# *t = (SoFieldcxx . . $ SoField# *)type.createInstancecxx . . $ SoType#createInstance(45a5c5ac6be858a8).(); |
| 380 | // If the field has connections, it needs to have a non-NULL |
| 381 | // container... |
| 382 | t->setContainercxx . . $ SoField#setContainer(1c5659d1d94c054f).(result); |
| 383 | t->enableNotifycxx . . $ SoField#enableNotify(7864480464b09eea).(FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 384 | if (!t->readcxx . . $ SoField#read(82f62b5975549baa).(in, myName)) { |
| 385 | delete result; |
| 386 | delete t; |
| 387 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 388 | } |
| 389 | // Get rid of any connections that may have been established-- |
| 390 | // this gets rid of any extraneous auditors. |
| 391 | t->disconnectcxx . . $ SoField#disconnect(49f6e7a06ebc5aa8).(); |
| 392 | delete t; |
| 393 | } |
| 394 | else { |
| 395 | // Read into newly-created global field. |
| 396 | if (!result->valuecxx . . $ SoGlobalField#value.->readcxx . . $ SoField#read(82f62b5975549baa).(in, myName)) { |
| 397 | // Problem reading value field |
| 398 | delete result; |
| 399 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 400 | } |
| 401 | } |
| 402 | return result; |
| 403 | } |
| 404 | |
| 405 | ////////////////////////////////////////////////////////////////////////////// |
| 406 | // |
| 407 | // Description: |
| 408 | // Return the field this is a container for: |
| 409 | // |
| 410 | // Use: internal |
| 411 | |
| 412 | SoFieldcxx . . $ SoField# * |
| 413 | SoGlobalFieldcxx . . $ SoGlobalField#::getMyFieldcxx . . $ SoGlobalField#getMyField(c4a4d937024b6702).() const |
| 414 | // |
| 415 | ////////////////////////////////////////////////////////////////////////////// |
| 416 | { |
| 417 | return valuecxx . . $ SoGlobalField#value.; |
| 418 | } |
| 419 | |
| 420 | ////////////////////////////////////////////////////////////////////////////// |
| 421 | // |
| 422 | // Description: |
| 423 | // Return the name of this global field. |
| 424 | // |
| 425 | // Use: internal |
| 426 | |
| 427 | SbNamecxx . . $ SbName# |
| 428 | SoGlobalFieldcxx . . $ SoGlobalField#::getNamecxx . . $ SoGlobalField#getName(a4a84af177c3b6e7).() const |
| 429 | // |
| 430 | ////////////////////////////////////////////////////////////////////////////// |
| 431 | { |
| 432 | return fieldDatacxx . . $ SbName#SbName(78e67776a82c5be1).->getFieldNamecxx . . $ SoFieldData#getFieldName(e603ed4d11f0a676).(0); |
| 433 | } |
| 434 | |
| 435 | ////////////////////////////////////////////////////////////////////////////// |
| 436 | // |
| 437 | // Description: |
| 438 | // A handy utility routine that saved some typing |
| 439 | // |
| 440 | // Use: private |
| 441 | |
| 442 | SoTypecxx . . $ SoType# |
| 443 | SoGlobalFieldcxx . . $ SoGlobalField#::getTypecxx . . $ SoGlobalField#getType(70775439ff16cb15).() const |
| 444 | // |
| 445 | ////////////////////////////////////////////////////////////////////////////// |
| 446 | { |
| 447 | return SoTypecxx . . $ SoType#::fromNamecxx . . $ SoType#fromName(9c5a3237ca15d417).(typeFieldcxx . . $ SbName#SbName(78e67776a82c5be1)..getValuecxx . . $ SoSFName#getValue(96f83ea34e3884f5).()); |
| 448 | } |
| 449 | |
| 450 | //////////////////////////////////////////////////////////////////////// |
| 451 | // |
| 452 | // Description: |
| 453 | // Adds a reference to the instance when writing. Always lie about |
| 454 | // isFromField, since it will always be from a field but we want to |
| 455 | // write out the global field anyway. |
| 456 | // |
| 457 | // Use: internal, virtual |
| 458 | |
| 459 | void |
| 460 | SoGlobalFieldcxx . . $ SoGlobalField#::addWriteReferencecxx . . $ SoGlobalField#addWriteReference(ef4b98cc8eef533a).(SoOutputcxx . . $ SoOutput# *out, SbBoolcxx . . $ SbBool#) |
| 461 | // |
| 462 | //////////////////////////////////////////////////////////////////////// |
| 463 | { |
| 464 | SoFieldContainercxx . . $ SoFieldContainer#::addWriteReferencecxx . . $ SoFieldContainer#addWriteReference(ef4b98cc8eef533a).(out, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 465 | } |