Back to index

salome-kernel  6.5.0
SALOMEDS_AttributeSequenceOfInteger.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDS_AttributeSequenceOfInteger.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_AttributeSequenceOfInteger.hxx"
00028 #include "SALOMEDS.hxx"
00029 
00030 SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger
00031                   (SALOMEDSImpl_AttributeSequenceOfInteger* theAttr)
00032 :SALOMEDS_GenericAttribute(theAttr)
00033 {}
00034 
00035 SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger
00036                   (SALOMEDS::AttributeSequenceOfInteger_ptr theAttr)
00037 :SALOMEDS_GenericAttribute(theAttr)
00038 {}
00039 
00040 SALOMEDS_AttributeSequenceOfInteger::~SALOMEDS_AttributeSequenceOfInteger()
00041 {}
00042 
00043 void SALOMEDS_AttributeSequenceOfInteger::Assign(const std::vector<int>& other)
00044 {
00045   int i, aLength = other.size();
00046   if (_isLocal) {
00047     CheckLocked();
00048     SALOMEDS::Locker lock;
00049     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)->Assign(other);
00050   }
00051   else {
00052     SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
00053     aSeq->length(aLength);
00054     for (i = 0; i < aLength; i++) aSeq[i] = other[i];
00055     SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Assign(aSeq);
00056   }
00057 }
00058 
00059 std::vector<int> SALOMEDS_AttributeSequenceOfInteger::CorbaSequence()
00060 {
00061   std::vector<int> aVector;
00062   int i, aLength;
00063   if (_isLocal) {
00064     SALOMEDS::Locker lock;
00065     SALOMEDSImpl_AttributeSequenceOfInteger* aSeqAttr;
00066     aSeqAttr = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl);
00067     aLength = aSeqAttr->Length();
00068     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
00069   }
00070   else {
00071     SALOMEDS::AttributeSequenceOfInteger_var aSeqAttr =
00072       SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl);
00073     aLength = aSeqAttr->Length();
00074     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
00075   }
00076   return aVector;
00077 }
00078 
00079 void SALOMEDS_AttributeSequenceOfInteger::Add(int value)
00080 {
00081   if (_isLocal) {
00082     CheckLocked();
00083     SALOMEDS::Locker lock;
00084     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)->Add(value);
00085   }
00086   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Add(value);
00087 }
00088 
00089 void SALOMEDS_AttributeSequenceOfInteger::Remove(int index)
00090 {
00091   if (_isLocal) {
00092     CheckLocked();
00093     SALOMEDS::Locker lock;
00094     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)->Remove(index);
00095   }
00096   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Remove(index);
00097 }
00098 
00099 void SALOMEDS_AttributeSequenceOfInteger::ChangeValue(int index, int value)
00100 {
00101   if (_isLocal) {
00102     CheckLocked();
00103     SALOMEDS::Locker lock;
00104     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)->ChangeValue(index, value);
00105   }
00106   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->ChangeValue(index, value);
00107 }
00108 
00109 int SALOMEDS_AttributeSequenceOfInteger::Value(int index)
00110 {
00111   int aValue;
00112   if (_isLocal) {
00113     SALOMEDS::Locker lock;
00114     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)->Value(index);
00115   }
00116   else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Value(index);
00117   return aValue;
00118 }
00119 
00120 int SALOMEDS_AttributeSequenceOfInteger::Length()
00121 {
00122   int aValue;
00123   if (_isLocal) {
00124     SALOMEDS::Locker lock;
00125     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfInteger*>(_local_impl)-> Length();
00126   }
00127   else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)-> Length();
00128   return aValue;
00129 }