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_i.cxx
21 // Author : Sergey RUIN
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>
35 static Handle(SALOMEDSImpl_AttributeTreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
36 const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode)
38 Handle(SALOMEDSImpl_AttributeTreeNode) aResult = new SALOMEDSImpl_AttributeTreeNode;
39 TCollection_AsciiString anEntry = value->Label();
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")
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")
54 void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value)
56 SALOMEDS::Locker lock;
58 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
59 aNode->SetFather(GetNode(value, aNode));
62 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather()
64 SALOMEDS::Locker lock;
65 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFather();
68 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather()
70 SALOMEDS::Locker lock;
71 SALOMEDS_AttributeTreeNode_i* aFather;
72 aFather = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFather(), _orb);
74 return aFather->POA_SALOMEDS::AttributeTreeNode::_this();
76 return aFather->AttributeTreeNode::_this();
80 void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value)
82 SALOMEDS::Locker lock;
84 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
85 aNode->SetPrevious(GetNode(value, aNode));
88 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious()
90 SALOMEDS::Locker lock;
91 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasPrevious();
94 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious()
96 SALOMEDS::Locker lock;
97 SALOMEDS_AttributeTreeNode_i* aPrevious;
98 aPrevious=new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetPrevious(), _orb);
100 return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this();
102 return aPrevious->AttributeTreeNode::_this();
106 void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value)
108 SALOMEDS::Locker lock;
110 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
111 aNode->SetNext(GetNode(value, aNode));
114 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext()
116 SALOMEDS::Locker lock;
117 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasNext();
120 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext()
122 SALOMEDS::Locker lock;
123 SALOMEDS_AttributeTreeNode_i* aNext;
124 aNext = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetNext(), _orb);
126 return aNext->POA_SALOMEDS::AttributeTreeNode::_this();
128 return aNext->AttributeTreeNode::_this();
132 void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value)
134 SALOMEDS::Locker lock;
136 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
137 aNode->SetFirst(GetNode(value, aNode));
140 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst()
142 SALOMEDS::Locker lock;
143 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFirst();
146 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst()
148 SALOMEDS::Locker lock;
149 SALOMEDS_AttributeTreeNode_i* aFirst;
150 aFirst = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFirst(), _orb);
152 return aFirst->POA_SALOMEDS::AttributeTreeNode::_this();
154 return aFirst->AttributeTreeNode::_this();
158 void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value)
160 SALOMEDS::Locker lock;
162 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
163 aNode->SetTreeID(Standard_GUID(aNode->ID()));
166 char* SALOMEDS_AttributeTreeNode_i::GetTreeID()
168 SALOMEDS::Locker lock;
169 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
171 aNode->ID().ToCString(aGUID);
172 return CORBA::String_var(CORBA::string_dup(aGUID))._retn();
175 void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value)
177 SALOMEDS::Locker lock;
179 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
180 aNode->Append(GetNode(value, aNode));
183 void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value)
185 SALOMEDS::Locker lock;
187 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
188 aNode->Prepend(GetNode(value, aNode));
191 void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value)
193 SALOMEDS::Locker lock;
195 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
196 aNode->InsertBefore(GetNode(value, aNode));
199 void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value)
201 SALOMEDS::Locker lock;
203 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
204 aNode->InsertAfter(GetNode(value, aNode));
207 void SALOMEDS_AttributeTreeNode_i::Remove()
209 SALOMEDS::Locker lock;
211 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
215 CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth()
217 SALOMEDS::Locker lock;
218 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
219 return aNode->Depth();
222 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot()
224 SALOMEDS::Locker lock;
225 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
226 return aNode->IsRoot();
229 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr value)
231 SALOMEDS::Locker lock;
232 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
233 return aNode->IsDescendant(GetNode(value, aNode));
236 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr value)
238 SALOMEDS::Locker lock;
239 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
240 return aNode->IsFather(GetNode(value, aNode));
243 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr value)
245 SALOMEDS::Locker lock;
246 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
247 return aNode->IsChild(GetNode(value, aNode));
250 char* SALOMEDS_AttributeTreeNode_i::Label()
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();