Back to index

salome-kernel  6.5.0
SALOMEDS_ChildIterator.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_ChildIterator.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_ChildIterator.hxx"
00028 #include "SALOMEDS_SObject.hxx"
00029 #include "SALOMEDS.hxx"
00030 
00031 SALOMEDS_ChildIterator::SALOMEDS_ChildIterator(const SALOMEDSImpl_ChildIterator& theIterator)
00032 {
00033   SALOMEDS::Locker lock;
00034 
00035   _isLocal = true;
00036   _local_impl = theIterator.GetPersistentCopy();
00037   _corba_impl = SALOMEDS::ChildIterator::_nil();
00038 }
00039 
00040 SALOMEDS_ChildIterator::SALOMEDS_ChildIterator(SALOMEDS::ChildIterator_ptr theIterator)
00041 {
00042   _isLocal = false;
00043   _corba_impl = SALOMEDS::ChildIterator::_duplicate(theIterator);
00044 }
00045 
00046 SALOMEDS_ChildIterator::~SALOMEDS_ChildIterator()
00047 {
00048   if(!_isLocal) _corba_impl->UnRegister(); 
00049   else if(_local_impl) delete _local_impl;
00050 }
00051 
00052 void SALOMEDS_ChildIterator::Init()
00053 {
00054   if (_isLocal) {
00055     SALOMEDS::Locker lock;
00056     _local_impl->Init();
00057   }
00058   else _corba_impl->Init();
00059 }
00060 
00061 void SALOMEDS_ChildIterator::InitEx(bool theAllLevels)
00062 {
00063   if (_isLocal) {
00064     SALOMEDS::Locker lock;
00065     _local_impl->InitEx(theAllLevels);
00066   }
00067   else _corba_impl->InitEx(theAllLevels);
00068 }
00069 
00070 bool SALOMEDS_ChildIterator::More()
00071 {
00072   bool ret = false;
00073   if (_isLocal) {
00074     SALOMEDS::Locker lock;
00075     ret = _local_impl->More();
00076   }
00077   else ret = _corba_impl->More();
00078   return ret;
00079 }
00080 
00081 void SALOMEDS_ChildIterator::Next() 
00082 {
00083   if (_isLocal) {
00084     SALOMEDS::Locker lock;
00085     _local_impl->Next();
00086   }
00087   else _corba_impl->Next();
00088 }
00089 
00090 _PTR(SObject) SALOMEDS_ChildIterator::Value()
00091 {
00092   SALOMEDSClient_SObject* aSO;
00093   if (_isLocal) {
00094     SALOMEDS::Locker lock;
00095     aSO = new SALOMEDS_SObject(_local_impl->Value());
00096   }
00097   else {
00098     SALOMEDS::SObject_var so=_corba_impl->Value();
00099     aSO = new SALOMEDS_SObject(so);
00100   }
00101   return _PTR(SObject)(aSO);
00102 }