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
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 = 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
97private:
98 static void clean(void);
99
100 int16_t index;
101
102 static SbList<SoTypeData *> * typedatalist;
103};
104
105/* inline methods ************************************************/
106
107inline int16_t
108SoType::getKey(void) const
109{
110 return this->index;
111}
112
113inline SbBool
115{
116 return (this->getKey() != type.getKey());
117}
118
119inline SbBool
121{
122 return (this->getKey() == type.getKey());
123}
124
125inline SbBool
126SoType::operator < (const SoType type) const
127{
128 return (this->getKey() < type.getKey());
129}
130
131inline SbBool
132SoType::operator <= (const SoType type) const
133{
134 return (this->getKey() <= type.getKey());
135}
136
137inline SbBool
139{
140 return (this->getKey() >= type.getKey());
141}
142
143inline SbBool
145{
146 return (this->getKey() > type.getKey());
147}
148
149inline SbBool
150SoType::isBad(void) const
151{
152 return (this->index == 0);
153}
154
155#endif // !COIN_SOTYPE_H
The SbDict class organizes a dictionary of keys and values.
Definition SbDict.h:54
The SbList class is a template container class for lists.
Definition SbList.h:61
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:108
SbBool operator>=(const SoType type) const
Definition SoType.h:138
SbBool operator==(const SoType type) const
Definition SoType.h:120
SbBool operator!=(const SoType type) const
Definition SoType.h:114
SbBool isBad(void) const
Definition SoType.h:150
SbBool operator>(const SoType type) const
Definition SoType.h:144
SbBool operator<=(const SoType type) const
Definition SoType.h:132
SbBool operator<(const SoType type) const
Definition SoType.h:126

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

Generated on Wed Jul 17 2024 for Coin by Doxygen 1.12.0.