X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDS%2FSALOMEDS_AttributeSequenceOfReal.cxx;h=708891275328233cde3200d31c3df8c1d67b7458;hb=1667ddf63b84e8c59ff34106a18c2dbcac83a506;hp=f29de16e6711c25e001517382d30af316542b752;hpb=1bd1d38e86c39b13e265f8ff534fc1463c25fef3;p=modules%2Fyacs.git diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx index f29de16e6..708891275 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx @@ -1,19 +1,39 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + // File : SALOMEDS_AttributeSequenceOfReal.cxx // Author : Sergey RUIN // Module : SALOME - +// #include "SALOMEDS_AttributeSequenceOfReal.hxx" +#include "SALOMEDS.hxx" -#include -#include -#include - -SALOMEDS_AttributeSequenceOfReal -::SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr) +SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal + (SALOMEDSImpl_AttributeSequenceOfReal* theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr) +SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal + (SALOMEDS::AttributeSequenceOfReal_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -23,15 +43,15 @@ SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal() void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector& other) { int i, aLength = other.size(); - if(_isLocal) { - Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; - for(i = 0; i < aLength; i++) aSeq->Append(other[i]); - Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + dynamic_cast(_local_impl)->Assign(other); } else { SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = other[i]; + for (i = 0; i < aLength; i++) aSeq[i] = other[i]; SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq); } } @@ -40,50 +60,69 @@ std::vector SALOMEDS_AttributeSequenceOfReal::CorbaSequence() { std::vector aVector; int i, aLength; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr; - aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeSequenceOfReal* aSeqAttr = NULL; + aSeqAttr = dynamic_cast(_local_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } else { SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } return aVector; } - + void SALOMEDS_AttributeSequenceOfReal::Add(double value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + dynamic_cast(_local_impl)->Add(value); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value); } void SALOMEDS_AttributeSequenceOfReal::Remove(int index) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + dynamic_cast(_local_impl)->Remove(index); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index); } - + void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + dynamic_cast(_local_impl)->ChangeValue(index, value); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value); } - + double SALOMEDS_AttributeSequenceOfReal::Value(int index) { double aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = dynamic_cast(_local_impl)->Value(index); + } else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index); return aValue; } - + int SALOMEDS_AttributeSequenceOfReal::Length() { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = dynamic_cast(_local_impl)-> Length(); + } else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length(); return aValue; }