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

# 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-2003 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 <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/SbBasic.h>
    00028 #include <Inventor/SbDict.h>
    00029 #include <stdlib.h> // For NULL definition.
    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 /* inline methods ************************************************/
    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