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