1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 #include "ReceiverFactory.hxx"
27 #include "Receivers.hxx"
29 #ifdef COMP_CORBA_DOUBLE
30 #define CorbaDNoCopyReceiver CorbaNCNoCopyReceiver
31 #define CorbaDWithCopyReceiver CorbaNCWithCopyReceiver
33 #define CorbaDNoCopyReceiver CorbaWCNoCopyReceiver
34 #define CorbaDWithCopyReceiver CorbaWCWithCopyReceiver
37 #ifdef COMP_CORBA_LONG
38 #define CorbaINoCopyReceiver CorbaNCNoCopyReceiver
39 #define CorbaIWithCopyReceiver CorbaNCWithCopyReceiver
41 #define CorbaINoCopyReceiver CorbaWCNoCopyReceiver
42 #define CorbaIWithCopyReceiver CorbaWCWithCopyReceiver
50 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).
52 double *ReceiverFactory::getValue(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException)
56 ret=getValueOneShot(sender,size);
58 catch(MultiCommException&)
60 SALOME::SenderDouble_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_);
61 MESSAGE("PROTOCOL CHANGED TO CORBA");
63 ret=getValueOneShot(newSender,size);
64 CORBA::release(newSender);
70 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).
72 int *ReceiverFactory::getValue(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException)
76 ret=getValueOneShot(sender,size);
78 catch(MultiCommException&)
80 SALOME::SenderInt_ptr newSender=sender->buildOtherWithProtocol(SALOME::CORBA_);
81 MESSAGE("PROTOCOL CHANGED TO CORBA");
83 ret=getValueOneShot(newSender,size);
84 CORBA::release(newSender);
90 This method performs the transfert with the remote SenderDouble given. If it fails an exception is thrown.
92 double *ReceiverFactory::getValueOneShot(SALOME::SenderDouble_ptr sender,long &size)throw(MultiCommException)
94 SALOME::CorbaDoubleNCSender_ptr cncD_ptr;
95 SALOME::CorbaDoubleCSender_ptr cwcD_ptr;
97 SALOME::MPISenderDouble_ptr mpi_ptr=SALOME::MPISenderDouble::_narrow(sender);
100 SALOME::SocketSenderDouble_ptr sock_ptr=SALOME::SocketSenderDouble::_narrow(sender);
102 cncD_ptr=SALOME::CorbaDoubleNCSender::_narrow(sender);
103 cwcD_ptr=SALOME::CorbaDoubleCSender::_narrow(sender);
104 if(!CORBA::is_nil(cncD_ptr))
106 CORBA::release(sender);
107 CorbaDNoCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleNCSender_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(cncD_ptr);
108 return rec.getValue(size);
110 else if(!CORBA::is_nil(cwcD_ptr))
112 CORBA::release(sender);
113 CorbaDWithCopyReceiver<double,CORBA::Double,SALOME::vectorOfDouble_var,SALOME::CorbaDoubleCSender_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(cwcD_ptr);
114 return rec.getValue(size);
117 else if(!CORBA::is_nil(mpi_ptr))
119 CORBA::release(sender);
120 MPIReceiver<double,SALOME::MPISenderDouble_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(mpi_ptr);
121 return rec.getValue(size);
125 else if(!CORBA::is_nil(sock_ptr))
127 CORBA::release(sender);
128 SocketReceiver<double,xdr_double,SALOME::SocketSenderDouble_ptr,SALOME::SenderDouble_ptr,SALOME_SenderDouble_i> rec(sock_ptr);
129 return rec.getValue(size);
134 throw MultiCommException("Unknown sender protocol");
140 This method performs the transfert with the remote SenderInt given. If it fails an exception is thrown.
142 int *ReceiverFactory::getValueOneShot(SALOME::SenderInt_ptr sender,long &size)throw(MultiCommException)
144 SALOME::CorbaLongNCSender_ptr cncL_ptr;
145 SALOME::CorbaLongCSender_ptr cwcL_ptr;
147 SALOME::MPISenderInt_ptr mpi_ptr=SALOME::MPISenderInt::_narrow(sender);
150 SALOME::SocketSenderInt_ptr sock_ptr=SALOME::SocketSenderInt::_narrow(sender);
152 cncL_ptr=SALOME::CorbaLongNCSender::_narrow(sender);
153 cwcL_ptr=SALOME::CorbaLongCSender::_narrow(sender);
154 if(!CORBA::is_nil(cncL_ptr))
156 CORBA::release(sender);
157 CorbaINoCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongNCSender_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(cncL_ptr);
158 return rec.getValue(size);
160 else if(!CORBA::is_nil(cwcL_ptr))
162 CORBA::release(sender);
163 CorbaIWithCopyReceiver<int,CORBA::Long,SALOME::vectorOfLong_var,SALOME::CorbaLongCSender_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(cwcL_ptr);
164 return rec.getValue(size);
167 else if(!CORBA::is_nil(mpi_ptr))
169 CORBA::release(sender);
170 MPIReceiver<int,SALOME::MPISenderInt_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(mpi_ptr);
171 return rec.getValue(size);
175 else if(!CORBA::is_nil(sock_ptr))
177 CORBA::release(sender);
178 SocketReceiver<int,xdr_int,SALOME::SocketSenderInt_ptr,SALOME::SenderInt_ptr,SALOME_SenderInt_i> rec(sock_ptr);
179 return rec.getValue(size);
184 throw MultiCommException("Unknown sender protocol");