Back to index

salome-kernel  6.5.0
SALOMEDS_UseCaseIterator.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDS_UseCaseIterator.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_UseCaseIterator.hxx"
00028 
00029 #include "SALOMEDS.hxx"
00030 #include "SALOMEDS_SObject.hxx"
00031 
00032 SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(const SALOMEDSImpl_UseCaseIterator& theIterator)
00033 {
00034   _isLocal = true;
00035   _local_impl = theIterator.GetPersistentCopy();
00036   _corba_impl = SALOMEDS::UseCaseIterator::_nil();
00037 }
00038 
00039 SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(SALOMEDS::UseCaseIterator_ptr theIterator)
00040 {
00041   _isLocal = false;
00042   _corba_impl = SALOMEDS::UseCaseIterator::_duplicate(theIterator);
00043 }
00044 
00045 SALOMEDS_UseCaseIterator::~SALOMEDS_UseCaseIterator()
00046 {
00047   if(!_isLocal) _corba_impl->UnRegister();    
00048   else if(_local_impl) delete _local_impl;
00049 }
00050 
00051 void SALOMEDS_UseCaseIterator::Init(bool theAllLevels)
00052 {
00053   if (_isLocal) {
00054     SALOMEDS::Locker lock;
00055     if(_local_impl) _local_impl->Init(theAllLevels);
00056   }
00057   else _corba_impl->Init(theAllLevels);
00058 }
00059 
00060 bool SALOMEDS_UseCaseIterator::More()
00061 {
00062   bool ret = false;
00063   if (_isLocal) {
00064     SALOMEDS::Locker lock;
00065     if(_local_impl) ret = _local_impl->More();
00066   }
00067   else ret = _corba_impl->More();
00068   return ret;
00069 }
00070 
00071 void SALOMEDS_UseCaseIterator::Next()
00072 {
00073   if (_isLocal) {
00074     SALOMEDS::Locker lock;
00075     if(_local_impl) _local_impl->Next();
00076   }
00077   else _corba_impl->Next();
00078 }
00079 
00080 _PTR(SObject) SALOMEDS_UseCaseIterator::Value()
00081 {
00082   SALOMEDS_SObject* aSO = NULL;
00083   if (_isLocal) {
00084     SALOMEDS::Locker lock;
00085     if(_local_impl) aSO = new SALOMEDS_SObject(_local_impl->Value());
00086   }
00087   else aSO = new SALOMEDS_SObject(_corba_impl->Value());
00088   return _PTR(SObject)(aSO);
00089 }