00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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
00111
00112
00113
00114
00115 #ifndef DOXYGEN_SKIP_THIS
00116 struct {
00117 int16_t referencecount : 15;
00118 uint16_t writerefcount : 15;
00119 unsigned int multirefs : 1;
00120 unsigned int ingraph : 1;
00121 } objdata;
00122 #endif // DOXYGEN_SKIP_THIS
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 SoAuditorList auditors;
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