Coin Logo http://www.sim.no
http://www.coin3d.org

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SoBase.h

00001 #ifndef COIN_SOBASE_H 00002 #define COIN_SOBASE_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2004 by Systems in Motion. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See <URL:http://www.coin3d.org/> for more information. 00021 * 00022 * Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY. 00023 * <URL:http://www.sim.no/>. 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/SoType.h> 00028 #include <Inventor/lists/SoAuditorList.h> 00029 #include <Inventor/C/base/rbptree.h> 00030 00031 class SbString; 00032 class SoBaseList; 00033 class SoInput; 00034 class SoOutput; 00035 00036 class COIN_DLL_API SoBase { 00037 00038 public: 00039 static void initClass(void); 00040 00041 void ref(void) const; 00042 void unref(void) const; 00043 void unrefNoDelete(void) const; 00044 int32_t getRefCount(void) const; 00045 00046 void touch(void); 00047 00048 virtual SoType getTypeId(void) const = 0; 00049 SbBool isOfType(SoType type) const; 00050 static SoType getClassTypeId(void); 00051 00052 virtual SbName getName(void) const; 00053 virtual void setName(const SbName & newname); 00054 00055 static void addName(SoBase * const base, const char * const name); 00056 static void removeName(SoBase * const base, const char * const name); 00057 00058 virtual void startNotify(void); 00059 virtual void notify(SoNotList * l); 00060 00061 void addAuditor(void * const auditor, const SoNotRec::Type type); 00062 void removeAuditor(void * const auditor, const SoNotRec::Type type); 00063 const SoAuditorList & getAuditors(void) const; 00064 00065 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE); 00066 SbBool shouldWrite(void); 00067 00068 static void incrementCurrentWriteCounter(void); 00069 static void decrementCurrentWriteCounter(void); 00070 00071 static SoBase * getNamedBase(const SbName & name, SoType type); 00072 static int getNamedBases(const SbName & name, SoBaseList & baselist, 00073 SoType type); 00074 00075 static SbBool read(SoInput * in, SoBase *& base, SoType expectedtype); 00076 static void setInstancePrefix(const SbString & c); 00077 00078 static void setTraceRefs(SbBool trace); 00079 static SbBool getTraceRefs(void); 00080 00081 static SbBool connectRoute(SoInput * in, 00082 const SbName & fromnodename, const SbName & fromfieldname, 00083 const SbName & tonodename, const SbName & tofieldname); 00084 00085 void assertAlive(void) const; 00086 static SbBool readRoute(SoInput * in); 00087 00088 protected: 00089 // Note: these are bitflags. 00090 enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }; 00091 00092 SoBase(void); 00093 virtual ~SoBase(); 00094 00095 virtual void destroy(void); 00096 00097 SbBool hasMultipleWriteRefs(void) const; 00098 SbBool writeHeader(SoOutput * out, SbBool isgroup, SbBool isengine) const; 00099 void writeFooter(SoOutput * out) const; 00100 virtual const char * getFileFormatName(void) const; 00101 00102 virtual SbBool readInstance(SoInput * in, unsigned short flags) = 0; 00103 00104 static uint32_t getCurrentWriteCounter(void); 00105 static void staticDataLock(void); 00106 static void staticDataUnlock(void); 00107 00108 private: 00109 static SbBool readReference(SoInput * in, SoBase *& base); 00110 static SbBool readBase(SoInput * in, SbName & classname, SoBase *& base); 00111 static SbBool readBaseInstance(SoInput * in, const SbName & classname, 00112 const SbName & refname, SoBase *& base); 00113 00114 static SoBase * createInstance(SoInput * in, const SbName & classname); 00115 static void flushInput(SoInput * in); 00116 00117 static void cleanClass(void); 00118 static void freeLists(unsigned long, void * value); 00119 00120 static SoType classTypeId; 00121 00122 struct { 00123 int32_t referencecount : 27; 00124 unsigned int ingraph : 1; 00125 unsigned int alive : 4; 00126 // The number of bits should sum up to 32, so we don't allocate 00127 // more than one machine word on a 32-bit platform. 00128 } objdata; 00129 00130 void doNotify(SoNotList * l, const void * auditor, const SoNotRec::Type type); 00131 static void rbptree_notify_cb(void * auditor, void * type, void * closure); 00132 cc_rbptree auditortree; 00133 00134 static SbDict * name2obj; 00135 static SbDict * obj2name; 00136 00137 static SbString * refwriteprefix; 00138 00139 static SbBool tracerefs; 00140 static uint32_t writecounter; 00141 }; 00142 00143 #endif // !COIN_SOBASE_H

Copyright © 1998-2004 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 28 00:04:18 2004 for Coin by Doxygen. 1.3.7