Salome HOME
Preparation of 3.1.0a2 - compilation error on Fedora3 platform
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTreeNode.cxx
1 //  File   : SALOMEDS_AttributeTreeNode.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5 #include "SALOMEDS_AttributeTreeNode.hxx"
6
7 #include <string>
8 #include <TCollection_AsciiString.hxx>
9 #include <TCollection_ExtendedString.hxx>
10 #include <Standard_GUID.hxx>
11 #include <TDF_Label.hxx>
12 #include <TDF_Tool.hxx>
13
14 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
15 #include "SALOMEDS_AttributeTreeNode.hxx"
16
17 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr)
18 :SALOMEDS_GenericAttribute(theAttr)
19 {}
20
21 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
22 :SALOMEDS_GenericAttribute(theAttr)
23 {}
24
25 SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
26 {}
27
28 void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
29 {
30   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
31   if(_isLocal) {
32     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFather;
33     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
34     aFather = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
35     aNode->SetFather(aFather);
36   }
37   else {
38     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
39     SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
40     aNode->SetFather(aFather);
41   }
42 }
43
44 bool SALOMEDS_AttributeTreeNode::HasFather()
45 {
46   bool ret;
47   if(_isLocal) {
48     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
49     ret = aNode->HasFather();
50   }
51   else {
52     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
53     ret = aNode->HasFather();
54   }
55   return ret;
56 }
57
58 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
59 {
60   SALOMEDSClient_AttributeTreeNode* aTN  = NULL;
61   if(_isLocal) {
62     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
63     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
64   }
65   else {
66     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
67     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
68   }
69   return _PTR(AttributeTreeNode)(aTN);
70 }
71
72 void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
73 {
74   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
75   if(_isLocal) {
76     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aPrev;
77     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
78     aPrev = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
79     aNode->SetPrevious(aPrev);
80   }
81   else {
82     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
83     SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
84     aNode->SetPrevious(aPrev);
85   }
86 }
87
88 bool SALOMEDS_AttributeTreeNode::HasPrevious()
89 {
90   bool ret;
91   if(_isLocal) {
92     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
93     ret = aNode->HasPrevious();
94   }
95   else {
96     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
97     ret = aNode->HasPrevious();
98   }
99   return ret;
100 }
101
102 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
103 {
104   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
105   if(_isLocal) {
106     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
107     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
108   }
109   else {
110     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
111     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
112   }
113   return _PTR(AttributeTreeNode)(aTN);
114 }
115
116 void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
117 {
118   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
119   if(_isLocal) {
120     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aNext;
121     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
122     aNext = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
123     aNode->SetNext(aNext);
124   }
125   else {
126     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
127     SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
128     aNode->SetNext(aNext);
129   }
130 }
131
132 bool SALOMEDS_AttributeTreeNode::HasNext()
133 {
134   bool ret;
135   if(_isLocal) {
136     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
137     ret = aNode->HasNext();
138   }
139   else {
140     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
141     ret = aNode->HasNext();
142   }
143   return ret;
144 }
145
146 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
147 {
148   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
149   if(_isLocal) {
150     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
151     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
152   }
153   else {
154     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
155     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
156   }
157   return _PTR(AttributeTreeNode)(aTN);
158 }
159
160 void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
161 {
162   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
163   if(_isLocal) {
164     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFirst;
165     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
166     aFirst = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
167     aNode->SetFirst(aFirst);
168   }
169   else {
170     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
171     SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
172     aNode->SetFirst(aFirst);
173   }
174 }
175
176 bool SALOMEDS_AttributeTreeNode::HasFirst()
177 {
178   bool ret;
179   if(_isLocal) {
180     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
181     ret = aNode->HasFirst();
182   }
183   else {
184     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
185     ret = aNode->HasFirst();
186   }
187   return ret;
188 }
189
190 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
191 {
192   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
193   if(_isLocal) {
194     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
195     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
196   }
197   else {
198     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
199     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
200   }
201   return _PTR(AttributeTreeNode)(aTN);
202 }
203
204 void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
205 {
206   if(_isLocal) {
207     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
208     aNode->SetTreeID(Standard_GUID((char*)value.c_str()));
209   }
210   else {
211     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
212     aNode->SetTreeID(value.c_str());
213   }
214 }
215
216 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
217 {
218   TCollection_AsciiString aGUID;
219   if(_isLocal) {
220     Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
221     char guid[40];
222     aNode->GetTreeID().ToCString(guid);
223     aGUID = TCollection_AsciiString(guid);
224   }
225   else {
226     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
227     aGUID = TCollection_AsciiString(aNode->GetTreeID());
228   }
229
230   return std::string(aGUID.ToCString());
231 }
232
233 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
234 {
235   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
236   if(_isLocal) {
237     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
238     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
239     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
240     aNode->Append(anOther);
241   }
242   else {
243     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
244     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
245     aNode->Append(anOther);
246   }
247 }
248
249 void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
250 {
251   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
252   if(_isLocal) {
253     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
254     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
255     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
256     aNode->Prepend(anOther);
257   }
258   else {
259     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
260     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
261     aNode->Prepend(anOther);
262   }
263 }
264
265 void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
266 {
267   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
268   if(_isLocal) {
269     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
270     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
271     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
272     aNode->InsertBefore(anOther);
273   }
274   else {
275     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
276     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
277     aNode->InsertBefore(anOther);
278   }
279 }
280
281 void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
282 {
283   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
284   if(_isLocal) {
285     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
286     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
287     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
288     aNode->InsertAfter(anOther);
289   }
290   else {
291     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
292     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
293     aNode->InsertAfter(anOther);
294   }
295 }
296
297 void SALOMEDS_AttributeTreeNode::Remove()
298 {
299   if(_isLocal) Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove();
300   else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
301 }
302
303 int SALOMEDS_AttributeTreeNode::Depth()
304 {
305   int aDepth;
306   if(_isLocal) aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth();
307   else aDepth =  SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
308   return aDepth;
309 }
310
311 bool SALOMEDS_AttributeTreeNode::IsRoot()
312 {
313   bool ret;
314   if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot();
315   else ret =  SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
316   return ret;
317 }
318
319 bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
320 {
321   bool ret;
322   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
323   if(_isLocal) {
324     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
325     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
326     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
327     ret = aNode->IsDescendant(anOther);
328   }
329   else {
330     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
331     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
332     ret = aNode->IsDescendant(anOther);
333   }  
334   return ret;
335 }
336
337 bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
338 {
339   bool ret;
340   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
341   if(_isLocal) {
342     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
343     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
344     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
345     ret = aNode->IsFather(anOther);
346   }
347   else {
348     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
349     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
350     ret = aNode->IsFather(anOther);
351   }  
352   return ret;  
353 }
354
355 bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
356 {
357   bool ret;
358   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
359   if(_isLocal) {
360     Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
361     aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
362     anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
363     ret = aNode->IsChild(anOther);
364   }
365   else {
366     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
367     SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
368     ret = aNode->IsChild(anOther);
369   }  
370   return ret;  
371 }
372
373 std::string SALOMEDS_AttributeTreeNode::Label()
374 {
375   TCollection_AsciiString aLabel;
376   if(_isLocal) TDF_Tool::Entry(_local_impl->Label(), aLabel);
377   else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();
378   return std::string(aLabel.ToCString());
379 }
380
381