Salome HOME
Fix pb. with loading of last module (in list).
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SComponentIterator.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDS_SComponentIterator.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #include "SALOMEDS_SComponentIterator.hxx"
25
26 #include "SALOMEDS.hxx"
27 #include "SALOMEDS_SComponent.hxx"
28 #include "SALOMEDSImpl_SComponent.hxx"
29
30 SALOMEDS_SComponentIterator::SALOMEDS_SComponentIterator(const SALOMEDSImpl_SComponentIterator& theIterator)
31 :_local_impl(theIterator.GetPersistentCopy())
32 {
33   _isLocal = true;
34   _corba_impl = SALOMEDS::SComponentIterator::_nil();
35 }
36
37 SALOMEDS_SComponentIterator::SALOMEDS_SComponentIterator(SALOMEDS::SComponentIterator_ptr theIterator)
38 {
39   _isLocal = false;
40   _corba_impl = SALOMEDS::SComponentIterator::_duplicate(theIterator);
41 }
42
43 SALOMEDS_SComponentIterator::~SALOMEDS_SComponentIterator()
44 {
45   if(!_isLocal) _corba_impl->Destroy(); 
46   else if(_local_impl) delete _local_impl;
47 }
48
49 void SALOMEDS_SComponentIterator::Init()
50 {
51   if (_isLocal) {
52     SALOMEDS::Locker lock; 
53     _local_impl->Init();
54   }
55   else _corba_impl->Init();
56 }
57
58 bool SALOMEDS_SComponentIterator::More()
59 {
60   bool ret;
61   if (_isLocal) {
62     SALOMEDS::Locker lock; 
63     ret = _local_impl->More();
64   }
65   else ret = _corba_impl->More();
66   return ret;
67 }
68
69 void SALOMEDS_SComponentIterator::Next()
70 {
71   if (_isLocal) {
72     SALOMEDS::Locker lock; 
73     _local_impl->Next();
74   }
75   else _corba_impl->Next();
76 }
77
78 _PTR(SComponent) SALOMEDS_SComponentIterator::Value()  
79 {
80   SALOMEDSClient_SComponent* aSCO = NULL;
81   if (_isLocal) {
82     SALOMEDS::Locker lock; 
83     aSCO = new SALOMEDS_SComponent(_local_impl->Value());
84   }
85   else aSCO = new SALOMEDS_SComponent(_corba_impl->Value());
86   return _PTR(SComponent)(aSCO);
87 }