1 // Created on: 1997-12-16
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <TDataStd_Expression.ixx>
24 #include <TCollection_AsciiString.hxx>
25 #include <TDataStd_Variable.hxx>
26 #include <TDF_ListIteratorOfAttributeList.hxx>
28 //=======================================================================
31 //=======================================================================
33 const Standard_GUID& TDataStd_Expression::GetID()
35 static Standard_GUID TDataStd_ExpressionID("ce24146a-8e57-11d1-8953-080009dc4425");
36 return TDataStd_ExpressionID;
39 //=======================================================================
42 //=======================================================================
44 Handle(TDataStd_Expression) TDataStd_Expression::Set(const TDF_Label& L)
46 Handle(TDataStd_Expression) A;
47 if (!L.FindAttribute (TDataStd_Expression::GetID(), A)) {
48 A = new TDataStd_Expression ();
54 //=======================================================================
55 //function : TDataStd_Expression
57 //=======================================================================
59 TDataStd_Expression::TDataStd_Expression()
64 //=======================================================================
67 //=======================================================================
68 TCollection_ExtendedString TDataStd_Expression::Name () const
70 return myExpression; // ->String();
73 //=======================================================================
74 //function : SetExpression
76 //=======================================================================
78 void TDataStd_Expression::SetExpression(const TCollection_ExtendedString& E)
81 if(myExpression == E) return;
87 //=======================================================================
88 //function : GetExpression
90 //=======================================================================
92 const TCollection_ExtendedString& TDataStd_Expression::GetExpression () const
97 //=======================================================================
98 //function : GetVariables
100 //=======================================================================
102 TDF_AttributeList& TDataStd_Expression::GetVariables()
107 //=======================================================================
110 //=======================================================================
112 const Standard_GUID& TDataStd_Expression::ID() const
117 //=======================================================================
120 //=======================================================================
122 void TDataStd_Expression::Restore(const Handle(TDF_Attribute)& With)
124 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (With);
125 myExpression = EXPR->GetExpression();
127 Handle(TDataStd_Variable) V;
128 for (TDF_ListIteratorOfAttributeList it (EXPR->GetVariables()); it.More(); it.Next()) {
129 V = Handle(TDataStd_Variable)::DownCast(it.Value());
130 myVariables.Append(V);
134 //=======================================================================
135 //function : NewEmpty
137 //=======================================================================
139 Handle(TDF_Attribute) TDataStd_Expression::NewEmpty() const
141 return new TDataStd_Expression();
144 //=======================================================================
147 //=======================================================================
149 void TDataStd_Expression::Paste(const Handle(TDF_Attribute)& Into,
150 const Handle(TDF_RelocationTable)& RT) const
152 Handle(TDataStd_Expression) EXPR = Handle(TDataStd_Expression)::DownCast (Into);
153 EXPR->SetExpression(myExpression);
154 Handle(TDataStd_Variable) V1,V2;
155 for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) {
156 V1 = Handle(TDataStd_Variable)::DownCast(it.Value());
157 RT->HasRelocation (V1,V2);
158 EXPR->GetVariables().Append(V2);
162 //=======================================================================
165 //=======================================================================
167 Standard_OStream& TDataStd_Expression::Dump(Standard_OStream& anOS) const
169 anOS << "Expression";