1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_AttributeTreeNode.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeTreeNode.hxx"
28 #include "SALOMEDS.hxx"
33 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
34 #include "SALOMEDS_AttributeTreeNode.hxx"
36 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDSImpl_AttributeTreeNode* theAttr)
37 :SALOMEDS_GenericAttribute(theAttr)
40 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
41 :SALOMEDS_GenericAttribute(theAttr)
44 SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
47 void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
49 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
52 SALOMEDS::Locker lock;
53 SALOMEDSImpl_AttributeTreeNode *aNode, *aFather;
54 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
55 aFather = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
56 aNode->SetFather(aFather);
59 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
60 SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
61 aNode->SetFather(aFather);
65 bool SALOMEDS_AttributeTreeNode::HasFather()
69 SALOMEDS::Locker lock;
70 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
71 ret = aNode->HasFather();
74 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
75 ret = aNode->HasFather();
80 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
82 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
84 SALOMEDS::Locker lock;
85 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
86 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
89 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
90 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
92 return _PTR(AttributeTreeNode)(aTN);
95 void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
97 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
100 SALOMEDS::Locker lock;
101 SALOMEDSImpl_AttributeTreeNode *aNode, *aPrev;
102 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
103 aPrev = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
104 aNode->SetPrevious(aPrev);
107 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
108 SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
109 aNode->SetPrevious(aPrev);
113 bool SALOMEDS_AttributeTreeNode::HasPrevious()
117 SALOMEDS::Locker lock;
118 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
119 ret = aNode->HasPrevious();
122 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
123 ret = aNode->HasPrevious();
128 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
130 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
132 SALOMEDS::Locker lock;
133 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
134 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
137 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
138 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
140 return _PTR(AttributeTreeNode)(aTN);
143 void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
145 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
148 SALOMEDS::Locker lock;
149 SALOMEDSImpl_AttributeTreeNode *aNode, *aNext;
150 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
151 aNext = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
152 aNode->SetNext(aNext);
155 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
156 SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
157 aNode->SetNext(aNext);
161 bool SALOMEDS_AttributeTreeNode::HasNext()
165 SALOMEDS::Locker lock;
166 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
167 ret = aNode->HasNext();
170 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
171 ret = aNode->HasNext();
176 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
178 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
180 SALOMEDS::Locker lock;
181 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
182 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
185 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
186 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
188 return _PTR(AttributeTreeNode)(aTN);
191 void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
193 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
196 SALOMEDS::Locker lock;
197 SALOMEDSImpl_AttributeTreeNode *aNode, *aFirst;
198 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
199 aFirst = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
200 aNode->SetFirst(aFirst);
203 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
204 SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
205 aNode->SetFirst(aFirst);
209 bool SALOMEDS_AttributeTreeNode::HasFirst()
213 SALOMEDS::Locker lock;
214 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
215 ret = aNode->HasFirst();
218 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
219 ret = aNode->HasFirst();
224 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
226 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
228 SALOMEDS::Locker lock;
229 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
230 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
233 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
234 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
236 return _PTR(AttributeTreeNode)(aTN);
239 void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
243 SALOMEDS::Locker lock;
244 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
245 aNode->SetTreeID(value);
248 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
249 aNode->SetTreeID(value.c_str());
253 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
257 SALOMEDS::Locker lock;
258 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
259 aGUID = aNode->GetTreeID();
262 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
263 aGUID = aNode->GetTreeID();
269 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
271 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
274 SALOMEDS::Locker lock;
275 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
276 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
277 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
278 aNode->Append(anOther);
281 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
282 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
283 aNode->Append(anOther);
287 void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
289 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
292 SALOMEDS::Locker lock;
293 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
294 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
295 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
296 aNode->Prepend(anOther);
299 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
300 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
301 aNode->Prepend(anOther);
305 void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
307 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
310 SALOMEDS::Locker lock;
311 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
312 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
313 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
314 aNode->InsertBefore(anOther);
317 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
318 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
319 aNode->InsertBefore(anOther);
323 void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
325 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
328 SALOMEDS::Locker lock;
329 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
330 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
331 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
332 aNode->InsertAfter(anOther);
335 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
336 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
337 aNode->InsertAfter(anOther);
341 void SALOMEDS_AttributeTreeNode::Remove()
345 SALOMEDS::Locker lock;
346 dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Remove();
348 else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
351 int SALOMEDS_AttributeTreeNode::Depth()
355 SALOMEDS::Locker lock;
356 aDepth = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Depth();
358 else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
362 bool SALOMEDS_AttributeTreeNode::IsRoot()
366 SALOMEDS::Locker lock;
367 ret = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->IsRoot();
369 else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
373 bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
376 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
378 SALOMEDS::Locker lock;
379 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
380 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
381 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
382 ret = aNode->IsDescendant(anOther);
385 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
386 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
387 ret = aNode->IsDescendant(anOther);
392 bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
395 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
397 SALOMEDS::Locker lock;
398 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
399 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
400 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
401 ret = aNode->IsFather(anOther);
404 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
405 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
406 ret = aNode->IsFather(anOther);
411 bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
414 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
416 SALOMEDS::Locker lock;
417 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
418 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
419 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
420 ret = aNode->IsChild(anOther);
423 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
424 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
425 ret = aNode->IsChild(anOther);
430 std::string SALOMEDS_AttributeTreeNode::Label()
434 SALOMEDS::Locker lock;
435 aLabel = _local_impl->Label().Entry();
437 else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();