Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/yacs.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 #include <TCollection_AsciiString.hxx>
28 #include <TCollection_ExtendedString.hxx>
29 #include <TColStd_HSequenceOfReal.hxx>
30
31 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
32                   (const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr)
33 :SALOMEDS_GenericAttribute(theAttr)
34 {}
35
36 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
37                   (SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
39 {}
40
41 SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
42 {}
43
44 void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
45 {
46   int i, aLength = other.size();
47   if (_isLocal) {
48     CheckLocked();
49     SALOMEDS::Locker lock; 
50     Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
51     for (i = 0; i < aLength; i++) aSeq->Append(other[i]);
52     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq);
53   }
54   else {
55     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
56     aSeq->length(aLength);
57     for (i = 0; i < aLength; i++) aSeq[i] = other[i];
58     SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
59   }
60 }
61
62 std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
63 {
64   std::vector<double> aVector;
65   int i, aLength;
66   if (_isLocal) {
67     SALOMEDS::Locker lock; 
68     Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr;
69     aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl);
70     aLength = aSeqAttr->Length();
71     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
72   }
73   else {
74     SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
75     aLength = aSeqAttr->Length();
76     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
77   }
78   return aVector;
79 }
80
81 void SALOMEDS_AttributeSequenceOfReal::Add(double value)
82 {
83   if (_isLocal) {
84     CheckLocked();
85     SALOMEDS::Locker lock; 
86     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value);
87   }
88   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
89 }
90
91 void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
92 {
93   if (_isLocal) {
94     CheckLocked();
95     SALOMEDS::Locker lock; 
96     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index);
97   }
98   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
99 }
100
101 void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
102 {
103   if (_isLocal) {
104     CheckLocked();
105     SALOMEDS::Locker lock; 
106     Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value);
107   }
108   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
109 }
110
111 double SALOMEDS_AttributeSequenceOfReal::Value(int index)
112 {
113   double aValue;
114   if (_isLocal) {
115     SALOMEDS::Locker lock; 
116     aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index);
117   }
118   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
119   return aValue;
120 }
121
122 int SALOMEDS_AttributeSequenceOfReal::Length()
123 {
124   int aValue;
125   if (_isLocal) {
126     SALOMEDS::Locker lock; 
127     aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length();
128   }
129   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
130   return aValue;
131 }