1 // Copyright (C) 2007-2008 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
22 // File : SALOMEDS_AttributeTreeNode.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDS_AttributeTreeNode.hxx"
27 #include "SALOMEDS.hxx"
32 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
33 #include "SALOMEDS_AttributeTreeNode.hxx"
37 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDSImpl_AttributeTreeNode* theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
41 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
42 :SALOMEDS_GenericAttribute(theAttr)
45 SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
48 void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
50 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
53 SALOMEDS::Locker lock;
54 SALOMEDSImpl_AttributeTreeNode *aNode, *aFather;
55 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
56 aFather = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
57 aNode->SetFather(aFather);
60 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
61 SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
62 aNode->SetFather(aFather);
66 bool SALOMEDS_AttributeTreeNode::HasFather()
70 SALOMEDS::Locker lock;
71 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
72 ret = aNode->HasFather();
75 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
76 ret = aNode->HasFather();
81 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
83 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
85 SALOMEDS::Locker lock;
86 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
87 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
90 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
91 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
93 return _PTR(AttributeTreeNode)(aTN);
96 void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
98 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
101 SALOMEDS::Locker lock;
102 SALOMEDSImpl_AttributeTreeNode *aNode, *aPrev;
103 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
104 aPrev = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
105 aNode->SetPrevious(aPrev);
108 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
109 SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
110 aNode->SetPrevious(aPrev);
114 bool SALOMEDS_AttributeTreeNode::HasPrevious()
118 SALOMEDS::Locker lock;
119 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
120 ret = aNode->HasPrevious();
123 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
124 ret = aNode->HasPrevious();
129 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
131 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
133 SALOMEDS::Locker lock;
134 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
135 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
138 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
139 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
141 return _PTR(AttributeTreeNode)(aTN);
144 void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
146 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
149 SALOMEDS::Locker lock;
150 SALOMEDSImpl_AttributeTreeNode *aNode, *aNext;
151 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
152 aNext = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
153 aNode->SetNext(aNext);
156 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
157 SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
158 aNode->SetNext(aNext);
162 bool SALOMEDS_AttributeTreeNode::HasNext()
166 SALOMEDS::Locker lock;
167 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
168 ret = aNode->HasNext();
171 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
172 ret = aNode->HasNext();
177 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
179 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
181 SALOMEDS::Locker lock;
182 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
183 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
186 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
187 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
189 return _PTR(AttributeTreeNode)(aTN);
192 void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
194 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
197 SALOMEDS::Locker lock;
198 SALOMEDSImpl_AttributeTreeNode *aNode, *aFirst;
199 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
200 aFirst = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
201 aNode->SetFirst(aFirst);
204 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
205 SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
206 aNode->SetFirst(aFirst);
210 bool SALOMEDS_AttributeTreeNode::HasFirst()
214 SALOMEDS::Locker lock;
215 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
216 ret = aNode->HasFirst();
219 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
220 ret = aNode->HasFirst();
225 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
227 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
229 SALOMEDS::Locker lock;
230 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
231 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
234 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
235 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
237 return _PTR(AttributeTreeNode)(aTN);
240 void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
244 SALOMEDS::Locker lock;
245 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
246 aNode->SetTreeID(value);
249 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
250 aNode->SetTreeID(value.c_str());
254 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
258 SALOMEDS::Locker lock;
259 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
260 aGUID = aNode->GetTreeID();
263 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
264 aGUID = aNode->GetTreeID();
270 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
272 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
275 SALOMEDS::Locker lock;
276 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
277 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
278 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
279 aNode->Append(anOther);
282 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
283 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
284 aNode->Append(anOther);
288 void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
290 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
293 SALOMEDS::Locker lock;
294 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
295 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
296 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
297 aNode->Prepend(anOther);
300 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
301 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
302 aNode->Prepend(anOther);
306 void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
308 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
311 SALOMEDS::Locker lock;
312 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
313 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
314 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
315 aNode->InsertBefore(anOther);
318 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
319 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
320 aNode->InsertBefore(anOther);
324 void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
326 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
329 SALOMEDS::Locker lock;
330 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
331 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
332 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
333 aNode->InsertAfter(anOther);
336 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
337 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
338 aNode->InsertAfter(anOther);
342 void SALOMEDS_AttributeTreeNode::Remove()
346 SALOMEDS::Locker lock;
347 dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Remove();
349 else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
352 int SALOMEDS_AttributeTreeNode::Depth()
356 SALOMEDS::Locker lock;
357 aDepth = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Depth();
359 else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
363 bool SALOMEDS_AttributeTreeNode::IsRoot()
367 SALOMEDS::Locker lock;
368 ret = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->IsRoot();
370 else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
374 bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
377 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
379 SALOMEDS::Locker lock;
380 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
381 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
382 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
383 ret = aNode->IsDescendant(anOther);
386 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
387 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
388 ret = aNode->IsDescendant(anOther);
393 bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
396 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
398 SALOMEDS::Locker lock;
399 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
400 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
401 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
402 ret = aNode->IsFather(anOther);
405 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
406 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
407 ret = aNode->IsFather(anOther);
412 bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
415 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
417 SALOMEDS::Locker lock;
418 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
419 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
420 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
421 ret = aNode->IsChild(anOther);
424 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
425 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
426 ret = aNode->IsChild(anOther);
431 std::string SALOMEDS_AttributeTreeNode::Label()
435 SALOMEDS::Locker lock;
436 aLabel = _local_impl->Label().Entry();
438 else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();