Salome HOME
updated copyright message
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTreeNode.cxx
index 2d2df71641a4dbe4b607cabd656bb729f69391c7..a674afabd481154dc849d76c0934b0a6c0d842c3 100644 (file)
@@ -1,41 +1,39 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  File   : SALOMEDS_AttributeTreeNode.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
+//
 #include "SALOMEDS_AttributeTreeNode.hxx"
 #include "SALOMEDS.hxx"
 
 #include <string>
-
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <Standard_GUID.hxx>
-#include <TDF_Label.hxx>
-#include <TDF_Tool.hxx>
+#include <stdexcept>
 
 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
 #include "SALOMEDS_AttributeTreeNode.hxx"
 
-SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr)
+SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDSImpl_AttributeTreeNode* theAttr)
 :SALOMEDS_GenericAttribute(theAttr)
 {}
 
@@ -52,9 +50,9 @@ void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFather;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    aFather = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *aFather;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aFather = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->SetFather(aFather);
   }
   else {
@@ -69,8 +67,7 @@ bool SALOMEDS_AttributeTreeNode::HasFather()
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     ret = aNode->HasFather();
   }
   else {
@@ -85,8 +82,7 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
   SALOMEDSClient_AttributeTreeNode* aTN  = NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
   }
   else {
@@ -102,9 +98,9 @@ void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& valu
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aPrev;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    aPrev = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *aPrev;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aPrev = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->SetPrevious(aPrev);
   }
   else {
@@ -119,8 +115,7 @@ bool SALOMEDS_AttributeTreeNode::HasPrevious()
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     ret = aNode->HasPrevious();
   }
   else {
@@ -135,8 +130,7 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
   }
   else {
@@ -152,9 +146,9 @@ void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aNext;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    aNext = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode  *aNode, *aNext;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aNext = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->SetNext(aNext);
   }
   else {
@@ -169,8 +163,7 @@ bool SALOMEDS_AttributeTreeNode::HasNext()
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     ret = aNode->HasNext();
   }
   else {
@@ -185,8 +178,7 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
   }
   else {
@@ -202,9 +194,9 @@ void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFirst;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    aFirst = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *aFirst;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aFirst = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->SetFirst(aFirst);
   }
   else {
@@ -219,8 +211,7 @@ bool SALOMEDS_AttributeTreeNode::HasFirst()
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     ret = aNode->HasFirst();
   }
   else {
@@ -235,8 +226,7 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
   SALOMEDSClient_AttributeTreeNode* aTN = NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
     aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
   }
   else {
@@ -251,9 +241,8 @@ void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    aNode->SetTreeID(Standard_GUID((char*)value.c_str()));
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aNode->SetTreeID(value);
   }
   else {
     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
@@ -263,21 +252,18 @@ void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
 
 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
 {
-  TCollection_AsciiString aGUID;
+  std::string aGUID;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode =
-      Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    char guid[40];
-    aNode->GetTreeID().ToCString(guid);
-    aGUID = TCollection_AsciiString(guid);
+    SALOMEDSImpl_AttributeTreeNode* aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    aGUID = aNode->GetTreeID();
   }
   else {
     SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
-    aGUID = TCollection_AsciiString(aNode->GetTreeID());
+    aGUID = aNode->GetTreeID();
   }
 
-  return std::string(aGUID.ToCString());
+  return aGUID;
 }
 
 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
@@ -286,9 +272,9 @@ void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->Append(anOther);
   }
   else {
@@ -304,9 +290,9 @@ void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->Prepend(anOther);
   }
   else {
@@ -322,9 +308,9 @@ void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& val
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->InsertBefore(anOther);
   }
   else {
@@ -340,9 +326,9 @@ void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& valu
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     aNode->InsertAfter(anOther);
   }
   else {
@@ -357,7 +343,7 @@ void SALOMEDS_AttributeTreeNode::Remove()
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove();
+    dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Remove();
   }
   else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
 }
@@ -367,7 +353,7 @@ int SALOMEDS_AttributeTreeNode::Depth()
   int aDepth;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth();
+    aDepth = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->Depth();
   }
   else aDepth =  SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
   return aDepth;
@@ -378,7 +364,7 @@ bool SALOMEDS_AttributeTreeNode::IsRoot()
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot();
+    ret = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl)->IsRoot();
   }
   else ret =  SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
   return ret;
@@ -390,9 +376,9 @@ bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& val
   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     ret = aNode->IsDescendant(anOther);
   }
   else {
@@ -409,9 +395,9 @@ bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     ret = aNode->IsFather(anOther);
   }
   else {
@@ -428,9 +414,9 @@ bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
   SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
-    aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
-    anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
+    SALOMEDSImpl_AttributeTreeNode *aNode, *anOther;
+    aNode = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(_local_impl);
+    anOther = dynamic_cast<SALOMEDSImpl_AttributeTreeNode*>(aTN->_local_impl);
     ret = aNode->IsChild(anOther);
   }
   else {
@@ -443,12 +429,10 @@ bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
 
 std::string SALOMEDS_AttributeTreeNode::Label()
 {
-  string aLabel;
+  std::string aLabel;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    TCollection_AsciiString anAsciiLabel;
-    TDF_Tool::Entry(_local_impl->Label(), anAsciiLabel);
-    aLabel = std::string(anAsciiLabel.ToCString());
+    aLabel = _local_impl->Label().Entry();
   }
   else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();
   return aLabel;