0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / StepData / StepData_ESDescr.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14
42cf5bc1 15#include <Dico_DictionaryOfInteger.hxx>
16#include <Interface_Macros.hxx>
17#include <Standard_Type.hxx>
18#include <StepData_Described.hxx>
19#include <StepData_ESDescr.hxx>
20#include <StepData_PDescr.hxx>
21#include <StepData_Simple.hxx>
22#include <TCollection_AsciiString.hxx>
7fd59977 23
92efcf78 24IMPLEMENT_STANDARD_RTTIEXT(StepData_ESDescr,StepData_EDescr)
25
7fd59977 26StepData_ESDescr::StepData_ESDescr (const Standard_CString name)
27: thenom (name) { thenames = new Dico_DictionaryOfInteger; }
28
29void StepData_ESDescr::SetNbFields (const Standard_Integer nb)
30{
31 Standard_Integer minb,i, oldnb = NbFields();
32 thenames->Clear();
33 if (nb == 0) { thedescr.Nullify(); return; }
34 Handle(TColStd_HArray1OfTransient) li = new TColStd_HArray1OfTransient(1,nb);
35 if (oldnb == 0) { thedescr = li; return; }
36 minb = (oldnb > nb ? nb : oldnb);
37 for (i = 1; i <= minb; i ++) {
38 DeclareAndCast(StepData_PDescr,pde,thedescr->Value(i));
39 if (!pde.IsNull()) thenames->SetItem (pde->Name(),i);
40 li->SetValue (i, pde);
41 }
42 thedescr = li;
43}
44
45
46 void StepData_ESDescr::SetField
47 (const Standard_Integer num, const Standard_CString name,
48 const Handle(StepData_PDescr)& descr)
49{
50 if (num < 1 || num > NbFields()) return;
51 Handle(StepData_PDescr) pde = new StepData_PDescr;
52 pde->SetFrom (descr);
53 pde->SetName (name);
54 thedescr->SetValue (num,pde);
55 thenames->SetItem (name,num);
56}
57
58 void StepData_ESDescr::SetBase (const Handle(StepData_ESDescr)& base)
59{
60 thebase = base;
61// il faut CUMULER les fields de la base et ses supers
62}
63
64 void StepData_ESDescr::SetSuper (const Handle(StepData_ESDescr)& super)
65{
66 Handle(StepData_ESDescr) sup = super->Base();
67 if (sup.IsNull()) sup = super;
68 if (!thebase.IsNull()) thebase->SetSuper (sup);
69 else thesuper = sup;
70}
71
72 Standard_CString StepData_ESDescr::TypeName () const
73 { return thenom.ToCString(); }
74
75 const TCollection_AsciiString& StepData_ESDescr::StepType () const
76 { return thenom; }
77
78 Handle(StepData_ESDescr) StepData_ESDescr::Base () const
79 { return thebase; }
80
81 Handle(StepData_ESDescr) StepData_ESDescr::Super () const
82 { return thesuper; }
83
84 Standard_Boolean StepData_ESDescr::IsSub (const Handle(StepData_ESDescr)& other) const
85{
86 Handle(StepData_ESDescr) oth = other->Base();
87 if (oth.IsNull()) oth = other;
88 if (!thebase.IsNull()) return thebase->IsSub (oth);
89 Handle(Standard_Transient) t1 = this;
90 if (oth == t1) return Standard_True;
91 if (oth == thesuper) return Standard_True;
92 else if (thesuper.IsNull()) return Standard_False;
93 return thesuper->IsSub (oth);
94}
95
96
97 Standard_Integer StepData_ESDescr::NbFields () const
98 { return (thedescr.IsNull() ? 0 : thedescr->Length()); }
99
100 Standard_Integer StepData_ESDescr::Rank (const Standard_CString name) const
101{
102 Standard_Integer rank;
103 if (!thenames->GetItem (name,rank)) return 0;
104 return rank;
105}
106
107 Standard_CString StepData_ESDescr::Name (const Standard_Integer num) const
108{
109 if (num < 1) return "";
110 if (num > NbFields()) return "";
111 DeclareAndCast(StepData_PDescr,pde,thedescr->Value(num));
112 return pde->Name();
113}
114
115 Handle(StepData_PDescr) StepData_ESDescr::Field (const Standard_Integer num) const
116 { return GetCasted(StepData_PDescr,thedescr->Value(num)); }
117
118 Handle(StepData_PDescr) StepData_ESDescr::NamedField
119 (const Standard_CString name) const
120{
121 Handle(StepData_PDescr) pde;
122 Standard_Integer rank = Rank(name);
123 if (rank > 0) pde = GetCasted(StepData_PDescr,thedescr->Value(rank));
124 return pde;
125}
126
127
128 Standard_Boolean StepData_ESDescr::Matches (const Standard_CString name) const
129{
130 if (thenom.IsEqual(name)) return Standard_True;
131 if (thesuper.IsNull()) return Standard_False;
132 return thesuper->Matches (name);
133}
134
135 Standard_Boolean StepData_ESDescr::IsComplex () const
136 { return Standard_False; }
137
138 Handle(StepData_Described) StepData_ESDescr::NewEntity () const
139{
140 Handle(StepData_Simple) ent = new StepData_Simple(this);
141 return ent;
142}