1 // Created on: 1997-12-16
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TDataStd_Expression.hxx>
19 #include <Standard_Dump.hxx>
20 #include <Standard_GUID.hxx>
21 #include <Standard_Type.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TCollection_ExtendedString.hxx>
24 #include <TDataStd_Variable.hxx>
25 #include <TDF_Attribute.hxx>
26 #include <TDF_Label.hxx>
27 #include <TDF_ListIteratorOfAttributeList.hxx>
28 #include <TDF_RelocationTable.hxx>
30 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Expression,TDF_Attribute)
32 //=======================================================================
35 //=======================================================================
36 const Standard_GUID& TDataStd_Expression::GetID()
38 static Standard_GUID TDataStd_ExpressionID("ce24146a-8e57-11d1-8953-080009dc4425");
39 return TDataStd_ExpressionID;
42 //=======================================================================
45 //=======================================================================
47 Handle(TDataStd_Expression) TDataStd_Expression::Set(const TDF_Label& L)
49 Handle(TDataStd_Expression) A;
50 if (!L.FindAttribute (TDataStd_Expression::GetID(), A)) {
51 A = new TDataStd_Expression ();
57 //=======================================================================
58 //function : TDataStd_Expression
60 //=======================================================================
62 TDataStd_Expression::TDataStd_Expression()
67 //=======================================================================
70 //=======================================================================
71 TCollection_ExtendedString TDataStd_Expression::Name () const
73 return myExpression; // ->String();
76 //=======================================================================
77 //function : SetExpression
79 //=======================================================================
81 void TDataStd_Expression::SetExpression(const TCollection_ExtendedString& E)
84 if(myExpression == E) return;
90 //=======================================================================
91 //function : GetExpression
93 //=======================================================================
95 const TCollection_ExtendedString& TDataStd_Expression::GetExpression () const
100 //=======================================================================
101 //function : GetVariables
103 //=======================================================================
105 TDF_AttributeList& TDataStd_Expression::GetVariables()
110 //=======================================================================
113 //=======================================================================
115 const Standard_GUID& TDataStd_Expression::ID() const
120 //=======================================================================
123 //=======================================================================
125 void TDataStd_Expression::Restore(const Handle(TDF_Attribute)& With)
127 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (With);
128 myExpression = EXPR->GetExpression();
130 Handle(TDataStd_Variable) V;
132 for (TDF_ListIteratorOfAttributeList it (EXPR->GetVariables()); it.More(); it.Next()) {
133 V = Handle(TDataStd_Variable)::DownCast(it.Value());
134 myVariables.Append(V);
138 //=======================================================================
139 //function : NewEmpty
141 //=======================================================================
143 Handle(TDF_Attribute) TDataStd_Expression::NewEmpty() const
145 return new TDataStd_Expression();
148 //=======================================================================
151 //=======================================================================
153 void TDataStd_Expression::Paste(const Handle(TDF_Attribute)& Into,
154 const Handle(TDF_RelocationTable)& RT) const
156 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (Into);
157 EXPR->SetExpression(myExpression);
158 Handle(TDataStd_Variable) V1;
159 for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) {
160 V1 = Handle(TDataStd_Variable)::DownCast(it.Value());
161 Handle(TDF_Attribute) V2;
162 RT->HasRelocation (V1,V2);
163 EXPR->GetVariables().Append(V2);
167 //=======================================================================
170 //=======================================================================
172 Standard_OStream& TDataStd_Expression::Dump(Standard_OStream& anOS) const
174 anOS << "Expression";
178 //=======================================================================
179 //function : DumpJson
181 //=======================================================================
182 void TDataStd_Expression::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
184 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
186 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
188 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myExpression)
190 for (TDF_AttributeList::Iterator aVariableIt (myVariables); aVariableIt.More(); aVariableIt.Next())
192 const Handle(TDF_Attribute)& anAttribute = aVariableIt.Value();
193 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anAttribute.get())