Salome HOME
A patch from Paul RASCLE for: kernel documentation with doxygen, modification on...
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeSequenceOfReal.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_AttributeSequenceOfReal.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #include "SALOMEDS_AttributeSequenceOfReal.hxx"
25 #include "SALOMEDS.hxx"
26
27 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
28                   (SALOMEDSImpl_AttributeSequenceOfReal* theAttr)
29 :SALOMEDS_GenericAttribute(theAttr)
30 {}
31
32 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
33                   (SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
34 :SALOMEDS_GenericAttribute(theAttr)
35 {}
36
37 SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
38 {}
39
40 void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
41 {
42   int i, aLength = other.size();
43   if (_isLocal) {
44     CheckLocked();
45     SALOMEDS::Locker lock; 
46     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Assign(other);
47   }
48   else {
49     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
50     aSeq->length(aLength);
51     for (i = 0; i < aLength; i++) aSeq[i] = other[i];
52     SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
53   }
54 }
55
56 std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
57 {
58   std::vector<double> aVector;
59   int i, aLength;
60   if (_isLocal) {
61     SALOMEDS::Locker lock; 
62     SALOMEDSImpl_AttributeSequenceOfReal* aSeqAttr = NULL;
63     aSeqAttr = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl);
64     aLength = aSeqAttr->Length();
65     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
66   }
67   else {
68     SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
69     aLength = aSeqAttr->Length();
70     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
71   }
72   return aVector;
73 }
74
75 void SALOMEDS_AttributeSequenceOfReal::Add(double value)
76 {
77   if (_isLocal) {
78     CheckLocked();
79     SALOMEDS::Locker lock; 
80     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Add(value);
81   }
82   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
83 }
84
85 void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
86 {
87   if (_isLocal) {
88     CheckLocked();
89     SALOMEDS::Locker lock; 
90     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Remove(index);
91   }
92   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
93 }
94
95 void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
96 {
97   if (_isLocal) {
98     CheckLocked();
99     SALOMEDS::Locker lock; 
100     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->ChangeValue(index, value);
101   }
102   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
103 }
104
105 double SALOMEDS_AttributeSequenceOfReal::Value(int index)
106 {
107   double aValue;
108   if (_isLocal) {
109     SALOMEDS::Locker lock; 
110     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Value(index);
111   }
112   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
113   return aValue;
114 }
115
116 int SALOMEDS_AttributeSequenceOfReal::Length()
117 {
118   int aValue;
119   if (_isLocal) {
120     SALOMEDS::Locker lock; 
121     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)-> Length();
122   }
123   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
124   return aValue;
125 }