00001 #ifndef COIN_SOTYPE_H
00002 #define COIN_SOTYPE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <Inventor/SbBasic.h>
00028 #include <Inventor/SbDict.h>
00029 #include <stdlib.h>
00030
00031 class SbName;
00032 class SoTypedObject;
00033 class SoTypeList;
00034 class SoFieldData;
00035 struct SoTypeData;
00036 template <class Type> class SbList;
00037
00038 class COIN_DLL_API SoType {
00039 public:
00040 typedef void * (*instantiationMethod)(void);
00041
00042 static SoType fromName(const SbName name);
00043 SbName getName(void) const;
00044 const SoType getParent(void) const;
00045 SbBool isDerivedFrom(const SoType type) const;
00046
00047 static int getAllDerivedFrom(const SoType type, SoTypeList & list);
00048
00049 SbBool canCreateInstance(void) const;
00050 void * createInstance(void) const;
00051
00052 uint16_t getData(void) const;
00053 int16_t getKey(void) const;
00054
00055 SbBool operator == (const SoType type) const;
00056 SbBool operator != (const SoType type) const;
00057
00058 SbBool operator < (const SoType type) const;
00059 SbBool operator <= (const SoType type) const;
00060 SbBool operator >= (const SoType type) const;
00061 SbBool operator > (const SoType type) const;
00062
00063 static const SoType createType(const SoType parent, const SbName name,
00064 const instantiationMethod method = (instantiationMethod) NULL,
00065 const uint16_t data = 0);
00066
00067 static const SoType overrideType(const SoType originalType,
00068 const instantiationMethod method = (instantiationMethod) NULL);
00069
00070 static void init(void);
00071
00072 static SoType fromKey(uint16_t key);
00073 static SoType badType(void);
00074 SbBool isBad(void) const;
00075
00076 void makeInternal(void);
00077 SbBool isInternal(void) const;
00078
00079 static int getNumTypes(void);
00080
00081 instantiationMethod getInstantiationMethod(void) const;
00082
00083 private:
00084 static void clean(void);
00085
00086 int16_t index;
00087
00088 static SbList<SoTypeData *> * typedatalist;
00089 static SbDict * typedict;
00090 static SbDict * moduledict;
00091 };
00092
00093
00094
00095 inline int16_t
00096 SoType::getKey(void) const
00097 {
00098 return this->index;
00099 }
00100
00101 inline SbBool
00102 SoType::operator != (const SoType type) const
00103 {
00104 return (this->getKey() != type.getKey());
00105 }
00106
00107 inline SbBool
00108 SoType::operator == (const SoType type) const
00109 {
00110 return (this->getKey() == type.getKey());
00111 }
00112
00113 inline SbBool
00114 SoType::operator < (const SoType type) const
00115 {
00116 return (this->getKey() < type.getKey());
00117 }
00118
00119 inline SbBool
00120 SoType::operator <= (const SoType type) const
00121 {
00122 return (this->getKey() <= type.getKey());
00123 }
00124
00125 inline SbBool
00126 SoType::operator >= (const SoType type) const
00127 {
00128 return (this->getKey() >= type.getKey());
00129 }
00130
00131 inline SbBool
00132 SoType::operator > (const SoType type) const
00133 {
00134 return (this->getKey() > type.getKey());
00135 }
00136
00137 inline SbBool
00138 SoType::isBad(void) const
00139 {
00140 return (this->index == 0);
00141 }
00142
00143 #endif // !COIN_SOTYPE_H