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).
# 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
/*! Abstract class factorizing common methods of all the receivers. All of the receivers have to inheritate from it.
*/
+template<class T,class senderPtr, class senderSrv>
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<class T,class senderPtr, class senderSrv>
+T *Receiver<T,senderPtr,senderSrv>::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<class T,class senderPtr, class senderSrv>
+T *Receiver<T,senderPtr,senderSrv>::getValue(long &size,senderPtr sender)
+{
+ senderSrv* data=senderSrv::find(sender);
+ if(data)
+ return getLocalValue(size,data);
+ else
+ return getDistValue(size);
+}
+
#endif
#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<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleNCSender_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(cncD_ptr);
+ return rec.getValue(size);
+ }
+ else if(!CORBA::is_nil(cwcD_ptr))
+ {
+ CORBA::release(sender);
+ CorbaDWithCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleCSender_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(cwcD_ptr);
+ return rec.getValue(size);
+ }
+#ifdef HAVE_MPI2
+ else if(!CORBA::is_nil(mpi_ptr))
+ {
+ CORBA::release(sender);
+ MPIReceiver<double,MPI_DOUBLE,SALOME::MPISenderDouble_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> 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<double,xdr_double,SALOME::SocketSenderDouble_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> 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<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleNCSender_ptr> rec(cncD_ptr);
- return rec.getValue(size);
- }
- else if(!CORBA::is_nil(cwcD_ptr))
- {
- CORBA::release(sender);
- CorbaDWithCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleCSender_ptr> 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<double,MPI_DOUBLE> 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<double,xdr_double> 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<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongNCSender_ptr> rec(cncL_ptr);
- return rec.getValue(size);
- }
- else if(!CORBA::is_nil(cwcL_ptr))
- {
- CORBA::release(sender);
- CorbaIWithCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongCSender_ptr> 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<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongNCSender_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(cncL_ptr);
+ return rec.getValue(size);
+ }
+ else if(!CORBA::is_nil(cwcL_ptr))
+ {
+ CORBA::release(sender);
+ CorbaIWithCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongCSender_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(cwcL_ptr);
+ return rec.getValue(size);
+ }
#ifdef HAVE_MPI2
- else if(!CORBA::is_nil(mpi_ptr))
- {
- CORBA::release(sender);
- MPIReceiver<int,MPI_INT> rec(mpi_ptr);
- return rec.getValue(size);
- }
+ else if(!CORBA::is_nil(mpi_ptr))
+ {
+ CORBA::release(sender);
+ MPIReceiver<int,MPI_INT,SALOME::MPISenderInt_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(mpi_ptr);
+ return rec.getValue(size);
+ }
#endif
#ifdef HAVE_SOCKET
- else if(!CORBA::is_nil(sock_ptr))
- {
- CORBA::release(sender);
- SocketReceiver<int,xdr_int> rec(sock_ptr);
- return rec.getValue(size);
- }
+ else if(!CORBA::is_nil(sock_ptr))
+ {
+ CORBA::release(sender);
+ SocketReceiver<int,xdr_int,SALOME::SocketSenderInt_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> 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;
}
}
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
#define TAILLE_SPLIT 100000
#define TIMEOUT 20
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::CorbaNCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::CorbaNCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::~CorbaNCNoCopyReceiver(){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::~CorbaNCNoCopyReceiver(){
_mySender->release();
- CORBA::release(_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getDistValue(long &size)
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getDistValue(long &size)
{
TSeqCorba seq=_mySender->send();
size=seq->length();
- return seq->get_buffer(1);
+ return (T *)seq->get_buffer(1);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getValue(long &size)
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaNCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::CorbaNCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::CorbaNCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::~CorbaNCWithCopyReceiver(){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::~CorbaNCWithCopyReceiver(){
_mySender->release();
- CORBA::release(_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getDistValue(long &size){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getDistValue(long &size){
size=_mySender->getSize();
long n;
T *ret=new T[size];
return ret;
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getValue(long &size)
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaNCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::CorbaWCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::CorbaWCNoCopyReceiver(CorbaSender mySender):_mySender(mySender){
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::~CorbaWCNoCopyReceiver(){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::~CorbaWCNoCopyReceiver(){
_mySender->release();
- CORBA::release(_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getDistValue(long &size){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getDistValue(long &size){
size=_mySender->getSize();
long n;
T *ret=new T[size];
return ret;
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getValue(long &size)
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaWCNoCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::CorbaWCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::CorbaWCWithCopyReceiver(CorbaSender mySender):_mySender(mySender){
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::~CorbaWCWithCopyReceiver(){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::~CorbaWCWithCopyReceiver(){
_mySender->release();
- CORBA::release(_mySender);
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getDistValue(long &size){
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getDistValue(long &size){
size=_mySender->getSize();
long n;
T *ret=new T[size];
return ret;
}
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-void *CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender>::getValue(long &size)
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+T *CorbaWCWithCopyReceiver<T,TCorba,TSeqCorba,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
#ifdef HAVE_MPI2
-template<class T,MPI_Datatype T2>
-MPIReceiver<T,T2>::MPIReceiver(SALOME::MPISender_ptr mySender):_mySender(mySender){
+template<class T,MPI_Datatype T2,class CorbaSender,class servForT,class ptrForT>
+MPIReceiver<T,T2,CorbaSender,servForT,ptrForT>::MPIReceiver(CorbaSender mySender):_mySender(mySender){
}
-template<class T,MPI_Datatype T2>
-MPIReceiver<T,T2>::~MPIReceiver(){
+template<class T,MPI_Datatype T2,class CorbaSender,class servForT,class ptrForT>
+MPIReceiver<T,T2,CorbaSender,servForT,ptrForT>::~MPIReceiver(){
_mySender->release();
- CORBA::release(_mySender);
}
-template<class T,MPI_Datatype T2>
-void *MPIReceiver<T,T2>::getDistValue(long &size){
+template<class T,MPI_Datatype T2,class CorbaSender,class servForT,class ptrForT>
+T *MPIReceiver<T,T2,CorbaSender,servForT,ptrForT>::getDistValue(long &size){
int i=0;
int myproc;
int sproc;
return _v;
}
-template<class T,MPI_Datatype T2>
-void *MPIReceiver<T,T2>::getValue(long &size)
+template<class T,MPI_Datatype T2,class CorbaSender,class servForT,class ptrForT>
+T *MPIReceiver<T,T2,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
#endif
#include <unistd.h>
#include <rpc/xdr.h>
-template<class T,int (*myFunc)(XDR*,T*)>
-SocketReceiver<T,myFunc>::SocketReceiver(SALOME::SocketSender_ptr mySender) : _mySender(mySender)
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::SocketReceiver(CorbaSender mySender) : _mySender(mySender)
{
_clientSockfd = -1;
_senderDestruc=true;
}
-template<class T,int (*myFunc)(XDR*,T*)>
-SocketReceiver<T,myFunc>::~SocketReceiver()
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::~SocketReceiver()
{
if(_senderDestruc)
{
_mySender->release();
- CORBA::release(_mySender);
}
}
-template<class T,int (*myFunc)(XDR*,T*)>
-void *SocketReceiver<T,myFunc>::getValue(long &size)
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+T *SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::getValue(long &size)
{
- return Receiver::getValue(size,_mySender);
+ return Receiver<T,servForT,ptrForT>::getValue(size,_mySender);
}
-template<class T,int (*myFunc)(XDR*,T*)>
-void* SocketReceiver<T,myFunc>::getDistValue(long &size)
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+T* SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::getDistValue(long &size)
{
int n=0, m;
T *v;
return v;
}
-template<class T,int (*myFunc)(XDR*,T*)>
-void SocketReceiver<T,myFunc>::initCom()
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+void SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::initCom()
{
try{
_mySender->initCom();
}
-template<class T,int (*myFunc)(XDR*,T*)>
-void SocketReceiver<T,myFunc>::connectCom(const char *dest_address, int port)
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+void SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::connectCom(const char *dest_address, int port)
{
struct sockaddr_in serv_addr;
struct hostent * server;
}
-template<class T,int (*myFunc)(XDR*,T*)>
-void SocketReceiver<T,myFunc>::closeCom()
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+void SocketReceiver<T,myFunc,CorbaSender,servForT,ptrForT>::closeCom()
{
_mySender->closeCom();
if( _clientSockfd >= 0 ){
/*!
Receiver used for transfert with CORBA when no copy is required remotely and locally.
*/
-template<class T,class TCorba,class TSeqCorba,class CorbaSender>
-class CorbaNCNoCopyReceiver : public Receiver
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+class CorbaNCNoCopyReceiver : public Receiver<T,servForT,ptrForT>
{
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 T,class TCorba,class TSeqCorba,class CorbaSender>
-class CorbaNCWithCopyReceiver : public Receiver
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+class CorbaNCWithCopyReceiver : public Receiver<T,servForT,ptrForT>
{
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 T,class TCorba,class TSeqCorba,class CorbaSender>
-class CorbaWCNoCopyReceiver : public Receiver
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+class CorbaWCNoCopyReceiver : public Receiver<T,servForT,ptrForT>
{
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 T,class TCorba,class TSeqCorba,class CorbaSender>
-class CorbaWCWithCopyReceiver : public Receiver
+template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
+class CorbaWCWithCopyReceiver : public Receiver<T,servForT,ptrForT>
{
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 T,MPI_Datatype T2>
-class MPIReceiver : public Receiver
+template<class T,MPI_Datatype T2,class CorbaSender,class servForT,class ptrForT>
+class MPIReceiver : public Receiver<T,servForT,ptrForT>
{
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
/*!
Receiver for transfert with sockets.
*/
-template<class T,int (*myFunc)(XDR*,T*)>
-class SocketReceiver : public Receiver
+template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
+class SocketReceiver : public Receiver<T,servForT,ptrForT>
{
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();
}
/*! 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);
return 0;
}
ret->_remove_ref();
- return dynamic_cast<SALOME_Sender_i *>(ret);
+ return dynamic_cast<SALOME_SenderDouble_i *>(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<SALOME_SenderInt_i *>(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(){
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(){
////////////////////////
-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(){
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(){
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];
}
void SALOME_MPISender_i::send()
{
+ _type=getTypeOfDataTransmitted();
_argsForThr=new (void *)[8];
_argsForThr[0]=_portName;
_argsForThr[1]=&_lgrTabToSend;
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)
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
#include <netdb.h>
#include <unistd.h>
-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;
void SALOME_SocketSender_i::send()
{
+ _type=getTypeOfDataTransmitted();
_argsForThr=new void *[6];
_argsForThr[0]=&_serverSockfd;
_argsForThr[1]=&_clientSockfd;
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)
void SALOME_SocketSender_i::acceptCom() throw(SALOME::SALOME_Exception)
{
socklen_t sin_size;
- int new_fd;
struct sockaddr_in client_addr;
SALOME::ExceptionStruct es;
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
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);
/*! 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);
/*! 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);
/*! 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);
/*! 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;
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();
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;
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();
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
#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
{
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);
+}
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.
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<class T>
+struct mapCppSender {
+ typedef T SenderVarType;
+};
+
+template<>
+struct mapCppSender<int>
+{
+ typedef SALOME::SenderInt_var SenderVarType;
+};
+
+template<>
+struct mapCppSender<double>
+{
+ typedef SALOME::SenderDouble_var SenderVarType;
};
#endif