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

SoType.h

00001 #ifndef COIN_SOTYPE_H
00002 #define COIN_SOTYPE_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) 1998-2007 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 http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/SbBasic.h>
00028 #include <stdlib.h> // For NULL definition.
00029 
00030 #ifndef COIN_INTERNAL
00031 // The next include for Open Inventor compatibility.
00032 //
00033 // FIXME: I haven't checked that this is actually required -- test vs
00034 // SGI Inventor. 20050524 mortene.
00035 #include <Inventor/SbDict.h>
00036 #endif // COIN_INTERNAL
00037 
00038 // *************************************************************************
00039 
00040 class SbName;
00041 class SoTypedObject;
00042 class SoTypeList;
00043 class SoFieldData;
00044 class SbDict;
00045 struct SoTypeData;
00046 template <class Type> class SbList;
00047 
00048 // *************************************************************************
00049 
00050 class COIN_DLL_API SoType {
00051 public:
00052   typedef void * (*instantiationMethod)(void);
00053 
00054   static SoType fromName(const SbName name);
00055   SbName getName(void) const;
00056   const SoType getParent(void) const;
00057   SbBool isDerivedFrom(const SoType type) const;
00058 
00059   static int getAllDerivedFrom(const SoType type, SoTypeList & list);
00060 
00061   SbBool canCreateInstance(void) const;
00062   void * createInstance(void) const;
00063 
00064   uint16_t getData(void) const;
00065   int16_t getKey(void) const;
00066 
00067   SbBool operator == (const SoType type) const;
00068   SbBool operator != (const SoType type) const;
00069 
00070   SbBool operator <  (const SoType type) const;
00071   SbBool operator <= (const SoType type) const;
00072   SbBool operator >= (const SoType type) const;
00073   SbBool operator >  (const SoType type) const;
00074 
00075   static const SoType createType(const SoType parent, const SbName name,
00076                                  const instantiationMethod method = (instantiationMethod) NULL,
00077                                  const uint16_t data = 0);
00078 
00079   static const SoType overrideType(const SoType originalType,
00080                                    const instantiationMethod method = (instantiationMethod) NULL);
00081 
00082   static void init(void);
00083 
00084   static SoType fromKey(uint16_t key);
00085   static SoType badType(void);
00086   SbBool isBad(void) const;
00087 
00088   void makeInternal(void);
00089   SbBool isInternal(void) const;
00090 
00091   static int getNumTypes(void);
00092 
00093   instantiationMethod getInstantiationMethod(void) const;
00094 
00095 private:
00096   static void clean(void);
00097 
00098   int16_t index;
00099 
00100   static SbList<SoTypeData *> * typedatalist;
00101 
00102   // OBSOLETE, only kept for Coin 2.x ABI compatibility.
00103   static SbDict * typedict;
00104   static SbDict * moduledict;
00105 };
00106 
00107 /* inline methods ************************************************/
00108 
00109 inline int16_t
00110 SoType::getKey(void) const
00111 {
00112   return this->index;
00113 }
00114 
00115 inline SbBool
00116 SoType::operator != (const SoType type) const
00117 {
00118   return (this->getKey() != type.getKey());
00119 }
00120 
00121 inline SbBool
00122 SoType::operator == (const SoType type) const
00123 {
00124   return (this->getKey() == type.getKey());
00125 }
00126 
00127 inline SbBool
00128 SoType::operator <  (const SoType type) const
00129 {
00130   return (this->getKey() < type.getKey());
00131 }
00132 
00133 inline SbBool
00134 SoType::operator <= (const SoType type) const
00135 {
00136   return (this->getKey() <= type.getKey());
00137 }
00138 
00139 inline SbBool
00140 SoType::operator >= (const SoType type) const
00141 {
00142   return (this->getKey() >= type.getKey());
00143 }
00144 
00145 inline SbBool
00146 SoType::operator >  (const SoType type) const
00147 {
00148   return (this->getKey() > type.getKey());
00149 }
00150 
00151 inline SbBool
00152 SoType::isBad(void) const
00153 {
00154   return (this->index == 0);
00155 }
00156 
00157 #endif // !COIN_SOTYPE_H

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

Generated on Mon Feb 28 2011 10:11:59 for Coin by Doxygen. 1.7.3