Salome HOME
PR: mergefrom branch BR_V3_1_0_PR tag mergeto_trunk_02feb06
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_UseCaseIterator.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/
19 //
20 //  File   : SALOMEDS_UseCaseIterator.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25
26 #include "SALOMEDS_UseCaseIterator.hxx"
27
28 #include "SALOMEDS.hxx"
29 #include "SALOMEDS_SObject.hxx"
30
31 using namespace std; 
32
33 SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(const Handle(SALOMEDSImpl_UseCaseIterator)& theIterator)
34 {
35   _isLocal = true;
36   _local_impl = theIterator;
37   _corba_impl = SALOMEDS::UseCaseIterator::_nil();
38 }
39
40 SALOMEDS_UseCaseIterator::SALOMEDS_UseCaseIterator(SALOMEDS::UseCaseIterator_ptr theIterator)
41 {
42   _isLocal = false;
43   _local_impl = NULL;
44   _corba_impl = SALOMEDS::UseCaseIterator::_duplicate(theIterator);
45 }
46
47 SALOMEDS_UseCaseIterator::~SALOMEDS_UseCaseIterator()
48 {
49   if(!_isLocal) _corba_impl->Destroy();    
50 }
51
52 void SALOMEDS_UseCaseIterator::Init(bool theAllLevels)
53 {
54   if (_isLocal) {
55     SALOMEDS::Locker lock;
56     _local_impl->Init(theAllLevels);
57   }
58   else _corba_impl->Init(theAllLevels);
59 }
60
61 bool SALOMEDS_UseCaseIterator::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_UseCaseIterator::Next()
73 {
74   if (_isLocal) {
75     SALOMEDS::Locker lock;
76     _local_impl->Next();
77   }
78   else _corba_impl->Next();
79 }
80
81 _PTR(SObject) SALOMEDS_UseCaseIterator::Value()
82 {
83   SALOMEDS_SObject* aSO;
84   if (_isLocal) {
85     SALOMEDS::Locker lock;
86     aSO = new SALOMEDS_SObject(_local_impl->Value());
87   }
88   else aSO = new SALOMEDS_SObject(_corba_impl->Value());
89   return _PTR(SObject)(aSO);
90 }