1 // File: TFunction_GraphNode.cxx
2 // Created: Mon Jun 21 14:35:37 2008
3 // Author: Vladislav ROMASHKO
4 // <vladislav.romashko@opencascade.com>
7 #include <TFunction_GraphNode.ixx>
8 #include <TFunction_Scope.hxx>
10 //=======================================================================
12 //purpose : Static method to get an ID
13 //=======================================================================
15 const Standard_GUID& TFunction_GraphNode::GetID()
17 static Standard_GUID TFunction_GraphNodeID("DD51FA86-E171-41a4-A2C1-3A0FBF286798");
18 return TFunction_GraphNodeID;
21 //=======================================================================
23 //purpose : Finds or creates a graph node attribute
24 //=======================================================================
26 Handle(TFunction_GraphNode) TFunction_GraphNode::Set(const TDF_Label& L)
28 Handle(TFunction_GraphNode) G;
29 if (!L.FindAttribute(TFunction_GraphNode::GetID(), G))
31 G = new TFunction_GraphNode();
37 //=======================================================================
39 //purpose : Returns GUID of the function
40 //=======================================================================
42 const Standard_GUID& TFunction_GraphNode::ID() const
47 //=======================================================================
48 //function : TFunction_GraphNode
49 //purpose : Constructor
50 //=======================================================================
52 TFunction_GraphNode::TFunction_GraphNode():myStatus(TFunction_ES_WrongDefinition)
57 //=======================================================================
58 //function : AddPrevious
59 //purpose : Adds a function to the previous functions of this function.
60 //=======================================================================
62 Standard_Boolean TFunction_GraphNode::AddPrevious(const Standard_Integer funcID)
64 if (myPrevious.Contains(funcID))
65 return Standard_False;
69 return myPrevious.Add(funcID);
72 //=======================================================================
73 //function : AddPrevious
74 //purpose : Adds a function to the previous functions of this function.
75 //=======================================================================
77 Standard_Boolean TFunction_GraphNode::AddPrevious(const TDF_Label& func)
79 Handle(TFunction_Scope) scope = TFunction_Scope::Set(func);
80 if (!scope->GetFunctions().IsBound2(func))
81 return Standard_False;
82 Standard_Integer funcID = scope->GetFunctions().Find2(func);
83 return AddPrevious(funcID);
86 //=======================================================================
87 //function : RemovePrevious
88 //purpose : Removes a function to the previous functions of this function.
89 //=======================================================================
91 Standard_Boolean TFunction_GraphNode::RemovePrevious(const Standard_Integer funcID)
93 if (!myPrevious.Contains(funcID))
94 return Standard_False;
98 return myPrevious.Remove(funcID);
101 //=======================================================================
102 //function : RemovePrevious
103 //purpose : Removes a function to the previous functions of this function.
104 //=======================================================================
106 Standard_Boolean TFunction_GraphNode::RemovePrevious(const TDF_Label& func)
108 Handle(TFunction_Scope) scope = TFunction_Scope::Set(func);
109 if (!scope->GetFunctions().IsBound2(func))
110 return Standard_False;
111 Standard_Integer funcID = scope->GetFunctions().Find2(func);
112 return RemovePrevious(funcID);
115 //=======================================================================
116 //function : GetPrevious
117 //purpose : Returns a map of previous functions.
118 //=======================================================================
120 const TColStd_MapOfInteger& TFunction_GraphNode::GetPrevious() const
125 //=======================================================================
126 //function : RemoveAllPrevious
127 //purpose : Clear the map of previous functions.
128 //=======================================================================
130 void TFunction_GraphNode::RemoveAllPrevious()
132 if (myPrevious.IsEmpty())
140 //=======================================================================
142 //purpose : Adds a function to the next functions of this function.
143 //=======================================================================
145 Standard_Boolean TFunction_GraphNode::AddNext(const Standard_Integer funcID)
147 if (myNext.Contains(funcID))
148 return Standard_False;
152 return myNext.Add(funcID);
155 //=======================================================================
157 //purpose : Adds a function to the next functions of this function.
158 //=======================================================================
160 Standard_Boolean TFunction_GraphNode::AddNext(const TDF_Label& func)
162 Handle(TFunction_Scope) scope = TFunction_Scope::Set(func);
163 if (!scope->GetFunctions().IsBound2(func))
164 return Standard_False;
165 Standard_Integer funcID = scope->GetFunctions().Find2(func);
166 return AddNext(funcID);
169 //=======================================================================
170 //function : RemoveNext
171 //purpose : Removes a function to the next functions of this function.
172 //=======================================================================
174 Standard_Boolean TFunction_GraphNode::RemoveNext(const Standard_Integer funcID)
176 if (!myNext.Contains(funcID))
177 return Standard_False;
181 return myNext.Remove(funcID);
184 //=======================================================================
185 //function : RemoveNext
186 //purpose : Remove a function to the next functions of this function.
187 //=======================================================================
189 Standard_Boolean TFunction_GraphNode::RemoveNext(const TDF_Label& func)
191 Handle(TFunction_Scope) scope = TFunction_Scope::Set(func);
192 if (!scope->GetFunctions().IsBound2(func))
193 return Standard_False;
194 Standard_Integer funcID = scope->GetFunctions().Find2(func);
195 return RemoveNext(funcID);
198 //=======================================================================
200 //purpose : Returns a map of next functions.
201 //=======================================================================
203 const TColStd_MapOfInteger& TFunction_GraphNode::GetNext() const
208 //=======================================================================
209 //function : RemoveAllNext
210 //purpose : Clear the map of next functions.
211 //=======================================================================
213 void TFunction_GraphNode::RemoveAllNext()
215 if (myNext.IsEmpty())
223 //=======================================================================
224 //function : GetStatus
225 //purpose : Returns the execution status of the function.
226 //=======================================================================
228 TFunction_ExecutionStatus TFunction_GraphNode::GetStatus() const
233 //=======================================================================
234 //function : SetStatus
235 //purpose : Defines an execution status for a function.
236 //=======================================================================
238 void TFunction_GraphNode::SetStatus(const TFunction_ExecutionStatus status)
240 if (myStatus == status)
248 //=======================================================================
251 //=======================================================================
253 void TFunction_GraphNode::Restore(const Handle(TDF_Attribute)& other)
255 Handle(TFunction_GraphNode) G = Handle(TFunction_GraphNode)::DownCast(other);
258 myPrevious = G->myPrevious;
264 myStatus = G->myStatus;
267 //=======================================================================
269 //purpose : Method for Copy mechanism
270 //=======================================================================
272 void TFunction_GraphNode::Paste(const Handle(TDF_Attribute)& into,
273 const Handle(TDF_RelocationTable)& /*RT*/) const
275 Handle(TFunction_GraphNode) G = Handle(TFunction_GraphNode)::DownCast(into);
278 G->myPrevious = myPrevious;
284 G->myStatus = myStatus;
287 //=======================================================================
288 //function : NewEmpty
289 //purpose : Returns new empty graph node attribute
290 //=======================================================================
292 Handle(TDF_Attribute) TFunction_GraphNode::NewEmpty() const
294 return new TFunction_GraphNode();
297 //=======================================================================
298 //function : References
299 //purpose : Collects the references
300 //=======================================================================
302 void TFunction_GraphNode::References(const Handle(TDF_DataSet)& /*aDataSet*/) const
307 //=======================================================================
309 //purpose : Dump of the graph node
310 //=======================================================================
312 Standard_OStream& TFunction_GraphNode::Dump (Standard_OStream& anOS) const
314 TDF_Attribute::Dump(anOS);