Salome HOME
0020523: String notebook support
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_UseCaseBuilder.cxx
index d429516f359dd487ae8d15f21f4f9ff042298f7a..3131077e04aaa3d1c73043bf250db06e8d200d9d 100644 (file)
@@ -1,28 +1,28 @@
-// Copyright (C) 2005  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 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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
+//  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
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : SALOMEDS_UseCaseBuilder.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
-
-
+//
 #include "SALOMEDS_UseCaseBuilder.hxx"
 
 #include "SALOMEDS.hxx"
 #include "SALOMEDSImpl_SObject.hxx"
 #include "SALOMEDSImpl_UseCaseIterator.hxx"
 
-#include <TCollection_AsciiString.hxx> 
 #include <string>
 
 using namespace std; 
 
-SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(const Handle(SALOMEDSImpl_UseCaseBuilder)& theBuilder)
+SALOMEDS_UseCaseBuilder::SALOMEDS_UseCaseBuilder(SALOMEDSImpl_UseCaseBuilder* theBuilder)
 {
   _isLocal = true;
   _local_impl = theBuilder;
@@ -62,7 +61,7 @@ bool SALOMEDS_UseCaseBuilder::Append(const _PTR(SObject)& theObject)
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->Append(obj->GetLocalImpl());
+    ret = _local_impl->Append(*(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->Append(obj->GetCORBAImpl());
   return ret;
@@ -74,7 +73,7 @@ bool SALOMEDS_UseCaseBuilder::Remove(const _PTR(SObject)& theObject)
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->Remove(obj->GetLocalImpl());
+    ret = _local_impl->Remove(*(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->Remove(obj->GetCORBAImpl());
   return ret;
@@ -87,7 +86,7 @@ bool SALOMEDS_UseCaseBuilder::AppendTo(const _PTR(SObject)& theFather, _PTR(SObj
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->AppendTo(father->GetLocalImpl(), obj->GetLocalImpl());
+    ret = _local_impl->AppendTo(*(father->GetLocalImpl()), *(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->AppendTo(father->GetCORBAImpl(), obj->GetCORBAImpl());
   return ret;
@@ -100,7 +99,7 @@ bool SALOMEDS_UseCaseBuilder::InsertBefore(const _PTR(SObject)& theFirst, _PTR(S
   SALOMEDS_SObject* next = dynamic_cast<SALOMEDS_SObject*>(theNext.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->InsertBefore(first->GetLocalImpl(), next->GetLocalImpl());
+    ret = _local_impl->InsertBefore(*(first->GetLocalImpl()), *(next->GetLocalImpl()));
   }
   else ret = _corba_impl->InsertBefore(first->GetCORBAImpl(), next->GetCORBAImpl());
   return ret;
@@ -112,7 +111,7 @@ bool SALOMEDS_UseCaseBuilder::SetCurrentObject(const _PTR(SObject)& theObject)
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->SetCurrentObject(obj->GetLocalImpl());
+    ret = _local_impl->SetCurrentObject(*(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->SetCurrentObject(obj->GetCORBAImpl());
   return ret;
@@ -135,7 +134,7 @@ bool SALOMEDS_UseCaseBuilder::HasChildren(const _PTR(SObject)& theObject)
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->HasChildren(obj->GetLocalImpl());
+    ret = _local_impl->HasChildren(*(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->HasChildren(obj->GetCORBAImpl());
   return ret;
@@ -147,7 +146,7 @@ bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject)
   SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->IsUseCase(obj->GetLocalImpl());
+    ret = _local_impl->IsUseCase(*(obj->GetLocalImpl()));
   }
   else ret = _corba_impl->IsUseCase(obj->GetCORBAImpl());
   return ret;
@@ -158,7 +157,7 @@ bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName)
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = _local_impl->SetName((char*)theName.c_str());
+    ret = _local_impl->SetName(theName);
   }
   else ret = _corba_impl->SetName((char*)theName.c_str());
   return ret;
@@ -180,7 +179,7 @@ std::string SALOMEDS_UseCaseBuilder::GetName()
   std::string aName;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    aName = _local_impl->GetName().ToCString();
+    aName = _local_impl->GetName();
   }
   else aName = _corba_impl->GetName();
   return aName;
@@ -191,7 +190,7 @@ _PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName)
   SALOMEDS_SObject* obj = NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    obj = new SALOMEDS_SObject(_local_impl->AddUseCase((char*)theName.c_str()));
+    obj = new SALOMEDS_SObject(_local_impl->AddUseCase(theName));
   }
   else obj = new SALOMEDS_SObject(_corba_impl->AddUseCase((char*)theName.c_str()));
   return _PTR(SObject)(obj);
@@ -200,11 +199,19 @@ _PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName)
 _PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SObject)& theObject) 
 {
   SALOMEDS_UseCaseIterator* it = NULL;
-  SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+  SALOMEDS_SObject* obj = (theObject)?dynamic_cast<SALOMEDS_SObject*>(theObject.get()):NULL;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl()));
+    if(obj)
+      it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(*(obj->GetLocalImpl())));
+    else 
+      it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(SALOMEDSImpl_SObject()));
+  }
+  else {
+    if(obj)
+      it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
+    else
+      it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(SALOMEDS::SObject::_nil()));
   }
-  else it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
   return _PTR(UseCaseIterator)(it);
 }