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