From: ageay Date: Wed, 13 Apr 2005 12:53:47 +0000 (+0000) Subject: Improvement PAL8343. X-Git-Tag: V2_2_3~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6dc555b3081c08f41fd290bf5ec2dcb856b3ee48;p=modules%2Fkernel.git Improvement PAL8343. Sender reaplaced by SenderInt and SenderDouble for more explicit API. WARNING as it is asked in PAL8343 ReceiverFactory do not yet release local obj ref SenderInt_ptr and SenderDouble_ptr, but it still releases remote sender servant and optionally the c++ array pointer (ownTabToSend). --- diff --git a/src/Communication/Makefile.in b/src/Communication/Makefile.in index 736fbe560..e859ea4fb 100644 --- a/src/Communication/Makefile.in +++ b/src/Communication/Makefile.in @@ -17,7 +17,7 @@ EXPORT_HEADERS = \ # Libraries targets LIB = libSalomeCommunication.la -LIB_SRC = SALOME_Comm_i.cxx SenderFactory.cxx Receiver.cxx MultiCommException.cxx SALOMEMultiComm.cxx ReceiverFactory.cxx +LIB_SRC = SALOME_Comm_i.cxx SenderFactory.cxx MultiCommException.cxx SALOMEMultiComm.cxx ReceiverFactory.cxx LIB_SERVER_IDL = SALOME_Comm.idl SALOME_Exception.idl # Executables targets diff --git a/src/Communication/Receiver.hxx b/src/Communication/Receiver.hxx index 56c65ad7e..d155e3360 100644 --- a/src/Communication/Receiver.hxx +++ b/src/Communication/Receiver.hxx @@ -5,16 +5,38 @@ /*! Abstract class factorizing common methods of all the receivers. All of the receivers have to inheritate from it. */ +template class Receiver { public: - virtual void *getValue(long &size)=0; + virtual T *getValue(long &size)=0; virtual ~Receiver() {} protected: - virtual void *getValue(long &size,SALOME::Sender_ptr sender); - static inline void *getLocalValue(long &size,SALOME_Sender_i* servant); - virtual void *getDistValue(long &size)=0; + virtual T *getValue(long &size,senderPtr sender); + static inline T *getLocalValue(long &size,senderSrv* servant); + virtual T *getDistValue(long &size)=0; }; +template +T *Receiver::getLocalValue(long &size,senderSrv* servant) +{ + const T *src=(const T *)servant->getData(size); + long lgr=size*servant->getSizeOf(); + void *ret=new char[lgr]; + memcpy(ret,src,lgr); + return (T *)ret; + //return (void *)servant->getData(size); +} + +template +T *Receiver::getValue(long &size,senderPtr sender) +{ + senderSrv* data=senderSrv::find(sender); + if(data) + return getLocalValue(size,data); + else + return getDistValue(size); +} + #endif diff --git a/src/Communication/ReceiverFactory.cxx b/src/Communication/ReceiverFactory.cxx index f3f0da6b1..1a2bd9125 100644 --- a/src/Communication/ReceiverFactory.cxx +++ b/src/Communication/ReceiverFactory.cxx @@ -23,116 +23,141 @@ using namespace std; #endif /*! - This method performs the transfert with the remote sender given. If it fails with this sender it tries with an another protocol (CORBA by default). + This method performs the transfert of double array with the remote SenderDouble given. If it fails with this SenderDouble it tries with an another protocol (CORBA by default). */ -void *ReceiverFactory::getValue(SALOME::Sender_ptr sender,long &size)throw(MultiCommException) +double *ReceiverFactory::getValue(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException) { - void *ret; + double *ret; try{ ret=getValueOneShot(sender,size); } catch(MultiCommException&) { - SALOME::Sender_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_); + SALOME::SenderDouble_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_); + MESSAGE("PROTOCOL CHANGED TO CORBA"); + sender->release(); + ret=getValueOneShot(newSender,size); + CORBA::release(newSender); + } + return ret; +} + +/*! + This method performs the transfert of int array with the remote SenderInt given. If it fails with this SenderInt it tries with an another protocol (CORBA by default). + */ +int *ReceiverFactory::getValue(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException) +{ + int *ret; + try{ + ret=getValueOneShot(sender,size); + } + catch(MultiCommException&) + { + SALOME::SenderInt_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_); MESSAGE("PROTOCOL CHANGED TO CORBA"); sender->release(); - CORBA::release(sender); ret=getValueOneShot(newSender,size); + CORBA::release(newSender); } return ret; } /*! - This method performs the transfert with the remote sender given. If it fails an exception is thrown. + This method performs the transfert with the remote SenderDouble given. If it fails an exception is thrown. */ -void *ReceiverFactory::getValueOneShot(SALOME::Sender_ptr sender,long &size)throw(MultiCommException) +double *ReceiverFactory::getValueOneShot(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException) { SALOME::CorbaDoubleNCSender_ptr cncD_ptr; SALOME::CorbaDoubleCSender_ptr cwcD_ptr; - SALOME::CorbaLongNCSender_ptr cncL_ptr; - SALOME::CorbaLongCSender_ptr cwcL_ptr; #ifdef HAVE_MPI2 - SALOME::MPISender_ptr mpi_ptr=SALOME::MPISender::_narrow(sender); + SALOME::MPISenderDouble_ptr mpi_ptr=SALOME::MPISenderDouble::_narrow(sender); +#endif +#ifdef HAVE_SOCKET + SALOME::SocketSenderDouble_ptr sock_ptr=SALOME::SocketSenderDouble::_narrow(sender); +#endif + cncD_ptr=SALOME::CorbaDoubleNCSender::_narrow(sender); + cwcD_ptr=SALOME::CorbaDoubleCSender::_narrow(sender); + if(!CORBA::is_nil(cncD_ptr)) + { + CORBA::release(sender); + CorbaDNoCopyReceiver rec(cncD_ptr); + return rec.getValue(size); + } + else if(!CORBA::is_nil(cwcD_ptr)) + { + CORBA::release(sender); + CorbaDWithCopyReceiver rec(cwcD_ptr); + return rec.getValue(size); + } +#ifdef HAVE_MPI2 + else if(!CORBA::is_nil(mpi_ptr)) + { + CORBA::release(sender); + MPIReceiver rec(mpi_ptr); + return rec.getValue(size); + } #endif #ifdef HAVE_SOCKET - SALOME::SocketSender_ptr sock_ptr=SALOME::SocketSender::_narrow(sender); + else if(!CORBA::is_nil(sock_ptr)) + { + CORBA::release(sender); + SocketReceiver rec(sock_ptr); + return rec.getValue(size); + } #endif - switch(sender->getTypeOfDataTransmitted()) + else { - case SALOME::DOUBLE_: - cncD_ptr=SALOME::CorbaDoubleNCSender::_narrow(sender); - cwcD_ptr=SALOME::CorbaDoubleCSender::_narrow(sender); - if(!CORBA::is_nil(cncD_ptr)) - { - CORBA::release(sender); - CorbaDNoCopyReceiver rec(cncD_ptr); - return rec.getValue(size); - } - else if(!CORBA::is_nil(cwcD_ptr)) - { - CORBA::release(sender); - CorbaDWithCopyReceiver rec(cwcD_ptr); - return rec.getValue(size); - } + throw MultiCommException("Unknown sender protocol"); + return 0; + } +} + +/*! + This method performs the transfert with the remote SenderInt given. If it fails an exception is thrown. + */ +int *ReceiverFactory::getValueOneShot(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException) +{ + SALOME::CorbaLongNCSender_ptr cncL_ptr; + SALOME::CorbaLongCSender_ptr cwcL_ptr; #ifdef HAVE_MPI2 - else if(!CORBA::is_nil(mpi_ptr)) - { - CORBA::release(sender); - MPIReceiver rec(mpi_ptr); - return rec.getValue(size); - } + SALOME::MPISenderInt_ptr mpi_ptr=SALOME::MPISenderInt::_narrow(sender); #endif #ifdef HAVE_SOCKET - else if(!CORBA::is_nil(sock_ptr)) - { - CORBA::release(sender); - SocketReceiver rec(sock_ptr); - return rec.getValue(size); - } + SALOME::SocketSenderInt_ptr sock_ptr=SALOME::SocketSenderInt::_narrow(sender); #endif - else - { - throw MultiCommException("Unknown sender protocol"); - return 0; - } - case SALOME::INT_: - cncL_ptr=SALOME::CorbaLongNCSender::_narrow(sender); - cwcL_ptr=SALOME::CorbaLongCSender::_narrow(sender); - if(!CORBA::is_nil(cncL_ptr)) - { - CORBA::release(sender); - CorbaINoCopyReceiver rec(cncL_ptr); - return rec.getValue(size); - } - else if(!CORBA::is_nil(cwcL_ptr)) - { - CORBA::release(sender); - CorbaIWithCopyReceiver rec(cwcL_ptr); - return rec.getValue(size); - } + cncL_ptr=SALOME::CorbaLongNCSender::_narrow(sender); + cwcL_ptr=SALOME::CorbaLongCSender::_narrow(sender); + if(!CORBA::is_nil(cncL_ptr)) + { + CORBA::release(sender); + CorbaINoCopyReceiver rec(cncL_ptr); + return rec.getValue(size); + } + else if(!CORBA::is_nil(cwcL_ptr)) + { + CORBA::release(sender); + CorbaIWithCopyReceiver rec(cwcL_ptr); + return rec.getValue(size); + } #ifdef HAVE_MPI2 - else if(!CORBA::is_nil(mpi_ptr)) - { - CORBA::release(sender); - MPIReceiver rec(mpi_ptr); - return rec.getValue(size); - } + else if(!CORBA::is_nil(mpi_ptr)) + { + CORBA::release(sender); + MPIReceiver rec(mpi_ptr); + return rec.getValue(size); + } #endif #ifdef HAVE_SOCKET - else if(!CORBA::is_nil(sock_ptr)) - { - CORBA::release(sender); - SocketReceiver rec(sock_ptr); - return rec.getValue(size); - } + else if(!CORBA::is_nil(sock_ptr)) + { + CORBA::release(sender); + SocketReceiver rec(sock_ptr); + return rec.getValue(size); + } #endif - else - { - throw MultiCommException("Unknown sender protocol"); - return 0; - } - default: - throw MultiCommException("unknown type of data transfered"); + else + { + throw MultiCommException("Unknown sender protocol"); return 0; } } diff --git a/src/Communication/ReceiverFactory.hxx b/src/Communication/ReceiverFactory.hxx index e5072c999..28eac49f6 100644 --- a/src/Communication/ReceiverFactory.hxx +++ b/src/Communication/ReceiverFactory.hxx @@ -12,9 +12,11 @@ class ReceiverFactory { public: - static void *getValue(SALOME::Sender_ptr sender,long &size)throw(MultiCommException); + static double *getValue(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException); + static int *getValue(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException); private: - static void *getValueOneShot(SALOME::Sender_ptr sender,long &size)throw(MultiCommException); + static double *getValueOneShot(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException); + static int *getValueOneShot(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException); }; #endif diff --git a/src/Communication/Receivers.cxx b/src/Communication/Receivers.cxx index a5d65ae15..19ea8c164 100644 --- a/src/Communication/Receivers.cxx +++ b/src/Communication/Receivers.cxx @@ -5,42 +5,40 @@ using namespace std; #define TAILLE_SPLIT 100000 #define TIMEOUT 20 -template -CorbaNCNoCopyReceiver::CorbaNCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){ +template +CorbaNCNoCopyReceiver::CorbaNCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){ } -template -CorbaNCNoCopyReceiver::~CorbaNCNoCopyReceiver(){ +template +CorbaNCNoCopyReceiver::~CorbaNCNoCopyReceiver(){ _mySender->release(); - CORBA::release(_mySender); } -template -void *CorbaNCNoCopyReceiver::getDistValue(long &size) +template +T *CorbaNCNoCopyReceiver::getDistValue(long &size) { TSeqCorba seq=_mySender->send(); size=seq->length(); - return seq->get_buffer(1); + return (T *)seq->get_buffer(1); } -template -void *CorbaNCNoCopyReceiver::getValue(long &size) +template +T *CorbaNCNoCopyReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } -template -CorbaNCWithCopyReceiver::CorbaNCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){ +template +CorbaNCWithCopyReceiver::CorbaNCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){ } -template -CorbaNCWithCopyReceiver::~CorbaNCWithCopyReceiver(){ +template +CorbaNCWithCopyReceiver::~CorbaNCWithCopyReceiver(){ _mySender->release(); - CORBA::release(_mySender); } -template -void *CorbaNCWithCopyReceiver::getDistValue(long &size){ +template +T *CorbaNCWithCopyReceiver::getDistValue(long &size){ size=_mySender->getSize(); long n; T *ret=new T[size]; @@ -59,24 +57,23 @@ void *CorbaNCWithCopyReceiver::getDistValue(long return ret; } -template -void *CorbaNCWithCopyReceiver::getValue(long &size) +template +T *CorbaNCWithCopyReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } -template -CorbaWCNoCopyReceiver::CorbaWCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){ +template +CorbaWCNoCopyReceiver::CorbaWCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){ } -template -CorbaWCNoCopyReceiver::~CorbaWCNoCopyReceiver(){ +template +CorbaWCNoCopyReceiver::~CorbaWCNoCopyReceiver(){ _mySender->release(); - CORBA::release(_mySender); } -template -void *CorbaWCNoCopyReceiver::getDistValue(long &size){ +template +T *CorbaWCNoCopyReceiver::getDistValue(long &size){ size=_mySender->getSize(); long n; T *ret=new T[size]; @@ -95,24 +92,23 @@ void *CorbaWCNoCopyReceiver::getDistValue(long & return ret; } -template -void *CorbaWCNoCopyReceiver::getValue(long &size) +template +T *CorbaWCNoCopyReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } -template -CorbaWCWithCopyReceiver::CorbaWCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){ +template +CorbaWCWithCopyReceiver::CorbaWCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){ } -template -CorbaWCWithCopyReceiver::~CorbaWCWithCopyReceiver(){ +template +CorbaWCWithCopyReceiver::~CorbaWCWithCopyReceiver(){ _mySender->release(); - CORBA::release(_mySender); } -template -void *CorbaWCWithCopyReceiver::getDistValue(long &size){ +template +T *CorbaWCWithCopyReceiver::getDistValue(long &size){ size=_mySender->getSize(); long n; T *ret=new T[size]; @@ -131,26 +127,25 @@ void *CorbaWCWithCopyReceiver::getDistValue(long return ret; } -template -void *CorbaWCWithCopyReceiver::getValue(long &size) +template +T *CorbaWCWithCopyReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } #ifdef HAVE_MPI2 -template -MPIReceiver::MPIReceiver(SALOME::MPISender_ptr mySender):_mySender(mySender){ +template +MPIReceiver::MPIReceiver(CorbaSender mySender):_mySender(mySender){ } -template -MPIReceiver::~MPIReceiver(){ +template +MPIReceiver::~MPIReceiver(){ _mySender->release(); - CORBA::release(_mySender); } -template -void *MPIReceiver::getDistValue(long &size){ +template +T *MPIReceiver::getDistValue(long &size){ int i=0; int myproc; int sproc; @@ -204,10 +199,10 @@ void *MPIReceiver::getDistValue(long &size){ return _v; } -template -void *MPIReceiver::getValue(long &size) +template +T *MPIReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } #endif @@ -221,31 +216,30 @@ void *MPIReceiver::getValue(long &size) #include #include -template -SocketReceiver::SocketReceiver(SALOME::SocketSender_ptr mySender) : _mySender(mySender) +template +SocketReceiver::SocketReceiver(CorbaSender mySender) : _mySender(mySender) { _clientSockfd = -1; _senderDestruc=true; } -template -SocketReceiver::~SocketReceiver() +template +SocketReceiver::~SocketReceiver() { if(_senderDestruc) { _mySender->release(); - CORBA::release(_mySender); } } -template -void *SocketReceiver::getValue(long &size) +template +T *SocketReceiver::getValue(long &size) { - return Receiver::getValue(size,_mySender); + return Receiver::getValue(size,_mySender); } -template -void* SocketReceiver::getDistValue(long &size) +template +T* SocketReceiver::getDistValue(long &size) { int n=0, m; T *v; @@ -296,8 +290,8 @@ void* SocketReceiver::getDistValue(long &size) return v; } -template -void SocketReceiver::initCom() +template +void SocketReceiver::initCom() { try{ _mySender->initCom(); @@ -325,8 +319,8 @@ void SocketReceiver::initCom() } -template -void SocketReceiver::connectCom(const char *dest_address, int port) +template +void SocketReceiver::connectCom(const char *dest_address, int port) { struct sockaddr_in serv_addr; struct hostent * server; @@ -377,8 +371,8 @@ void SocketReceiver::connectCom(const char *dest_address, int port) } -template -void SocketReceiver::closeCom() +template +void SocketReceiver::closeCom() { _mySender->closeCom(); if( _clientSockfd >= 0 ){ diff --git a/src/Communication/Receivers.hxx b/src/Communication/Receivers.hxx index 4fd2581ee..c4309b754 100644 --- a/src/Communication/Receivers.hxx +++ b/src/Communication/Receivers.hxx @@ -10,82 +10,82 @@ /*! Receiver used for transfert with CORBA when no copy is required remotely and locally. */ -template -class CorbaNCNoCopyReceiver : public Receiver +template +class CorbaNCNoCopyReceiver : public Receiver { private: CorbaSender _mySender; public: CorbaNCNoCopyReceiver(CorbaSender mySender); ~CorbaNCNoCopyReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); }; /*! Receiver used for transfert with CORBA when copy is not required remotely but required locally. */ -template -class CorbaNCWithCopyReceiver : public Receiver +template +class CorbaNCWithCopyReceiver : public Receiver { private: CorbaSender _mySender; public: CorbaNCWithCopyReceiver(CorbaSender mySender); ~CorbaNCWithCopyReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); }; /*! Receiver used for transfert with CORBA when copy is required remotely but not required locally. */ -template -class CorbaWCNoCopyReceiver : public Receiver +template +class CorbaWCNoCopyReceiver : public Receiver { private: CorbaSender _mySender; public: CorbaWCNoCopyReceiver(CorbaSender mySender); ~CorbaWCNoCopyReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); }; /*! Receiver used for transfert with CORBA when copy is required both remotely and locally. */ -template -class CorbaWCWithCopyReceiver : public Receiver +template +class CorbaWCWithCopyReceiver : public Receiver { private: CorbaSender _mySender; public: CorbaWCWithCopyReceiver(CorbaSender mySender); ~CorbaWCWithCopyReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); }; #ifdef HAVE_MPI2 /*! Receiver for MPI transfert. */ -template -class MPIReceiver : public Receiver +template +class MPIReceiver : public Receiver { private: - SALOME::MPISender_ptr _mySender; + CorbaSender _mySender; public: - MPIReceiver(SALOME::MPISender_ptr mySender); + MPIReceiver(CorbaSender mySender); ~MPIReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); }; #endif @@ -96,19 +96,19 @@ class XDR; /*! Receiver for transfert with sockets. */ -template -class SocketReceiver : public Receiver +template +class SocketReceiver : public Receiver { private: - SALOME::SocketSender_ptr _mySender; + CorbaSender _mySender; int _clientSockfd; bool _senderDestruc; public: - SocketReceiver(SALOME::SocketSender_ptr mySender); + SocketReceiver(CorbaSender mySender); ~SocketReceiver(); - void *getValue(long &size); + T *getValue(long &size); private: - void *getDistValue(long &size); + T *getDistValue(long &size); void initCom(); void connectCom(const char *, int); void closeCom(); diff --git a/src/Communication/SALOME_Comm_i.cxx b/src/Communication/SALOME_Comm_i.cxx index c9b677a84..aed4140b5 100644 --- a/src/Communication/SALOME_Comm_i.cxx +++ b/src/Communication/SALOME_Comm_i.cxx @@ -30,13 +30,47 @@ int SALOME_Sender_i::getSizeOf() const { } /*! Unique constructor */ -SALOME_Sender_i::SALOME_Sender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf):_tabToSend(tabToSend),_lgrTabToSend(lgrTabToSend),_type(type),_sizeOf(sizeOf){ +SALOME_Sender_i::SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):_tabToSend(tabToSend),_lgrTabToSend(lgrTabToSend),_sizeOf(sizeOf),_ownTabToSend(ownTabToSend){ +} + +/*! To force ownerShip status */ +void SALOME_Sender_i::setOwnerShip(bool own) +{ + _ownTabToSend=own; +} + +/*! Method for the remote destroy of the current servant. This method is used by the receiver to destroy the sender when the transfert is complete. + */ +void SALOME_Sender_i::release() +{ + PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); + _default_POA()->deactivate_object(oid); + _remove_ref(); +} + +SALOME_SenderDouble_i::SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend) +{ +} + +/*! Destructor. + */ +SALOME_SenderDouble_i::~SALOME_SenderDouble_i() +{ + if(_ownTabToSend) + delete [] (double *)_tabToSend; +} + +/*! Return a new sender of the same array but with an another protocol and delegates to the returned sender the ownership of array. + */ +SALOME::SenderDouble_ptr SALOME_SenderDouble_i::buildOtherWithProtocol(SALOME::TypeOfCommunication type) +{ + return SenderFactory::buildSender(type,this); } /*! Method to establish if the CORBA object refered by pCorba is collocalised.\n If it is, the pointer to the servant that incarnates the CORBA object is returned. */ -SALOME_Sender_i *SALOME_Sender_i::find(SALOME::Sender_ptr pCorba){ +SALOME_SenderDouble_i *SALOME_SenderDouble_i::find(SALOME::SenderDouble_ptr pCorba){ PortableServer::ServantBase *ret; try { ret=PortableServer::POA::_the_root_poa()->reference_to_servant(pCorba); @@ -45,33 +79,44 @@ SALOME_Sender_i *SALOME_Sender_i::find(SALOME::Sender_ptr pCorba){ return 0; } ret->_remove_ref(); - return dynamic_cast(ret); + return dynamic_cast(ret); } -/*! Method for the remote destroy of the current servant. This method is used by the receiver to destroy the sender when the transfert is complete. - */ -void SALOME_Sender_i::release() +SALOME_SenderInt_i::SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend) { - PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); - _default_POA()->deactivate_object(oid); - _remove_ref(); } -/*! Return the type of the element that compose the array. Used by receiverfactory to build the correct receiver. +/*! Destructor. */ -SALOME::TypeOfDataTransmitted SALOME_Sender_i::getTypeOfDataTransmitted() +SALOME_SenderInt_i::~SALOME_SenderInt_i() { - return _type; + if(_ownTabToSend) + delete [] (int *)_tabToSend; } /*! Return a new sender of the same array but with an another protocol. */ -SALOME::Sender_ptr SALOME_Sender_i::buildOtherWithProtocol(SALOME::TypeOfCommunication type) +SALOME::SenderInt_ptr SALOME_SenderInt_i::buildOtherWithProtocol(SALOME::TypeOfCommunication type) { return SenderFactory::buildSender(type,this); } -SALOME_CorbaDoubleNCSender_i::SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend):SALOME_Sender_i(SALOME::DOUBLE_,tabToSend,lgrTabToSend,sizeof(double)){ +/*! Method to establish if the CORBA object refered by pCorba is collocalised.\n + If it is, the pointer to the servant that incarnates the CORBA object is returned. +*/ +SALOME_SenderInt_i *SALOME_SenderInt_i::find(SALOME::SenderInt_ptr pCorba){ + PortableServer::ServantBase *ret; + try { + ret=PortableServer::POA::_the_root_poa()->reference_to_servant(pCorba); + } + catch(...){ + return 0; + } + ret->_remove_ref(); + return dynamic_cast(ret); +} + +SALOME_CorbaDoubleNCSender_i::SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend){ } SALOME_CorbaDoubleNCSender_i::~SALOME_CorbaDoubleNCSender_i(){ @@ -92,7 +137,7 @@ SALOME::vectorOfDouble* SALOME_CorbaDoubleNCSender_i::send(){ return c1._retn(); } -SALOME_CorbaDoubleCSender_i::SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend):SALOME_Sender_i(SALOME::DOUBLE_,tabToSend,lgrTabToSend,sizeof(double)){ +SALOME_CorbaDoubleCSender_i::SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend){ } SALOME_CorbaDoubleCSender_i::~SALOME_CorbaDoubleCSender_i(){ @@ -113,7 +158,7 @@ SALOME::vectorOfDouble* SALOME_CorbaDoubleCSender_i::sendPart(CORBA::ULong offse //////////////////////// -SALOME_CorbaLongNCSender_i::SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend):SALOME_Sender_i(SALOME::INT_,tabToSend,lgrTabToSend,sizeof(int)){ +SALOME_CorbaLongNCSender_i::SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend){ } SALOME_CorbaLongNCSender_i::~SALOME_CorbaLongNCSender_i(){ @@ -134,7 +179,7 @@ SALOME::vectorOfLong* SALOME_CorbaLongNCSender_i::send(){ return c1._retn(); } -SALOME_CorbaLongCSender_i::SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend):SALOME_Sender_i(SALOME::INT_,tabToSend,lgrTabToSend,sizeof(int)){ +SALOME_CorbaLongCSender_i::SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend){ } SALOME_CorbaLongCSender_i::~SALOME_CorbaLongCSender_i(){ @@ -159,7 +204,7 @@ unsigned long SALOME_MPISender_i::_tag1=0; unsigned long SALOME_MPISender_i::_tag2=1; -SALOME_MPISender_i::SALOME_MPISender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf):SALOME_Sender_i(type,tabToSend,lgrTabToSend,sizeOf){ +SALOME_MPISender_i::SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeOf,ownTabToSend){ _portName=new char[MPI_MAX_PORT_NAME]; } @@ -203,6 +248,7 @@ SALOME::MPISender::param* SALOME_MPISender_i::getParam() void SALOME_MPISender_i::send() { + _type=getTypeOfDataTransmitted(); _argsForThr=new (void *)[8]; _argsForThr[0]=_portName; _argsForThr[1]=&_lgrTabToSend; @@ -238,6 +284,7 @@ void* SALOME_MPISender_i::myThread(void *args) MPI_Send(argsTab[2],*lgrTabToSend,MPI_INT,*cproc,*tag2,*com); } omni_thread::exit(); + return args; } void SALOME_MPISender_i::close(const SALOME::MPISender::param& p) @@ -252,6 +299,18 @@ void SALOME_MPISender_i::close(const SALOME::MPISender::param& p) delete [] _argsForThr; } +SALOME_MPISenderDouble_i::SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend) + :SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_MPISender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend) + ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend) +{ +} + +SALOME_MPISenderInt_i::SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend) + :SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_MPISender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend) + ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend) +{ +} + #endif #ifdef HAVE_SOCKET @@ -267,7 +326,7 @@ void SALOME_MPISender_i::close(const SALOME::MPISender::param& p) #include #include -SALOME_SocketSender_i::SALOME_SocketSender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf):SALOME_Sender_i(type,tabToSend,lgrTabToSend,sizeOf){ +SALOME_SocketSender_i::SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeOf,ownTabToSend){ _IPAddress = inetAddress(); _serverSockfd = -1; _clientSockfd = -1; @@ -314,6 +373,7 @@ SALOME::SocketSender::param * SALOME_SocketSender_i::getParam() void SALOME_SocketSender_i::send() { + _type=getTypeOfDataTransmitted(); _argsForThr=new void *[6]; _argsForThr[0]=&_serverSockfd; _argsForThr[1]=&_clientSockfd; @@ -393,6 +453,7 @@ void* SALOME_SocketSender_i::myThread(void *args) xdr_vector( &xp, (char*)tabToSend, *lgrTabToSend, sizeof(int), (xdrproc_t)xdr_int ); xdr_destroy( &xp ); } + return args; } void SALOME_SocketSender_i::initCom() throw(SALOME::SALOME_Exception) @@ -443,7 +504,6 @@ void SALOME_SocketSender_i::initCom() throw(SALOME::SALOME_Exception) void SALOME_SocketSender_i::acceptCom() throw(SALOME::SALOME_Exception) { socklen_t sin_size; - int new_fd; struct sockaddr_in client_addr; SALOME::ExceptionStruct es; @@ -485,6 +545,18 @@ void SALOME_SocketSender_i::endOfCom() delete [] _argsForThr; } +SALOME_SocketSenderDouble_i::SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend) + :SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_SocketSender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend) + ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend) +{ +} + +SALOME_SocketSenderInt_i::SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend) + :SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_SocketSender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend) + ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend) +{ +} + //CCRT porting #undef _LIBC_POLLUTION_H_ #undef _POSIX_PII_SOCKET diff --git a/src/Communication/SALOME_Comm_i.hxx b/src/Communication/SALOME_Comm_i.hxx index 7b6e8df43..485b4ea8d 100644 --- a/src/Communication/SALOME_Comm_i.hxx +++ b/src/Communication/SALOME_Comm_i.hxx @@ -26,26 +26,48 @@ protected: Practically in terms of bytes the size to be transmitted is _lgrTabToSend*_sizeOf */ int _sizeOf; - /*! Type the component of the array*/ - SALOME::TypeOfDataTransmitted _type; + /*! Indicates if _tabToSend has to be deallocated */ + bool _ownTabToSend; - SALOME_Sender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf); + SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false); public: const void *getData(long &size) const; int getSizeOf() const; + void setOwnerShip(bool own); + bool getOwnerShip() const { return _ownTabToSend; } void release(); - SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted(); - SALOME::Sender_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type); - static SALOME_Sender_i *find(SALOME::Sender_ptr pCorba); + virtual ~SALOME_Sender_i() {} +}; + +class SALOME_SenderDouble_i : public virtual POA_SALOME::SenderDouble, + public virtual SALOME_Sender_i +{ +public: + SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::DOUBLE_; } + SALOME::SenderDouble_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type); + virtual ~SALOME_SenderDouble_i(); + static SALOME_SenderDouble_i *find(SALOME::SenderDouble_ptr pCorba); +}; + +class SALOME_SenderInt_i : public virtual POA_SALOME::SenderInt, + public virtual SALOME_Sender_i +{ +public: + SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::INT_; } + SALOME::SenderInt_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type); + virtual ~SALOME_SenderInt_i(); + static SALOME_SenderInt_i *find(SALOME::SenderInt_ptr pCorba); }; /*! Servant class for CORBA sender for double* when no copy of array _tabToSend is required, that is to say double and CORBA::Double are binary equal. */ class SALOME_CorbaDoubleNCSender_i : public POA_SALOME::CorbaDoubleNCSender, - public SALOME_Sender_i + public SALOME_SenderDouble_i { public: - SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend); + SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); ~SALOME_CorbaDoubleNCSender_i(); CORBA::ULong getSize(); SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length); @@ -55,10 +77,10 @@ public: /*! Servant class for CORBA sender for double* when copy of array _tabToSend is required, that is to say double and CORBA::Double are NOT binary equal. */ class SALOME_CorbaDoubleCSender_i : public POA_SALOME::CorbaDoubleCSender, - public SALOME_Sender_i + public SALOME_SenderDouble_i { public: - SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend); + SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); ~SALOME_CorbaDoubleCSender_i(); CORBA::ULong getSize(); SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length); @@ -67,10 +89,10 @@ public: /*! Servant class for CORBA sender for int* when no copy of array _tabToSend is required, that is to say int and CORBA::Long are binary equal. */ class SALOME_CorbaLongNCSender_i : public POA_SALOME::CorbaLongNCSender, - public SALOME_Sender_i + public SALOME_SenderInt_i { public: - SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend); + SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); ~SALOME_CorbaLongNCSender_i(); CORBA::ULong getSize(); SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length); @@ -80,10 +102,10 @@ public: /*! Servant class for CORBA sender for int* when copy of array _tabToSend is required, that is to say int and CORBA::Long are NOT binary equal. */ class SALOME_CorbaLongCSender_i : public POA_SALOME::CorbaLongCSender, - public SALOME_Sender_i + public SALOME_SenderInt_i { public: - SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend); + SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); ~SALOME_CorbaLongCSender_i(); CORBA::ULong getSize(); SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length); @@ -94,8 +116,8 @@ public: /*! Servant class of sender using MPI2. */ -class SALOME_MPISender_i : public POA_SALOME::MPISender, - public SALOME_Sender_i +class SALOME_MPISender_i : public virtual POA_SALOME::MPISender, + public virtual SALOME_Sender_i { private: static unsigned long _tag1; @@ -113,8 +135,10 @@ private: void **_argsForThr; /*! Pointer to thread created on asynchronous invocation*/ omni_thread *_newThr; + /*! Type the component of the array*/ + SALOME::TypeOfDataTransmitted _type; public: - SALOME_MPISender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf); + SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false); ~SALOME_MPISender_i(); SALOME::MPISender::param* getParam(); void send(); @@ -123,14 +147,30 @@ private: static void* myThread(void *args); }; +class SALOME_MPISenderDouble_i : public POA_SALOME::MPISenderDouble, + public SALOME_SenderDouble_i, + public SALOME_MPISender_i +{ +public: + SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); +}; + +class SALOME_MPISenderInt_i : public POA_SALOME::MPISenderInt, + public SALOME_SenderInt_i, + public SALOME_MPISender_i +{ +public: + SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); +}; + #endif #ifdef HAVE_SOCKET /*! Servant class of sender using Sockets. */ -class SALOME_SocketSender_i : public POA_SALOME::SocketSender, - public SALOME_Sender_i +class SALOME_SocketSender_i : public virtual POA_SALOME::SocketSender, + public virtual SALOME_Sender_i { private: int _serverSockfd; @@ -140,8 +180,10 @@ private: void **_argsForThr; omni_thread *_newThr; bool _errorFlag; + /*! Type the component of the array*/ + SALOME::TypeOfDataTransmitted _type; public: - SALOME_SocketSender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf); + SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false); ~SALOME_SocketSender_i(); SALOME::SocketSender::param* getParam(); void send(); @@ -154,6 +196,22 @@ private: std::string inetAddress(); }; +class SALOME_SocketSenderDouble_i : public POA_SALOME::SocketSenderDouble, + public SALOME_SenderDouble_i, + public SALOME_SocketSender_i +{ +public: + SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); +}; + +class SALOME_SocketSenderInt_i : public POA_SALOME::SocketSenderInt, + public SALOME_SenderInt_i, + public SALOME_SocketSender_i +{ +public: + SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); +}; + #endif #endif diff --git a/src/Communication/SenderFactory.cxx b/src/Communication/SenderFactory.cxx index 3b1f81165..04f8056d0 100644 --- a/src/Communication/SenderFactory.cxx +++ b/src/Communication/SenderFactory.cxx @@ -16,25 +16,25 @@ using namespace std; #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 @@ -42,58 +42,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); +} diff --git a/src/Communication/SenderFactory.hxx b/src/Communication/SenderFactory.hxx index d85a842ba..ce3a0ad91 100644 --- a/src/Communication/SenderFactory.hxx +++ b/src/Communication/SenderFactory.hxx @@ -7,7 +7,8 @@ class SALOMEMultiComm; -class SALOME_Sender_i; +class SALOME_SenderDouble_i; +class SALOME_SenderInt_i; /*! This class implements the factory pattern of GoF by making a sender by giving an array and a communicator.It completely hides the type of sender from the user. @@ -15,9 +16,27 @@ class SALOME_Sender_i; class SenderFactory { public: - static SALOME::Sender_ptr buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr) throw(MultiCommException); - static SALOME::Sender_ptr buildSender(SALOMEMultiComm &multiCommunicator,const int *tab,long lgr) throw(MultiCommException); - static SALOME::Sender_ptr buildSender(SALOME::TypeOfCommunication NewType,SALOME_Sender_i *src); + static SALOME::SenderDouble_ptr buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr,bool ownTab=false) throw(MultiCommException); + static SALOME::SenderInt_ptr buildSender(SALOMEMultiComm &multiCommunicator,const int *tab,long lgr,bool ownTab=false) throw(MultiCommException); + static SALOME::SenderDouble_ptr buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderDouble_i *src); + static SALOME::SenderInt_ptr buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderInt_i *src); +}; + +template +struct mapCppSender { + typedef T SenderVarType; +}; + +template<> +struct mapCppSender +{ + typedef SALOME::SenderInt_var SenderVarType; +}; + +template<> +struct mapCppSender +{ + typedef SALOME::SenderDouble_var SenderVarType; }; #endif