1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_AttributeTreeNode.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeTreeNode.hxx"
25 #include "SALOMEDS.hxx"
30 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
31 #include "SALOMEDS_AttributeTreeNode.hxx"
35 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDSImpl_AttributeTreeNode* theAttr)
36 :SALOMEDS_GenericAttribute(theAttr)
39 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
40 :SALOMEDS_GenericAttribute(theAttr)
43 SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
46 void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
48 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
51 SALOMEDS::Locker lock;
52 SALOMEDSImpl_AttributeTreeNode *aNode, *aFather;
53 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
54 aFather = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
55 aNode->SetFather(aFather);
58 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
59 SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
60 aNode->SetFather(aFather);
64 bool SALOMEDS_AttributeTreeNode::HasFather()
68 SALOMEDS::Locker lock;
69 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
70 ret = aNode->HasFather();
73 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
74 ret = aNode->HasFather();
79 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
81 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
83 SALOMEDS::Locker lock;
84 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
85 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
88 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
89 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
91 return _PTR(AttributeTreeNode)(aTN);
94 void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
96 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
99 SALOMEDS::Locker lock;
100 SALOMEDSImpl_AttributeTreeNode *aNode, *aPrev;
101 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
102 aPrev = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
103 aNode->SetPrevious(aPrev);
106 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
107 SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
108 aNode->SetPrevious(aPrev);
112 bool SALOMEDS_AttributeTreeNode::HasPrevious()
116 SALOMEDS::Locker lock;
117 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
118 ret = aNode->HasPrevious();
121 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
122 ret = aNode->HasPrevious();
127 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
129 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
131 SALOMEDS::Locker lock;
132 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
133 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
136 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
137 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
139 return _PTR(AttributeTreeNode)(aTN);
142 void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
144 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
147 SALOMEDS::Locker lock;
148 SALOMEDSImpl_AttributeTreeNode *aNode, *aNext;
149 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
150 aNext = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
151 aNode->SetNext(aNext);
154 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
155 SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
156 aNode->SetNext(aNext);
160 bool SALOMEDS_AttributeTreeNode::HasNext()
164 SALOMEDS::Locker lock;
165 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
166 ret = aNode->HasNext();
169 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
170 ret = aNode->HasNext();
175 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
177 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
179 SALOMEDS::Locker lock;
180 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
181 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
184 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
185 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
187 return _PTR(AttributeTreeNode)(aTN);
190 void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
192 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
195 SALOMEDS::Locker lock;
196 SALOMEDSImpl_AttributeTreeNode *aNode, *aFirst;
197 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
198 aFirst = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
199 aNode->SetFirst(aFirst);
202 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
203 SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
204 aNode->SetFirst(aFirst);
208 bool SALOMEDS_AttributeTreeNode::HasFirst()
212 SALOMEDS::Locker lock;
213 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
214 ret = aNode->HasFirst();
217 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
218 ret = aNode->HasFirst();
223 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
225 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
227 SALOMEDS::Locker lock;
228 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
229 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
232 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
233 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
235 return _PTR(AttributeTreeNode)(aTN);
238 void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
242 SALOMEDS::Locker lock;
243 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
244 aNode->SetTreeID(value);
247 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
248 aNode->SetTreeID(value.c_str());
252 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
256 SALOMEDS::Locker lock;
257 SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
258 aGUID = aNode->GetTreeID();
261 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
262 aGUID = aNode->GetTreeID();
268 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
270 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
273 SALOMEDS::Locker lock;
274 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
275 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
276 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
277 aNode->Append(anOther);
280 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
281 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
282 aNode->Append(anOther);
286 void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
288 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
291 SALOMEDS::Locker lock;
292 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
293 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
294 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
295 aNode->Prepend(anOther);
298 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
299 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
300 aNode->Prepend(anOther);
304 void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
306 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
309 SALOMEDS::Locker lock;
310 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
311 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
312 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
313 aNode->InsertBefore(anOther);
316 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
317 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
318 aNode->InsertBefore(anOther);
322 void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
324 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
327 SALOMEDS::Locker lock;
328 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
329 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
330 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
331 aNode->InsertAfter(anOther);
334 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
335 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
336 aNode->InsertAfter(anOther);
340 void SALOMEDS_AttributeTreeNode::Remove()
344 SALOMEDS::Locker lock;
345 dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Remove();
347 else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
350 int SALOMEDS_AttributeTreeNode::Depth()
354 SALOMEDS::Locker lock;
355 aDepth = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Depth();
357 else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
361 bool SALOMEDS_AttributeTreeNode::IsRoot()
365 SALOMEDS::Locker lock;
366 ret = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->IsRoot();
368 else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
372 bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
375 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
377 SALOMEDS::Locker lock;
378 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
379 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
380 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
381 ret = aNode->IsDescendant(anOther);
384 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
385 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
386 ret = aNode->IsDescendant(anOther);
391 bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
394 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
396 SALOMEDS::Locker lock;
397 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
398 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
399 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
400 ret = aNode->IsFather(anOther);
403 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
404 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
405 ret = aNode->IsFather(anOther);
410 bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
413 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
415 SALOMEDS::Locker lock;
416 SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
417 aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
418 anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
419 ret = aNode->IsChild(anOther);
422 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
423 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
424 ret = aNode->IsChild(anOther);
429 std::string SALOMEDS_AttributeTreeNode::Label()
433 SALOMEDS::Locker lock;
434 aLabel = _local_impl->Label().Entry();
436 else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();