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