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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
18  * about acquiring a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, 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 = NULL,
77  const uint16_t data = 0);
78 
79  static const SoType overrideType(const SoType originalType,
80  const instantiationMethod method = NULL);
81 
82  static SbBool removeType(const SbName & name);
83 
84  static void init(void);
85 
86  static SoType fromKey(uint16_t key);
87  static SoType badType(void);
88  SbBool isBad(void) const;
89 
90  void makeInternal(void);
91  SbBool isInternal(void) const;
92 
93  static int getNumTypes(void);
94 
95  instantiationMethod getInstantiationMethod(void) const;
96 
97 private:
98  static void clean(void);
99 
100  int16_t index;
101 
102  static SbList<SoTypeData *> * typedatalist;
103 };
104 
105 /* inline methods ************************************************/
106 
107 inline int16_t
108 SoType::getKey(void) const
109 {
110  return this->index;
111 }
112 
113 inline SbBool
114 SoType::operator != (const SoType type) const
115 {
116  return (this->getKey() != type.getKey());
117 }
118 
119 inline SbBool
120 SoType::operator == (const SoType type) const
121 {
122  return (this->getKey() == type.getKey());
123 }
124 
125 inline SbBool
126 SoType::operator < (const SoType type) const
127 {
128  return (this->getKey() < type.getKey());
129 }
130 
131 inline SbBool
132 SoType::operator <= (const SoType type) const
133 {
134  return (this->getKey() <= type.getKey());
135 }
136 
137 inline SbBool
138 SoType::operator >= (const SoType type) const
139 {
140  return (this->getKey() >= type.getKey());
141 }
142 
143 inline SbBool
144 SoType::operator > (const SoType type) const
145 {
146  return (this->getKey() > type.getKey());
147 }
148 
149 inline SbBool
150 SoType::isBad(void) const
151 {
152  return (this->index == 0);
153 }
154 
155 #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:150
The SbDict class organizes a dictionary of keys and values.It uses hashing to quickly insert and find...
Definition: SbDict.h:54
SbBool operator<=(const SoType type) const
Definition: SoType.h:132
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:120
SbBool operator>(const SoType type) const
Definition: SoType.h:144
SbBool operator!=(const SoType type) const
Definition: SoType.h:114
int16_t getKey(void) const
Definition: SoType.h:108
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:126
SbBool operator>=(const SoType type) const
Definition: SoType.h:138

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

Generated for Coin by Doxygen 1.8.14.