X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCommunication%2FSenderFactory.cxx;h=d0f38a4abe6e4c208a113b6ad00dfa54e53fd49c;hb=f464a8dab4fb05a38720c3fb6790117e9d5bb7b7;hp=35b4af0b91e2307a7e9cae39c745039a5220d47e;hpb=5d2351ab498f7367b46d26f0371fe841a6960f15;p=modules%2Fkernel.git diff --git a/src/Communication/SenderFactory.cxx b/src/Communication/SenderFactory.cxx index 35b4af0b9..d0f38a4ab 100644 --- a/src/Communication/SenderFactory.cxx +++ b/src/Communication/SenderFactory.cxx @@ -1,7 +1,29 @@ +// Copyright (C) 2007-2008 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 +// +#include "SALOME_Comm_i.hxx" #include "SenderFactory.hxx" #include "utilities.h" #include "SALOMEMultiComm.hxx" -#include "SALOME_Comm_i.hxx" +using namespace std; #ifdef COMP_CORBA_DOUBLE #define SALOME_CorbaDoubleSender SALOME_CorbaDoubleNCSender_i @@ -15,25 +37,25 @@ #define SALOME_CorbaLongSender SALOME_CorbaLongCSender_i #endif -SALOME::Sender_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr)throw(MultiCommException){ +SALOME::SenderDouble_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr,bool ownTab)throw(MultiCommException){ switch(multiCommunicator.getProtocol()) { case SALOME::CORBA_: { - SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr); + SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr,ownTab); return retc->_this(); } #ifdef HAVE_MPI2 case SALOME::MPI_: { - SALOME_MPISender_i* retm=new SALOME_MPISender_i(SALOME::DOUBLE_,tab,lgr,sizeof(double)); + SALOME_MPISenderDouble_i* retm=new SALOME_MPISenderDouble_i(tab,lgr,ownTab); return retm->_this(); } #endif #ifdef HAVE_SOCKET case SALOME::SOCKET_: { - SALOME_SocketSender_i* rets=new SALOME_SocketSender_i(SALOME::DOUBLE_,tab,lgr,sizeof(double)); + SALOME_SocketSenderDouble_i* rets=new SALOME_SocketSenderDouble_i(tab,lgr,ownTab); return rets->_this(); } #endif @@ -41,58 +63,61 @@ SALOME::Sender_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator { multiCommunicator.setProtocol(SALOME::CORBA_); MESSAGE("PROTOCOL CHANGED TO CORBA"); - SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr); + SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr,ownTab); return retc->_this(); } // throw MultiCommException("Communication protocol not implemented"); } } -SALOME::Sender_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const int *tab,long lgr)throw(MultiCommException){ +SALOME::SenderInt_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const int *tab,long lgr,bool ownTab)throw(MultiCommException){ switch(multiCommunicator.getProtocol()) { case SALOME::CORBA_: { - SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr); + SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr,ownTab); return retc->_this(); } #ifdef HAVE_MPI2 case SALOME::MPI_: { - SALOME_MPISender_i* retm=new SALOME_MPISender_i(SALOME::INT_,tab,lgr,sizeof(int)); + SALOME_MPISenderInt_i* retm=new SALOME_MPISenderInt_i(tab,lgr,ownTab); return retm->_this(); } #endif #ifdef HAVE_SOCKET case SALOME::SOCKET_: { - SALOME_SocketSender_i* rets=new SALOME_SocketSender_i(SALOME::INT_,tab,lgr,sizeof(int)); + SALOME_SocketSenderInt_i* rets=new SALOME_SocketSenderInt_i(tab,lgr,ownTab); return rets->_this(); } #endif default: { multiCommunicator.setProtocol(SALOME::CORBA_); - SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr); + SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr,ownTab); return retc->_this(); } // throw MultiCommException("Communication protocol not implemented"); } } -SALOME::Sender_ptr SenderFactory::buildSender(SALOME::TypeOfCommunication NewType,SALOME_Sender_i *src) +SALOME::SenderDouble_ptr SenderFactory::buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderDouble_i *src) { SALOMEMultiComm mc(NewType); long n; - const void *data=src->getData(n); - switch(src->getTypeOfDataTransmitted()) - { - case SALOME::DOUBLE_: - return buildSender(mc,(const double *)data,n); - case SALOME::INT_: - return buildSender(mc,(const int *)data,n); - } - + const double *data=(const double *)src->getData(n); + bool own=src->getOwnerShip(); + src->setOwnerShip(false); + return buildSender(mc,data,n,own); } - +SALOME::SenderInt_ptr SenderFactory::buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderInt_i *src) +{ + SALOMEMultiComm mc(NewType); + long n; + const int *data=(const int *)src->getData(n); + bool own=src->getOwnerShip(); + src->setOwnerShip(false); + return buildSender(mc,data,n,own); +}