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