0025418: Debug output to be limited to OCC development environment
[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#include <StepData_ESDescr.ixx>
15#include <StepData_Simple.hxx>
16#include <Interface_Macros.hxx>
17
18
19StepData_ESDescr::StepData_ESDescr (const Standard_CString name)
20: thenom (name) { thenames = new Dico_DictionaryOfInteger; }
21
22void StepData_ESDescr::SetNbFields (const Standard_Integer nb)
23{
24 Standard_Integer minb,i, oldnb = NbFields();
25 thenames->Clear();
26 if (nb == 0) { thedescr.Nullify(); return; }
27 Handle(TColStd_HArray1OfTransient) li = new TColStd_HArray1OfTransient(1,nb);
28 if (oldnb == 0) { thedescr = li; return; }
29 minb = (oldnb > nb ? nb : oldnb);
30 for (i = 1; i <= minb; i ++) {
31 DeclareAndCast(StepData_PDescr,pde,thedescr->Value(i));
32 if (!pde.IsNull()) thenames->SetItem (pde->Name(),i);
33 li->SetValue (i, pde);
34 }
35 thedescr = li;
36}
37
38
39 void StepData_ESDescr::SetField
40 (const Standard_Integer num, const Standard_CString name,
41 const Handle(StepData_PDescr)& descr)
42{
43 if (num < 1 || num > NbFields()) return;
44 Handle(StepData_PDescr) pde = new StepData_PDescr;
45 pde->SetFrom (descr);
46 pde->SetName (name);
47 thedescr->SetValue (num,pde);
48 thenames->SetItem (name,num);
49}
50
51 void StepData_ESDescr::SetBase (const Handle(StepData_ESDescr)& base)
52{
53 thebase = base;
54// il faut CUMULER les fields de la base et ses supers
55}
56
57 void StepData_ESDescr::SetSuper (const Handle(StepData_ESDescr)& super)
58{
59 Handle(StepData_ESDescr) sup = super->Base();
60 if (sup.IsNull()) sup = super;
61 if (!thebase.IsNull()) thebase->SetSuper (sup);
62 else thesuper = sup;
63}
64
65 Standard_CString StepData_ESDescr::TypeName () const
66 { return thenom.ToCString(); }
67
68 const TCollection_AsciiString& StepData_ESDescr::StepType () const
69 { return thenom; }
70
71 Handle(StepData_ESDescr) StepData_ESDescr::Base () const
72 { return thebase; }
73
74 Handle(StepData_ESDescr) StepData_ESDescr::Super () const
75 { return thesuper; }
76
77 Standard_Boolean StepData_ESDescr::IsSub (const Handle(StepData_ESDescr)& other) const
78{
79 Handle(StepData_ESDescr) oth = other->Base();
80 if (oth.IsNull()) oth = other;
81 if (!thebase.IsNull()) return thebase->IsSub (oth);
82 Handle(Standard_Transient) t1 = this;
83 if (oth == t1) return Standard_True;
84 if (oth == thesuper) return Standard_True;
85 else if (thesuper.IsNull()) return Standard_False;
86 return thesuper->IsSub (oth);
87}
88
89
90 Standard_Integer StepData_ESDescr::NbFields () const
91 { return (thedescr.IsNull() ? 0 : thedescr->Length()); }
92
93 Standard_Integer StepData_ESDescr::Rank (const Standard_CString name) const
94{
95 Standard_Integer rank;
96 if (!thenames->GetItem (name,rank)) return 0;
97 return rank;
98}
99
100 Standard_CString StepData_ESDescr::Name (const Standard_Integer num) const
101{
102 if (num < 1) return "";
103 if (num > NbFields()) return "";
104 DeclareAndCast(StepData_PDescr,pde,thedescr->Value(num));
105 return pde->Name();
106}
107
108 Handle(StepData_PDescr) StepData_ESDescr::Field (const Standard_Integer num) const
109 { return GetCasted(StepData_PDescr,thedescr->Value(num)); }
110
111 Handle(StepData_PDescr) StepData_ESDescr::NamedField
112 (const Standard_CString name) const
113{
114 Handle(StepData_PDescr) pde;
115 Standard_Integer rank = Rank(name);
116 if (rank > 0) pde = GetCasted(StepData_PDescr,thedescr->Value(rank));
117 return pde;
118}
119
120
121 Standard_Boolean StepData_ESDescr::Matches (const Standard_CString name) const
122{
123 if (thenom.IsEqual(name)) return Standard_True;
124 if (thesuper.IsNull()) return Standard_False;
125 return thesuper->Matches (name);
126}
127
128 Standard_Boolean StepData_ESDescr::IsComplex () const
129 { return Standard_False; }
130
131 Handle(StepData_Described) StepData_ESDescr::NewEntity () const
132{
133 Handle(StepData_Simple) ent = new StepData_Simple(this);
134 return ent;
135}