Salome HOME
0020523: String notebook support
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_UseCaseIterator_i.cxx
index db1624eb4335436eb20e4ab3b8815546988ec2d5..3fd6ced610eaa0ec0b525cdcc3fff430045c879f 100644 (file)
@@ -1,27 +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_UseCaseIterator_i.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
-
+//
 #include "SALOMEDS_UseCaseIterator_i.hxx"
 #include "SALOMEDS_SObject_i.hxx"
 #include "SALOMEDS.hxx"
@@ -36,11 +37,11 @@ using namespace std;
  *  Purpose  :
  */
 //============================================================================
-SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const Handle(SALOMEDSImpl_UseCaseIterator)& theImpl, 
+SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const SALOMEDSImpl_UseCaseIterator& theImpl, 
                                                       CORBA::ORB_ptr orb)
 {
   _orb = CORBA::ORB::_duplicate(orb);
-  _impl = theImpl;
+  _impl = theImpl.GetPersistentCopy();
 }
 
 //============================================================================
@@ -50,6 +51,7 @@ SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const Handle(SALOMEDSImpl
 //============================================================================
 SALOMEDS_UseCaseIterator_i::~SALOMEDS_UseCaseIterator_i()
 {
+    if(_impl) delete _impl;
 }
 
 //============================================================================
@@ -60,7 +62,7 @@ SALOMEDS_UseCaseIterator_i::~SALOMEDS_UseCaseIterator_i()
 void SALOMEDS_UseCaseIterator_i::Init(CORBA::Boolean allLevels)
 { 
   SALOMEDS::Locker lock;
-  _impl->Init(allLevels);
+  if(_impl) _impl->Init(allLevels);
 }
 
 //============================================================================
@@ -71,6 +73,7 @@ void SALOMEDS_UseCaseIterator_i::Init(CORBA::Boolean allLevels)
 CORBA::Boolean SALOMEDS_UseCaseIterator_i::More()
 {
   SALOMEDS::Locker lock;
+  if(!_impl) return false;
   return _impl->More();
 }
 
@@ -82,7 +85,7 @@ CORBA::Boolean SALOMEDS_UseCaseIterator_i::More()
 void SALOMEDS_UseCaseIterator_i::Next()
 {
   SALOMEDS::Locker lock;
-  _impl->Next();
+  if(_impl) _impl->Next();
 }
 
 
@@ -94,7 +97,8 @@ void SALOMEDS_UseCaseIterator_i::Next()
 SALOMEDS::SObject_ptr SALOMEDS_UseCaseIterator_i::Value()
 {
   SALOMEDS::Locker lock;
-  Handle(SALOMEDSImpl_SObject) aSO = _impl->Value();
+  if(!_impl) return SALOMEDS::SObject::_nil();
+  SALOMEDSImpl_SObject aSO = _impl->Value();
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
   return so._retn();
 }