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

SoBase.h

00001 /**************************************************************************\ 00002 * 00003 * This file is part of the Coin 3D visualization library. 00004 * Copyright (C) 1998-2003 by Systems in Motion. All rights reserved. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * version 2.1 as published by the Free Software Foundation. See the 00009 * file LICENSE.LGPL at the root directory of the distribution for 00010 * more details. 00011 * 00012 * If you want to use Coin for applications not compatible with the 00013 * LGPL, please contact SIM to acquire a Professional Edition license. 00014 * 00015 * Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY 00016 * http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097 00017 * 00018 \**************************************************************************/ 00019 00020 #ifndef COIN_SOBASE_H 00021 #define COIN_SOBASE_H 00022 00023 #include <Inventor/SoType.h> 00024 #include <Inventor/lists/SoAuditorList.h> 00025 00026 class SbString; 00027 class SoBaseList; 00028 class SoInput; 00029 class SoOutput; 00030 00031 class COIN_DLL_API SoBase { 00032 00033 public: 00034 static void initClass(void); 00035 00036 void ref(void) const; 00037 void unref(void) const; 00038 void unrefNoDelete(void) const; 00039 int32_t getRefCount(void) const; 00040 00041 void touch(void); 00042 00043 virtual SoType getTypeId(void) const = 0; 00044 SbBool isOfType(SoType type) const; 00045 static SoType getClassTypeId(void); 00046 00047 virtual SbName getName(void) const; 00048 virtual void setName(const SbName & newname); 00049 00050 static void addName(SoBase * const base, const char * const name); 00051 static void removeName(SoBase * const base, const char * const name); 00052 00053 virtual void startNotify(void); 00054 virtual void notify(SoNotList * l); 00055 00056 void addAuditor(void * const auditor, const SoNotRec::Type type); 00057 void removeAuditor(void * const auditor, const SoNotRec::Type type); 00058 const SoAuditorList & getAuditors(void) const; 00059 00060 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE); 00061 SbBool shouldWrite(void); 00062 00063 static void incrementCurrentWriteCounter(void); 00064 static void decrementCurrentWriteCounter(void); 00065 00066 static SoBase * getNamedBase(const SbName & name, SoType type); 00067 static int getNamedBases(const SbName & name, SoBaseList & baselist, 00068 SoType type); 00069 00070 static SbBool read(SoInput * in, SoBase *& base, SoType expectedtype); 00071 static void setInstancePrefix(const SbString & c); 00072 00073 static void setTraceRefs(SbBool trace); 00074 static SbBool getTraceRefs(void); 00075 00076 00077 protected: 00078 // Note: these are bitflags. 00079 enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }; 00080 00081 SoBase(void); 00082 virtual ~SoBase(); 00083 00084 virtual void destroy(void); 00085 00086 SbBool hasMultipleWriteRefs(void) const; 00087 SbBool writeHeader(SoOutput * out, SbBool isgroup, SbBool isengine) const; 00088 void writeFooter(SoOutput * out) const; 00089 virtual const char * getFileFormatName(void) const; 00090 00091 virtual SbBool readInstance(SoInput * in, unsigned short flags) = 0; 00092 00093 static uint32_t getCurrentWriteCounter(void); 00094 00095 00096 private: 00097 static SbBool readReference(SoInput * in, SoBase *& base); 00098 static SbBool readBase(SoInput * in, SbName & classname, SoBase *& base); 00099 static SbBool readBaseInstance(SoInput * in, const SbName & classname, 00100 const SbName & refname, SoBase *& base); 00101 00102 static SoBase * createInstance(SoInput * in, const SbName & classname); 00103 static void flushInput(SoInput * in); 00104 00105 static void cleanClass(void); 00106 static void freeLists(unsigned long, void * value); 00107 00108 static SoType classTypeId; 00109 00110 struct { 00111 int16_t referencecount : 15; 00112 uint16_t writerefcount : 15; 00113 unsigned int multirefs : 1; 00114 unsigned int ingraph : 1; 00115 } objdata; 00116 00117 // Don't convert this to a pointer reference, as practically 00118 // speaking all SoBase derived objects have auditors -- so the list 00119 // will be allocated anyway, and we won't save any space (on the 00120 // contrary, we'll use a few extra bytes for the pointer on each 00121 // instance). 00122 // 00123 // But we should look into the possibility of slimming down 00124 // SoAuditorList. 00125 SoAuditorList auditors; 00126 00127 static SbDict * name2obj; 00128 static SbDict * obj2name; 00129 00130 static SbString * refwriteprefix; 00131 00132 static SbBool tracerefs; 00133 static uint32_t writecounter; 00134 }; 00135 00136 #endif // !COIN_SOBASE_H

Generated on Tue Jul 27 23:53:00 2004 for Coin by doxygen 1.3.7