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

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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
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 public:
00038   static void initClass(void);
00039 
00040   void ref(void) const;
00041   void unref(void) const;
00042   void unrefNoDelete(void) const;
00043   int32_t getRefCount(void) const;
00044 
00045   void touch(void);
00046 
00047   virtual SoType getTypeId(void) const = 0;
00048   SbBool isOfType(SoType type) const;
00049   static SoType getClassTypeId(void);
00050 
00051   virtual SbName getName(void) const;
00052   virtual void setName(const SbName & newname);
00053 
00054   static void addName(SoBase * const base, const char * const name);
00055   static void removeName(SoBase * const base, const char * const name);
00056 
00057   virtual void startNotify(void);
00058   virtual void notify(SoNotList * l);
00059 
00060   void addAuditor(void * const auditor, const SoNotRec::Type type);
00061   void removeAuditor(void * const auditor, const SoNotRec::Type type);
00062   const SoAuditorList & getAuditors(void) const;
00063 
00064   virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
00065   SbBool shouldWrite(void);
00066 
00067   static void incrementCurrentWriteCounter(void);
00068   static void decrementCurrentWriteCounter(void);
00069 
00070   static SoBase * getNamedBase(const SbName & name, SoType type);
00071   static int getNamedBases(const SbName & name, SoBaseList & baselist,
00072                            SoType type);
00073 
00074   static SbBool read(SoInput * input, SoBase *& base, SoType expectedtype);
00075   static void setInstancePrefix(const SbString & c);
00076 
00077   static void setTraceRefs(SbBool trace);
00078   static SbBool getTraceRefs(void);
00079 
00080   static SbBool connectRoute(SoInput * input,
00081                              const SbName & fromnodename, const SbName & fromfieldname,
00082                              const SbName & tonodename, const SbName & tofieldname);
00083 
00084   void assertAlive(void) const;
00085   static SbBool readRoute(SoInput * input);
00086 
00087 protected:
00088   // Note: these are bitflags.
00089   enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 };
00090 
00091   SoBase(void);
00092   virtual ~SoBase();
00093 
00094   virtual void destroy(void);
00095 
00096   SbBool hasMultipleWriteRefs(void) const;
00097   SbBool writeHeader(SoOutput * out, SbBool isgroup, SbBool isengine) const;
00098   void writeFooter(SoOutput * out) const;
00099   virtual const char * getFileFormatName(void) const;
00100 
00101   virtual SbBool readInstance(SoInput * input, unsigned short flags) = 0;
00102 
00103   static uint32_t getCurrentWriteCounter(void);
00104   static void staticDataLock(void);
00105   static void staticDataUnlock(void);
00106 
00107 private:
00108   static void cleanClass(void);
00109 
00110   static SoType classTypeId;
00111 
00112   struct {
00113     mutable int referencecount  : 28;
00114     mutable unsigned int alive  :  4;
00115   } objdata;
00116 
00117   void doNotify(SoNotList * l, const void * auditor, const SoNotRec::Type type);
00118   cc_rbptree auditortree;
00119 
00120   class PImpl;
00121   friend class PImpl; // MSVC6
00122 };
00123 
00124 // support for boost::intrusive_ptr<SoBase>
00125 inline void intrusive_ptr_add_ref(SoBase * obj) { obj->ref(); }
00126 inline void intrusive_ptr_release(SoBase * obj) { obj->unref(); }
00127 
00128 #endif // !COIN_SOBASE_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Sun May 1 2011 02:58:20 for Coin by Doxygen 1.7.3.