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

SoBase.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 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, Prof Brochs gate 6, 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   // FIXME: the ifndef wrapper is a workaround for a bug in Doxygen
00111   // 1.0.0, where private members in a structure doesn't "inherit" the
00112   // private status of their "parent". (This has been confirmed to be
00113   // a bug by Dimitri.) Remove the workaround when a fixed Doxygen
00114   // appears. 20000124 mortene.
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   // Don't convert this to a pointer reference, as practically
00125   // speaking all SoBase derived objects have auditors -- so the list
00126   // will be allocated anyway, and we won't save any space (on the
00127   // contrary, we'll use a few extra bytes for the pointer on each
00128   // instance).
00129   //
00130   // But we should look into the possibility of slimming down
00131   // SoAuditorList.
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

Generated at Tue Mar 5 03:31:11 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001