1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #ifndef _SALOME_COMM_I_HXX_
21 #define _SALOME_COMM_I_HXX_
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(SALOME_Comm)
34 Generic servant class for senders that factorizes all the common methods and attributes necessary to senders.
35 All servant classes for senders have to inheritate from it.
37 class SALOME_Sender_i : public virtual POA_SALOME::Sender,
38 public PortableServer::RefCountServantBase {
40 /*! Pointer to the generic array to transmit*/
41 const void *_tabToSend;
42 /*! Length of the generic array to transmit*/
44 /*! it represents the sizeof() of each component of the generic array:\n
45 Practically in terms of bytes the size to be transmitted is _lgrTabToSend*_sizeOf
48 /*! Indicates if _tabToSend has to be deallocated */
51 SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
53 const void *getData(long &size) const;
54 int getSizeOf() const;
55 void setOwnerShip(bool own);
56 bool getOwnerShip() const { return _ownTabToSend; }
58 virtual ~SALOME_Sender_i() {}
61 class SALOME_SenderDouble_i : public virtual POA_SALOME::SenderDouble,
62 public virtual SALOME_Sender_i
65 SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
66 SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::DOUBLE_; }
67 SALOME::SenderDouble_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
68 virtual ~SALOME_SenderDouble_i();
69 static SALOME_SenderDouble_i *find(SALOME::SenderDouble_ptr pCorba);
72 class SALOME_SenderInt_i : public virtual POA_SALOME::SenderInt,
73 public virtual SALOME_Sender_i
76 SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
77 SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::INT_; }
78 SALOME::SenderInt_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
79 virtual ~SALOME_SenderInt_i();
80 static SALOME_SenderInt_i *find(SALOME::SenderInt_ptr pCorba);
83 /*! 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.
85 class SALOME_CorbaDoubleNCSender_i : public POA_SALOME::CorbaDoubleNCSender,
86 public SALOME_SenderDouble_i
89 SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
90 ~SALOME_CorbaDoubleNCSender_i();
91 CORBA::ULong getSize();
92 SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
93 SALOME::vectorOfDouble* send();
96 /*! 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.
98 class SALOME_CorbaDoubleCSender_i : public POA_SALOME::CorbaDoubleCSender,
99 public SALOME_SenderDouble_i
102 SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
103 ~SALOME_CorbaDoubleCSender_i();
104 CORBA::ULong getSize();
105 SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
108 /*! 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.
110 class SALOME_CorbaLongNCSender_i : public POA_SALOME::CorbaLongNCSender,
111 public SALOME_SenderInt_i
114 SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
115 ~SALOME_CorbaLongNCSender_i();
116 CORBA::ULong getSize();
117 SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
118 SALOME::vectorOfLong* send();
121 /*! 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.
123 class SALOME_CorbaLongCSender_i : public POA_SALOME::CorbaLongCSender,
124 public SALOME_SenderInt_i
127 SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
128 ~SALOME_CorbaLongCSender_i();
129 CORBA::ULong getSize();
130 SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
132 SALOME::CorbaLongCSender_ptr _this();
138 /*! Servant class of sender using MPI2.
140 class SALOME_MPISender_i : public virtual POA_SALOME::MPISender,
141 public virtual SALOME_Sender_i
144 static unsigned long _tag1;
145 static unsigned long _tag2;
146 /*! Name of the port opened*/
149 /*! Tag 1 that identifies the transfert*/
151 /*! Tag 2 that identifies the transfert*/
153 /*! MPI communicator*/
155 /*! Array of pointer for asynchronous invocation with omnithread*/
157 /*! Pointer to thread created on asynchronous invocation*/
158 omni_thread *_newThr;
159 /*! Type the component of the array*/
160 SALOME::TypeOfDataTransmitted _type;
162 SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
163 ~SALOME_MPISender_i();
164 SALOME::MPISender::param* getParam();
166 void close(const SALOME::MPISender::param& p);
168 static void* myThread(void *args);
171 class SALOME_MPISenderDouble_i : public POA_SALOME::MPISenderDouble,
172 public SALOME_SenderDouble_i,
173 public SALOME_MPISender_i
176 SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
179 class SALOME_MPISenderInt_i : public POA_SALOME::MPISenderInt,
180 public SALOME_SenderInt_i,
181 public SALOME_MPISender_i
184 SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
191 /*! Servant class of sender using Sockets.
193 class SALOME_SocketSender_i : public virtual POA_SALOME::SocketSender,
194 public virtual SALOME_Sender_i
200 std::string _IPAddress;
202 omni_thread *_newThr;
204 /*! Type the component of the array*/
205 SALOME::TypeOfDataTransmitted _type;
207 SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
208 ~SALOME_SocketSender_i();
209 SALOME::SocketSender::param* getParam();
211 void initCom() throw(SALOME::SALOME_Exception);
212 void acceptCom() throw(SALOME::SALOME_Exception);
216 static void* myThread(void *args);
217 std::string inetAddress();
220 class SALOME_SocketSenderDouble_i : public POA_SALOME::SocketSenderDouble,
221 public SALOME_SenderDouble_i,
222 public SALOME_SocketSender_i
225 SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
228 class SALOME_SocketSenderInt_i : public POA_SALOME::SocketSenderInt,
229 public SALOME_SenderInt_i,
230 public SALOME_SocketSender_i
233 SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);