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