0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / TDataStd / TDataStd_Expression.cxx
CommitLineData
b311480e 1// Created on: 1997-12-16
2// Created by: Denis PASCAL
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TDataStd_Expression.ixx>
18#include <TCollection_AsciiString.hxx>
19#include <TDataStd_Variable.hxx>
20#include <TDF_ListIteratorOfAttributeList.hxx>
21
22//=======================================================================
23//function : GetID
24//purpose :
25//=======================================================================
26
27const Standard_GUID& TDataStd_Expression::GetID()
28{
29 static Standard_GUID TDataStd_ExpressionID("ce24146a-8e57-11d1-8953-080009dc4425");
30 return TDataStd_ExpressionID;
31}
32
33//=======================================================================
34//function : Set
35//purpose :
36//=======================================================================
37
38Handle(TDataStd_Expression) TDataStd_Expression::Set(const TDF_Label& L)
39{
40 Handle(TDataStd_Expression) A;
41 if (!L.FindAttribute (TDataStd_Expression::GetID(), A)) {
42 A = new TDataStd_Expression ();
43 L.AddAttribute(A);
44 }
45 return A;
46}
47
48//=======================================================================
49//function : TDataStd_Expression
50//purpose :
51//=======================================================================
52
53TDataStd_Expression::TDataStd_Expression()
54{
55}
56
57
58//=======================================================================
59//function : Name
60//purpose :
61//=======================================================================
62TCollection_ExtendedString TDataStd_Expression::Name () const
63{
64 return myExpression; // ->String();
65}
66
67//=======================================================================
68//function : SetExpression
69//purpose :
70//=======================================================================
71
72void TDataStd_Expression::SetExpression(const TCollection_ExtendedString& E)
73{
74 // OCC2932 correction
75 if(myExpression == E) return;
76
77 Backup();
78 myExpression = E;
79}
80
81//=======================================================================
82//function : GetExpression
83//purpose :
84//=======================================================================
85
86const TCollection_ExtendedString& TDataStd_Expression::GetExpression () const
87{
88 return myExpression;
89}
90
91//=======================================================================
92//function : GetVariables
93//purpose :
94//=======================================================================
95
96TDF_AttributeList& TDataStd_Expression::GetVariables()
97{
98 return myVariables;
99}
100
101//=======================================================================
102//function : ID
103//purpose :
104//=======================================================================
105
106const Standard_GUID& TDataStd_Expression::ID() const
107{
108 return GetID();
109}
110
111//=======================================================================
112//function : Restore
113//purpose :
114//=======================================================================
115
116void TDataStd_Expression::Restore(const Handle(TDF_Attribute)& With)
117{
118 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (With);
119 myExpression = EXPR->GetExpression();
120
121 Handle(TDataStd_Variable) V;
122 for (TDF_ListIteratorOfAttributeList it (EXPR->GetVariables()); it.More(); it.Next()) {
123 V = Handle(TDataStd_Variable)::DownCast(it.Value());
124 myVariables.Append(V);
125 }
126}
127
128//=======================================================================
129//function : NewEmpty
130//purpose :
131//=======================================================================
132
133Handle(TDF_Attribute) TDataStd_Expression::NewEmpty() const
134{
135 return new TDataStd_Expression();
136}
137
138//=======================================================================
139//function : Paste
140//purpose :
141//=======================================================================
142
143void TDataStd_Expression::Paste(const Handle(TDF_Attribute)& Into,
144 const Handle(TDF_RelocationTable)& RT) const
145{
146 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (Into);
147 EXPR->SetExpression(myExpression);
148 Handle(TDataStd_Variable) V1,V2;
149 for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) {
150 V1 = Handle(TDataStd_Variable)::DownCast(it.Value());
151 RT->HasRelocation (V1,V2);
152 EXPR->GetVariables().Append(V2);
153 }
154}
155
156//=======================================================================
157//function : Dump
158//purpose :
159//=======================================================================
160
161Standard_OStream& TDataStd_Expression::Dump(Standard_OStream& anOS) const
162{
163 anOS << "Expression";
164 return anOS;
165}
166