Salome HOME
Integrate missing files
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTreeNode_i.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDS_AttributeTreeNode_i.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDS_AttributeTreeNode_i.hxx"
26 #include "utilities.h"
27 #include "SALOMEDS.hxx"
28 #include <TDocStd_Document.hxx>
29 #include <TDF_Attribute.hxx>
30 #include <TDF_Tool.hxx>
31 #include <TDF_Data.hxx>
32
33 using namespace std;
34
35 static Handle(SALOMEDSImpl_AttributeTreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
36                                                       const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode) 
37 {
38   Handle(SALOMEDSImpl_AttributeTreeNode) aResult = new SALOMEDSImpl_AttributeTreeNode;
39   TCollection_AsciiString anEntry = value->Label();
40   TDF_Label aLabel;
41   TDF_Tool::Label(aNode->Label().Data(), anEntry, aLabel);
42   if (aLabel.IsNull()) {
43     MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
44     MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
45     return aResult;
46   }
47   if (!aLabel.FindAttribute(aNode->ID(), aResult)) {
48     MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute")
49     MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute")
50   }
51   return aResult;
52 }
53
54 void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value) 
55 {
56   SALOMEDS::Locker lock;
57   CheckLocked();
58   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
59   aNode->SetFather(GetNode(value, aNode));
60 }
61
62 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather() 
63 {
64   SALOMEDS::Locker lock;
65   return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFather();
66 }
67
68 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather() 
69 {
70   SALOMEDS::Locker lock;
71   SALOMEDS_AttributeTreeNode_i* aFather;
72   aFather = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFather(), _orb);
73 #ifndef WNT
74   return aFather->POA_SALOMEDS::AttributeTreeNode::_this();
75 #else
76   return aFather->AttributeTreeNode::_this();
77 #endif
78 }
79
80 void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value) 
81 {
82   SALOMEDS::Locker lock;
83   CheckLocked();
84   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
85   aNode->SetPrevious(GetNode(value, aNode));
86 }
87
88 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious() 
89 {
90   SALOMEDS::Locker lock;
91   return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasPrevious();
92 }
93
94 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious() 
95 {
96   SALOMEDS::Locker lock;
97   SALOMEDS_AttributeTreeNode_i* aPrevious;
98   aPrevious=new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetPrevious(), _orb);
99 #ifndef WNT
100   return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this();
101 #else
102   return aPrevious->AttributeTreeNode::_this();
103 #endif
104 }
105
106 void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value) 
107 {
108   SALOMEDS::Locker lock;
109   CheckLocked();
110   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
111   aNode->SetNext(GetNode(value, aNode));
112 }
113
114 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext() 
115 {
116   SALOMEDS::Locker lock;
117   return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasNext();
118 }
119
120 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext() 
121 {
122   SALOMEDS::Locker lock;
123   SALOMEDS_AttributeTreeNode_i* aNext;
124   aNext = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetNext(), _orb);
125 #ifndef WNT
126   return aNext->POA_SALOMEDS::AttributeTreeNode::_this();
127 #else
128   return aNext->AttributeTreeNode::_this();
129 #endif
130 }
131
132 void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value) 
133 {
134   SALOMEDS::Locker lock;
135   CheckLocked();
136   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
137   aNode->SetFirst(GetNode(value, aNode));
138 }
139
140 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst() 
141 {
142   SALOMEDS::Locker lock;
143   return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFirst();
144 }
145
146 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst() 
147 {
148   SALOMEDS::Locker lock;
149   SALOMEDS_AttributeTreeNode_i* aFirst;
150   aFirst = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFirst(), _orb);
151 #ifndef WNT
152   return aFirst->POA_SALOMEDS::AttributeTreeNode::_this();
153 #else
154   return aFirst->AttributeTreeNode::_this();
155 #endif
156 }
157
158 void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value) 
159 {
160   SALOMEDS::Locker lock;
161   CheckLocked();
162   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
163   aNode->SetTreeID(Standard_GUID((char*)value));
164 }
165
166 char* SALOMEDS_AttributeTreeNode_i::GetTreeID() 
167 {
168   SALOMEDS::Locker lock;
169   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
170   char aGUID[40];
171   aNode->ID().ToCString(aGUID);
172   return CORBA::String_var(CORBA::string_dup(aGUID))._retn();
173 }
174
175 void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value) 
176 {
177   SALOMEDS::Locker lock;
178   CheckLocked();
179   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
180   aNode->Append(GetNode(value, aNode));
181 }
182
183 void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value) 
184 {
185   SALOMEDS::Locker lock;
186   CheckLocked();
187   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
188   aNode->Prepend(GetNode(value, aNode));
189 }
190
191 void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value) 
192 {
193   SALOMEDS::Locker lock;
194   CheckLocked();
195   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
196   aNode->InsertBefore(GetNode(value, aNode));
197 }
198
199 void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value) 
200 {
201   SALOMEDS::Locker lock;
202   CheckLocked();
203   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
204   aNode->InsertAfter(GetNode(value, aNode));
205 }
206
207 void SALOMEDS_AttributeTreeNode_i::Remove() 
208 {
209   SALOMEDS::Locker lock;
210   CheckLocked();
211   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
212   aNode->Remove();
213 }
214
215 CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth() 
216 {
217   SALOMEDS::Locker lock;
218   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
219   return aNode->Depth();
220 }
221
222 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot() 
223 {
224   SALOMEDS::Locker lock;
225   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
226   return aNode->IsRoot();
227 }
228
229 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr value) 
230 {
231   SALOMEDS::Locker lock;
232   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
233   return aNode->IsDescendant(GetNode(value, aNode));
234 }
235
236 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr value) 
237 {
238   SALOMEDS::Locker lock;
239   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
240   return aNode->IsFather(GetNode(value, aNode));
241 }
242
243 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr value) 
244 {
245   SALOMEDS::Locker lock;
246   Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
247   return aNode->IsChild(GetNode(value, aNode));
248 }
249
250 char* SALOMEDS_AttributeTreeNode_i::Label() 
251 {
252   SALOMEDS::Locker lock;
253   TCollection_AsciiString aLabelName;
254   TDF_Tool::Entry(_impl->Label(),aLabelName);
255   return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn();
256 }
257