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
40class SbName;
41class SoTypedObject;
42class SoTypeList;
43class SoFieldData;
44class SbDict;
45struct SoTypeData;
46template <class Type> class SbList;
47
48// *************************************************************************
49
50class COIN_DLL_API SoType {
51public:
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
95private:
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
109inline int16_t
110SoType::getKey(void) const
111{
112 return this->index;
113}
114
115inline SbBool
117{
118 return (this->getKey() != type.getKey());
119}
120
121inline SbBool
123{
124 return (this->getKey() == type.getKey());
125}
126
127inline SbBool
128SoType::operator < (const SoType type) const
129{
130 return (this->getKey() < type.getKey());
131}
132
133inline SbBool
134SoType::operator <= (const SoType type) const
135{
136 return (this->getKey() <= type.getKey());
137}
138
139inline SbBool
141{
142 return (this->getKey() >= type.getKey());
143}
144
145inline SbBool
147{
148 return (this->getKey() > type.getKey());
149}
150
151inline SbBool
152SoType::isBad(void) const
153{
154 return (this->index == 0);
155}
156
157#endif // !COIN_SOTYPE_H
The SbDict class organizes a dictionary of keys and values.
Definition: SbDict.h:47
The SbList class is a template container class for lists.
Definition: SbList.h:47
The SbName class stores strings by reference.
Definition: SbName.h:31
The SoFieldData class is a container for a prototype set of fields.
Definition: SoFieldData.h:39
The SoTypeList class is a container class for arrays of SoType objects.
Definition: SoTypeList.h:30
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:50
int16_t getKey(void) const
Definition: SoType.h:110
SbBool operator>=(const SoType type) const
Definition: SoType.h:140
SbBool operator==(const SoType type) const
Definition: SoType.h:122
SbBool operator!=(const SoType type) const
Definition: SoType.h:116
SbBool isBad(void) const
Definition: SoType.h:152
SbBool operator>(const SoType type) const
Definition: SoType.h:146
SbBool operator<=(const SoType type) const
Definition: SoType.h:134
SbBool operator<(const SoType type) const
Definition: SoType.h:128

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

Generated on Wed Jan 18 2023 for Coin by Doxygen. 1.9.5