Back to index

salome-kernel  6.5.0
SALOMEDS_AttributeSequenceOfReal.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_AttributeSequenceOfReal.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_AttributeSequenceOfReal.hxx"
00028 #include "SALOMEDS.hxx"
00029 
00030 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
00031                   (SALOMEDSImpl_AttributeSequenceOfReal* theAttr)
00032 :SALOMEDS_GenericAttribute(theAttr)
00033 {}
00034 
00035 SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal
00036                   (SALOMEDS::AttributeSequenceOfReal_ptr theAttr)
00037 :SALOMEDS_GenericAttribute(theAttr)
00038 {}
00039 
00040 SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal()
00041 {}
00042 
00043 void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector<double>& other)
00044 {
00045   int i, aLength = other.size();
00046   if (_isLocal) {
00047     CheckLocked();
00048     SALOMEDS::Locker lock; 
00049     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Assign(other);
00050   }
00051   else {
00052     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
00053     aSeq->length(aLength);
00054     for (i = 0; i < aLength; i++) aSeq[i] = other[i];
00055     SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq);
00056   }
00057 }
00058 
00059 std::vector<double> SALOMEDS_AttributeSequenceOfReal::CorbaSequence()
00060 {
00061   std::vector<double> aVector;
00062   int i, aLength;
00063   if (_isLocal) {
00064     SALOMEDS::Locker lock; 
00065     SALOMEDSImpl_AttributeSequenceOfReal* aSeqAttr = NULL;
00066     aSeqAttr = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl);
00067     aLength = aSeqAttr->Length();
00068     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
00069   }
00070   else {
00071     SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl);
00072     aLength = aSeqAttr->Length();
00073     for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
00074   }
00075   return aVector;
00076 }
00077 
00078 void SALOMEDS_AttributeSequenceOfReal::Add(double value)
00079 {
00080   if (_isLocal) {
00081     CheckLocked();
00082     SALOMEDS::Locker lock; 
00083     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Add(value);
00084   }
00085   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value);
00086 }
00087 
00088 void SALOMEDS_AttributeSequenceOfReal::Remove(int index)
00089 {
00090   if (_isLocal) {
00091     CheckLocked();
00092     SALOMEDS::Locker lock; 
00093     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Remove(index);
00094   }
00095   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index);
00096 }
00097 
00098 void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value)
00099 {
00100   if (_isLocal) {
00101     CheckLocked();
00102     SALOMEDS::Locker lock; 
00103     dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->ChangeValue(index, value);
00104   }
00105   else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value);
00106 }
00107 
00108 double SALOMEDS_AttributeSequenceOfReal::Value(int index)
00109 {
00110   double aValue;
00111   if (_isLocal) {
00112     SALOMEDS::Locker lock; 
00113     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)->Value(index);
00114   }
00115   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index);
00116   return aValue;
00117 }
00118 
00119 int SALOMEDS_AttributeSequenceOfReal::Length()
00120 {
00121   int aValue;
00122   if (_isLocal) {
00123     SALOMEDS::Locker lock; 
00124     aValue = dynamic_cast<SALOMEDSImpl_AttributeSequenceOfReal*>(_local_impl)-> Length();
00125   }
00126   else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length();
00127   return aValue;
00128 }