1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
19 #include <Standard_Type.ixx>
20 #include <Standard_Persistent.hxx>
22 //============================================================================
23 // The constructor for a imported Type
24 //============================================================================
26 Standard_Type::Standard_Type(const Standard_CString aName,
27 const Standard_Integer aSize)
31 myKind = Standard_IsImported;
33 //==== Just for be clean with the class and the enumeration ================
35 myNumberOfAncestor = 0;
40 //============================================================================
41 // The constructor for a primitive Type
42 //============================================================================
44 Standard_Type::Standard_Type(const Standard_CString aName,
45 const Standard_Integer aSize,
46 const Standard_Integer aNumberOfParent ,
47 const Standard_Address aAncestors)
51 myKind = Standard_IsPrimitive;
53 myNumberOfParent = aNumberOfParent;
55 //==== Calculate the number of ancestor ====================================
56 myNumberOfAncestor = 0;
57 myAncestors = aAncestors;
58 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
59 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
64 //============================================================================
65 // The constructor for an enumeration.
66 //============================================================================
68 Standard_Type::Standard_Type(const Standard_CString aName,
69 const Standard_Integer aSize,
70 const Standard_Integer ,
71 const Standard_Integer aNumberOfParent,
72 const Standard_Address aAncestors,
73 const Standard_Address )
77 myKind = Standard_IsEnumeration;
79 myNumberOfParent = aNumberOfParent;
81 //==== Calculate the number of ancestor ====================================
82 myNumberOfAncestor = 0;
83 myAncestors = aAncestors;
84 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
85 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
90 //============================================================================
91 // The constructor for a class.
92 //============================================================================
94 Standard_Type::Standard_Type(const Standard_CString aName,
95 const Standard_Integer aSize,
96 const Standard_Integer aNumberOfParent ,
97 const Standard_Address aAncestors ,
98 const Standard_Address )
102 myKind = Standard_IsClass;
104 myNumberOfParent = aNumberOfParent;
106 //==== Calculate the number of ancestors ===================================
107 myNumberOfAncestor = 0;
108 myAncestors = aAncestors;
109 Handle(Standard_Type) *allAncestors = (Handle(Standard_Type) *)myAncestors;
110 for(Standard_Integer i=0; allAncestors && !allAncestors[i].IsNull(); i++) {
111 myNumberOfAncestor++;
115 //============================================================================
116 Standard_CString Standard_Type::Name() const
121 //============================================================================
122 Standard_Integer Standard_Type::Size()const
127 //============================================================================
128 Standard_Boolean Standard_Type::IsImported()const
130 return myKind == Standard_IsImported;
133 //============================================================================
134 Standard_Boolean Standard_Type::IsPrimitive()const
136 return myKind == Standard_IsPrimitive;
139 //============================================================================
140 Standard_Boolean Standard_Type::IsEnumeration()const
142 return myKind == Standard_IsEnumeration;
145 //============================================================================
146 Standard_Boolean Standard_Type::IsClass()const
148 return myKind == Standard_IsClass;
151 //============================================================================
152 Standard_Integer Standard_Type::NumberOfParent()const
154 return myNumberOfParent;
157 //============================================================================
158 Standard_Integer Standard_Type::NumberOfAncestor()const
160 return myNumberOfAncestor;
163 //============================================================================
164 Standard_Address Standard_Type::Ancestors()const
169 //============================================================================
170 Standard_Boolean Standard_Type::SubType(const Handle(Standard_Type)& anOther)const
172 // Among ancestors of the type of this, there is the type of anOther
173 return anOther == this ||
174 ( myNumberOfAncestor &&
175 (*(Handle(Standard_Type)*)myAncestors)->SubType(anOther) );
178 //============================================================================
179 Standard_Boolean Standard_Type::SubType(const Standard_CString theName)const
181 // Among ancestors of the type of this, there is the type of anOther
183 return Standard_False;
184 if ( IsSimilar(myName, theName) )
185 return Standard_True;
186 if (myNumberOfAncestor)
187 return (*(Handle(Standard_Type) *)myAncestors)->SubType(theName);
188 return Standard_False;
191 // ------------------------------------------------------------------
192 // Print (me; s: in out OStream) returns OStream;
193 // ------------------------------------------------------------------
194 void Standard_Type::Print (Standard_OStream& AStream) const
196 // AStream << myName ;
197 AStream << hex << (Standard_Address ) myName << " : " << dec << myName ;
200 Standard_OStream& operator << (Standard_OStream& AStream
201 ,const Handle(Standard_Type)& AType)
203 AType->Print(AStream);