Back to index

salome-kernel  6.5.0
SALOMEDS_AttributeTarget.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_AttributeTarget.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDS_AttributeTarget.hxx"
00028 #include "SALOMEDS.hxx"
00029 
00030 #include "SALOMEDSImpl_SObject.hxx"
00031 #include "SALOMEDS_SObject.hxx"
00032 
00033 SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(SALOMEDSImpl_AttributeTarget* theAttr)
00034 :SALOMEDS_GenericAttribute(theAttr)
00035 {}
00036 
00037 SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(SALOMEDS::AttributeTarget_ptr theAttr)
00038 :SALOMEDS_GenericAttribute(theAttr)
00039 {}
00040 
00041 SALOMEDS_AttributeTarget::~SALOMEDS_AttributeTarget()
00042 {}
00043 
00044 void SALOMEDS_AttributeTarget::Add(const _PTR(SObject)& theObject)
00045 {
00046   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
00047 
00048   if (_isLocal) {
00049     SALOMEDS::Locker lock;
00050     dynamic_cast<SALOMEDSImpl_AttributeTarget*>(_local_impl)->Add(*(aSO->GetLocalImpl()));
00051   }
00052   else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Add(aSO->GetCORBAImpl());
00053 }
00054 
00055 std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get()
00056 {
00057   std::vector<_PTR(SObject)> aVector;
00058   int aLength, i;
00059   SALOMEDSClient_SObject* aSO = NULL;
00060   
00061   if (_isLocal) {
00062     SALOMEDS::Locker lock;
00063     std::vector<SALOMEDSImpl_SObject> aSeq = dynamic_cast<SALOMEDSImpl_AttributeTarget*>(_local_impl)->Get();
00064     aLength = aSeq.size();
00065     for (i = 0; i < aLength; i++) {
00066       aSO = new SALOMEDS_SObject(aSeq[i]);
00067       aVector.push_back(_PTR(SObject)(aSO));
00068     }
00069   }
00070   else {
00071     SALOMEDS::Study::ListOfSObject_var aSeq = SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Get();
00072     aLength = aSeq->length();
00073     for (i = 0; i < aLength; i++)  {
00074        aSO = new SALOMEDS_SObject(aSeq[i].in());
00075         aVector.push_back(_PTR(SObject)(aSO));
00076     }
00077   }
00078 
00079   return aVector;
00080 }
00081 
00082 void SALOMEDS_AttributeTarget::Remove(const _PTR(SObject)& theObject)
00083 {
00084   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
00085 
00086   if (_isLocal) {
00087     SALOMEDS::Locker lock;
00088     dynamic_cast<SALOMEDSImpl_AttributeTarget*>(_local_impl)->Remove(*(aSO->GetLocalImpl()));
00089   }
00090   else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Remove(aSO->GetCORBAImpl());
00091 }