0020716: Eliminate usage of "config.h" header file
[occt.git] / src / Standard / Standard_Type.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15#include <Standard_Type.ixx>
16#include <Standard_Persistent.hxx>
17
18//============================================================================
19// The constructor for a imported Type
20//============================================================================
21
22Standard_Type::Standard_Type(const Standard_CString aName,
23 const Standard_Integer aSize)
24{
25 myName = aName;
26 mySize = aSize;
27 myKind = Standard_IsImported;
28
29 //==== Just for be clean with the class and the enumeration ================
30 myNumberOfParent = 0;
31 myNumberOfAncestor = 0;
32
33 myAncestors = NULL;
34}
35
36//============================================================================
37// The constructor for a primitive Type
38//============================================================================
39
40Standard_Type::Standard_Type(const Standard_CString aName,
41 const Standard_Integer aSize,
42 const Standard_Integer aNumberOfParent ,
43 const Standard_Address aAncestors)
44{
45 myName = aName;
46 mySize = aSize;
47 myKind = Standard_IsPrimitive;
48
49 myNumberOfParent = aNumberOfParent;
50
51 //==== Calculate the number of ancestor ====================================
52 myNumberOfAncestor = 0;
53 myAncestors = aAncestors;
54 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
55 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
56 myNumberOfAncestor++;
57 }
58}
59
60//============================================================================
61// The constructor for an enumeration.
62//============================================================================
63
64Standard_Type::Standard_Type(const Standard_CString aName,
65 const Standard_Integer aSize,
66 const Standard_Integer ,
67 const Standard_Integer aNumberOfParent,
68 const Standard_Address aAncestors,
69 const Standard_Address )
70{
71 myName = aName;
72 mySize = aSize;
73 myKind = Standard_IsEnumeration;
74
75 myNumberOfParent = aNumberOfParent;
76
77 //==== Calculate the number of ancestor ====================================
78 myNumberOfAncestor = 0;
79 myAncestors = aAncestors;
80 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
81 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
82 myNumberOfAncestor++;
83 }
84}
85
86//============================================================================
87// The constructor for a class.
88//============================================================================
89
90Standard_Type::Standard_Type(const Standard_CString aName,
91 const Standard_Integer aSize,
92 const Standard_Integer aNumberOfParent ,
93 const Standard_Address aAncestors ,
94 const Standard_Address )
95{
96 myName = aName;
97 mySize = aSize;
98 myKind = Standard_IsClass;
99
100 myNumberOfParent = aNumberOfParent;
101
102 //==== Calculate the number of ancestors ===================================
103 myNumberOfAncestor = 0;
104 myAncestors = aAncestors;
105 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
106 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
107 myNumberOfAncestor++;
108 }
109}
110
111//============================================================================
112Standard_CString Standard_Type::Name() const
113{
114 return myName;
115}
116
117//============================================================================
118Standard_Integer Standard_Type::Size()const
119{
120 return mySize;
121}
122
123//============================================================================
124Standard_Boolean Standard_Type::IsImported()const
125{
126 return myKind == Standard_IsImported;
127}
128
129//============================================================================
130Standard_Boolean Standard_Type::IsPrimitive()const
131{
132 return myKind == Standard_IsPrimitive;
133}
134
135//============================================================================
136Standard_Boolean Standard_Type::IsEnumeration()const
137{
138 return myKind == Standard_IsEnumeration;
139}
140
141//============================================================================
142Standard_Boolean Standard_Type::IsClass()const
143{
144 return myKind == Standard_IsClass;
145}
146
147//============================================================================
148Standard_Integer Standard_Type::NumberOfParent()const
149{
150 return myNumberOfParent;
151}
152
153//============================================================================
154Standard_Integer Standard_Type::NumberOfAncestor()const
155{
156 return myNumberOfAncestor;
157}
158
159//============================================================================
160Standard_Address Standard_Type::Ancestors()const
161{
162 return myAncestors;
163}
164
165//============================================================================
857ffd5e 166Standard_Boolean Standard_Type::SubType(const Handle(Standard_Type)& anOther)const
7fd59977 167{
168 // Among ancestors of the type of this, there is the type of anOther
169 return anOther == this ||
170 ( myNumberOfAncestor &&
171 (*(Handle(Standard_Type)*)myAncestors)->SubType(anOther) );
172}
173
174//============================================================================
175Standard_Boolean Standard_Type::SubType(const Standard_CString theName)const
176{
177 // Among ancestors of the type of this, there is the type of anOther
178 if ( ! theName )
179 return Standard_False;
180 if ( IsSimilar(myName, theName) )
181 return Standard_True;
182 if (myNumberOfAncestor)
183 return (*(Handle(Standard_Type) *)myAncestors)->SubType(theName);
184 return Standard_False;
185}
186
7fd59977 187// ------------------------------------------------------------------
188// Print (me; s: in out OStream) returns OStream;
189// ------------------------------------------------------------------
190void Standard_Type::Print (Standard_OStream& AStream) const
191{
192// AStream << myName ;
193 AStream << hex << (Standard_Address ) myName << " : " << dec << myName ;
194}
195
196Standard_OStream& operator << (Standard_OStream& AStream
197 ,const Handle(Standard_Type)& AType)
198{
199 AType->Print(AStream);
200 return AStream;
201}