1 // File : SALOMEDS_AttributeTreeNode_i.cxx
2 // Author : Sergey RUIN
6 #include "SALOMEDS_AttributeTreeNode_i.hxx"
8 #include "SALOMEDS.hxx"
9 #include <TDocStd_Document.hxx>
10 #include <TDF_Attribute.hxx>
11 #include <TDF_Tool.hxx>
12 #include <TDF_Data.hxx>
16 static Handle(SALOMEDSImpl_AttributeTreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
17 const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode)
19 Handle(SALOMEDSImpl_AttributeTreeNode) aResult = new SALOMEDSImpl_AttributeTreeNode;
20 TCollection_AsciiString anEntry = value->Label();
22 TDF_Tool::Label(aNode->Label().Data(), anEntry, aLabel);
23 if (aLabel.IsNull()) {
24 MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
25 MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label")
28 if (!aLabel.FindAttribute(aNode->ID(), aResult)) {
29 MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute")
30 MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute")
35 void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value)
37 SALOMEDS::Locker lock;
39 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
40 aNode->SetFather(GetNode(value, aNode));
43 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather()
45 SALOMEDS::Locker lock;
46 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFather();
49 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather()
51 SALOMEDS::Locker lock;
52 SALOMEDS_AttributeTreeNode_i* aFather;
53 aFather = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFather(), _orb);
55 return aFather->POA_SALOMEDS::AttributeTreeNode::_this();
57 return aFather->AttributeTreeNode::_this();
61 void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value)
63 SALOMEDS::Locker lock;
65 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
66 aNode->SetPrevious(GetNode(value, aNode));
69 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious()
71 SALOMEDS::Locker lock;
72 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasPrevious();
75 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious()
77 SALOMEDS::Locker lock;
78 SALOMEDS_AttributeTreeNode_i* aPrevious;
79 aPrevious=new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetPrevious(), _orb);
81 return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this();
83 return aPrevious->AttributeTreeNode::_this();
87 void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value)
89 SALOMEDS::Locker lock;
91 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
92 aNode->SetNext(GetNode(value, aNode));
95 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext()
97 SALOMEDS::Locker lock;
98 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasNext();
101 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext()
103 SALOMEDS::Locker lock;
104 SALOMEDS_AttributeTreeNode_i* aNext;
105 aNext = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetNext(), _orb);
107 return aNext->POA_SALOMEDS::AttributeTreeNode::_this();
109 return aNext->AttributeTreeNode::_this();
113 void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value)
115 SALOMEDS::Locker lock;
117 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
118 aNode->SetFirst(GetNode(value, aNode));
121 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst()
123 SALOMEDS::Locker lock;
124 return Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->HasFirst();
127 SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst()
129 SALOMEDS::Locker lock;
130 SALOMEDS_AttributeTreeNode_i* aFirst;
131 aFirst = new SALOMEDS_AttributeTreeNode_i(Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl)->GetFirst(), _orb);
133 return aFirst->POA_SALOMEDS::AttributeTreeNode::_this();
135 return aFirst->AttributeTreeNode::_this();
139 void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value)
141 SALOMEDS::Locker lock;
143 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
144 aNode->SetTreeID(Standard_GUID(aNode->ID()));
147 char* SALOMEDS_AttributeTreeNode_i::GetTreeID()
149 SALOMEDS::Locker lock;
150 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
152 aNode->ID().ToCString(aGUID);
153 return CORBA::String_var(CORBA::string_dup(aGUID))._retn();
156 void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value)
158 SALOMEDS::Locker lock;
160 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
161 aNode->Append(GetNode(value, aNode));
164 void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value)
166 SALOMEDS::Locker lock;
168 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
169 aNode->Prepend(GetNode(value, aNode));
172 void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value)
174 SALOMEDS::Locker lock;
176 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
177 aNode->InsertBefore(GetNode(value, aNode));
180 void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value)
182 SALOMEDS::Locker lock;
184 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
185 aNode->InsertAfter(GetNode(value, aNode));
188 void SALOMEDS_AttributeTreeNode_i::Remove()
190 SALOMEDS::Locker lock;
192 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
196 CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth()
198 SALOMEDS::Locker lock;
199 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
200 return aNode->Depth();
203 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot()
205 SALOMEDS::Locker lock;
206 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
207 return aNode->IsRoot();
210 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr value)
212 SALOMEDS::Locker lock;
213 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
214 return aNode->IsDescendant(GetNode(value, aNode));
217 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr value)
219 SALOMEDS::Locker lock;
220 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
221 return aNode->IsFather(GetNode(value, aNode));
224 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr value)
226 SALOMEDS::Locker lock;
227 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
228 return aNode->IsChild(GetNode(value, aNode));
231 char* SALOMEDS_AttributeTreeNode_i::Label()
233 SALOMEDS::Locker lock;
234 TCollection_AsciiString aLabelName;
235 TDF_Tool::Entry(_impl->Label(),aLabelName);
236 return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn();