1 #include "ReceiverFactory.hxx"
2 #include "Receivers.hxx"
4 #ifdef COMP_CORBA_DOUBLE
5 #define CorbaDNoCopyReceiver CorbaNCNoCopyReceiver
6 #define CorbaDWithCopyReceiver CorbaNCWithCopyReceiver
8 #define CorbaDNoCopyReceiver CorbaWCNoCopyReceiver
9 #define CorbaDWithCopyReceiver CorbaWCWithCopyReceiver
12 #ifdef COMP_CORBA_LONG
13 #define CorbaINoCopyReceiver CorbaNCNoCopyReceiver
14 #define CorbaIWithCopyReceiver CorbaNCWithCopyReceiver
16 #define CorbaINoCopyReceiver CorbaWCNoCopyReceiver
17 #define CorbaIWithCopyReceiver CorbaWCWithCopyReceiver
25 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).
27 void *ReceiverFactory::getValue(SALOME::Sender_ptr sender,long &size)throw(MultiCommException)
31 ret=getValueOneShot(sender,size);
33 catch(MultiCommException&)
35 SALOME::Sender_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_);
36 MESSAGE("PROTOCOL CHANGED TO CORBA");
38 CORBA::release(sender);
39 ret=getValueOneShot(newSender,size);
45 This method performs the transfert with the remote sender given. If it fails an exception is thrown.
47 void *ReceiverFactory::getValueOneShot(SALOME::Sender_ptr sender,long &size)throw(MultiCommException)
49 SALOME::CorbaDoubleNCSender_ptr cncD_ptr;
50 SALOME::CorbaDoubleCSender_ptr cwcD_ptr;
51 SALOME::CorbaLongNCSender_ptr cncL_ptr;
52 SALOME::CorbaLongCSender_ptr cwcL_ptr;
54 SALOME::MPISender_ptr mpi_ptr=SALOME::MPISender::_narrow(sender);
57 SALOME::SocketSender_ptr sock_ptr=SALOME::SocketSender::_narrow(sender);
59 switch(sender->getTypeOfDataTransmitted())
62 cncD_ptr=SALOME::CorbaDoubleNCSender::_narrow(sender);
63 cwcD_ptr=SALOME::CorbaDoubleCSender::_narrow(sender);
64 if(!CORBA::is_nil(cncD_ptr))
66 CORBA::release(sender);
67 CorbaDNoCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleNCSender_ptr> rec(cncD_ptr);
68 return rec.getValue(size);
70 else if(!CORBA::is_nil(cwcD_ptr))
72 CORBA::release(sender);
73 CorbaDWithCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleCSender_ptr> rec(cwcD_ptr);
74 return rec.getValue(size);
77 else if(!CORBA::is_nil(mpi_ptr))
79 CORBA::release(sender);
80 MPIReceiver<double,MPI_DOUBLE> rec(mpi_ptr);
81 return rec.getValue(size);
85 else if(!CORBA::is_nil(sock_ptr))
87 CORBA::release(sender);
88 SocketReceiver<double,xdr_double> rec(sock_ptr);
89 return rec.getValue(size);
94 throw MultiCommException("Unknown sender protocol");
98 cncL_ptr=SALOME::CorbaLongNCSender::_narrow(sender);
99 cwcL_ptr=SALOME::CorbaLongCSender::_narrow(sender);
100 if(!CORBA::is_nil(cncL_ptr))
102 CORBA::release(sender);
103 CorbaINoCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongNCSender_ptr> rec(cncL_ptr);
104 return rec.getValue(size);
106 else if(!CORBA::is_nil(cwcL_ptr))
108 CORBA::release(sender);
109 CorbaIWithCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongCSender_ptr> rec(cwcL_ptr);
110 return rec.getValue(size);
113 else if(!CORBA::is_nil(mpi_ptr))
115 CORBA::release(sender);
116 MPIReceiver<int,MPI_INT> rec(mpi_ptr);
117 return rec.getValue(size);
121 else if(!CORBA::is_nil(sock_ptr))
123 CORBA::release(sender);
124 SocketReceiver<int,xdr_int> rec(sock_ptr);
125 return rec.getValue(size);
130 throw MultiCommException("Unknown sender protocol");
134 throw MultiCommException("unknown type of data transfered");