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

SoType.h
1 #ifndef COIN_SOTYPE_H
2 #define COIN_SOTYPE_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/SbBasic.h>
28 #include <stdlib.h> // For NULL definition.
29 
30 #ifndef COIN_INTERNAL
31 // The next include for Open Inventor compatibility.
32 //
33 // FIXME: I haven't checked that this is actually required -- test vs
34 // SGI Inventor. 20050524 mortene.
35 #include <Inventor/SbDict.h>
36 #endif // COIN_INTERNAL
37 
38 // *************************************************************************
39 
40 class SbName;
41 class SoTypedObject;
42 class SoTypeList;
43 class SoFieldData;
44 class SbDict;
45 struct SoTypeData;
46 template <class Type> class SbList;
47 
48 // *************************************************************************
49 
50 class COIN_DLL_API SoType {
51 public:
52  typedef void * (*instantiationMethod)(void);
53 
54  static SoType fromName(const SbName name);
55  SbName getName(void) const;
56  const SoType getParent(void) const;
57  SbBool isDerivedFrom(const SoType type) const;
58 
59  static int getAllDerivedFrom(const SoType type, SoTypeList & list);
60 
61  SbBool canCreateInstance(void) const;
62  void * createInstance(void) const;
63 
64  uint16_t getData(void) const;
65  int16_t getKey(void) const;
66 
67  SbBool operator == (const SoType type) const;
68  SbBool operator != (const SoType type) const;
69 
70  SbBool operator < (const SoType type) const;
71  SbBool operator <= (const SoType type) const;
72  SbBool operator >= (const SoType type) const;
73  SbBool operator > (const SoType type) const;
74 
75  static const SoType createType(const SoType parent, const SbName name,
76  const instantiationMethod method = (instantiationMethod) NULL,
77  const uint16_t data = 0);
78 
79  static const SoType overrideType(const SoType originalType,
80  const instantiationMethod method = (instantiationMethod) NULL);
81 
82  static void init(void);
83 
84  static SoType fromKey(uint16_t key);
85  static SoType badType(void);
86  SbBool isBad(void) const;
87 
88  void makeInternal(void);
89  SbBool isInternal(void) const;
90 
91  static int getNumTypes(void);
92 
93  instantiationMethod getInstantiationMethod(void) const;
94 
95 private:
96  static void clean(void);
97 
98  int16_t index;
99 
100  static SbList<SoTypeData *> * typedatalist;
101 
102  // OBSOLETE, only kept for Coin 2.x ABI compatibility.
103  static SbDict * typedict;
104  static SbDict * moduledict;
105 };
106 
107 /* inline methods ************************************************/
108 
109 inline int16_t
110 SoType::getKey(void) const
111 {
112  return this->index;
113 }
114 
115 inline SbBool
116 SoType::operator != (const SoType type) const
117 {
118  return (this->getKey() != type.getKey());
119 }
120 
121 inline SbBool
122 SoType::operator == (const SoType type) const
123 {
124  return (this->getKey() == type.getKey());
125 }
126 
127 inline SbBool
128 SoType::operator < (const SoType type) const
129 {
130  return (this->getKey() < type.getKey());
131 }
132 
133 inline SbBool
134 SoType::operator <= (const SoType type) const
135 {
136  return (this->getKey() <= type.getKey());
137 }
138 
139 inline SbBool
140 SoType::operator >= (const SoType type) const
141 {
142  return (this->getKey() >= type.getKey());
143 }
144 
145 inline SbBool
146 SoType::operator > (const SoType type) const
147 {
148  return (this->getKey() > type.getKey());
149 }
150 
151 inline SbBool
152 SoType::isBad(void) const
153 {
154  return (this->index == 0);
155 }
156 
157 #endif // !COIN_SOTYPE_H
The SbList class is a template container class for lists.SbList is an extension of the Coin library v...
Definition: SoType.h:46
SbBool isBad(void) const
Definition: SoType.h:152
The SbDict class organizes a dictionary of keys and values.It uses hashing to quickly insert and find...
Definition: SbDict.h:47
SbBool operator<=(const SoType type) const
Definition: SoType.h:134
The SoTypeList class is a container class for arrays of SoType objects.
Definition: SoTypeList.h:30
SbBool operator==(const SoType type) const
Definition: SoType.h:122
SbBool operator>(const SoType type) const
Definition: SoType.h:146
SbBool operator!=(const SoType type) const
Definition: SoType.h:116
int16_t getKey(void) const
Definition: SoType.h:110
The SoFieldData class is a container for a prototype set of fields.This class is instantiated once fo...
Definition: SoFieldData.h:39
The SoType class is the basis for the run-time type system in Coin.Many of the classes in the Coin li...
Definition: SoType.h:50
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
SbBool operator<(const SoType type) const
Definition: SoType.h:128
SbBool operator>=(const SoType type) const
Definition: SoType.h:140

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

Generated on Fri Feb 17 2017 for Coin by Doxygen. 1.8.13