Salome HOME
Implemented a possibility to dlopen SalomeDS libarary and create SObject, Study,...
[modules/kernel.git] / src / Communication / Receivers.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/
19 //
20 #ifndef _RECEIVERS_HXX_
21 #define _RECEIVERS_HXX_
22
23 #ifdef HAVE_MPI2
24 #include "mpi.h"
25 #endif
26 #include "SALOME_Comm_i.hxx"
27 #include "Receiver.hxx"
28
29 /*!
30   Receiver used for transfert with CORBA when no copy is required remotely and locally.
31  */
32 template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
33 class CorbaNCNoCopyReceiver : public Receiver<T,servForT,ptrForT>
34 {
35 private:
36   CorbaSender _mySender;
37 public:
38   CorbaNCNoCopyReceiver(CorbaSender mySender);
39   ~CorbaNCNoCopyReceiver();
40   T *getValue(long &size);
41 private:
42   T *getDistValue(long &size);
43 };
44
45 /*!
46   Receiver used for transfert with CORBA when copy is not required remotely but required locally.
47  */
48 template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
49 class CorbaNCWithCopyReceiver : public Receiver<T,servForT,ptrForT>
50 {
51 private:
52   CorbaSender _mySender;
53 public:
54   CorbaNCWithCopyReceiver(CorbaSender mySender);
55   ~CorbaNCWithCopyReceiver();
56   T *getValue(long &size);
57 private:
58   T *getDistValue(long &size);
59 };
60
61 /*!
62   Receiver used for transfert with CORBA when copy is required remotely but not required locally.
63  */
64 template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
65 class CorbaWCNoCopyReceiver : public Receiver<T,servForT,ptrForT>
66 {
67 private:
68   CorbaSender  _mySender;
69 public:
70   CorbaWCNoCopyReceiver(CorbaSender mySender);
71   ~CorbaWCNoCopyReceiver();
72   T *getValue(long &size);
73 private:
74   T *getDistValue(long &size);
75 };
76
77 /*!
78   Receiver used for transfert with CORBA when copy is required both remotely and locally.
79  */
80 template<class T,class TCorba,class TSeqCorba,class CorbaSender,class servForT,class ptrForT>
81 class CorbaWCWithCopyReceiver : public Receiver<T,servForT,ptrForT>
82 {
83 private:
84   CorbaSender _mySender;
85 public:
86   CorbaWCWithCopyReceiver(CorbaSender mySender);
87   ~CorbaWCWithCopyReceiver();
88   T *getValue(long &size);
89 private:
90   T *getDistValue(long &size);
91 };
92
93 #ifdef HAVE_MPI2
94 /*!
95   Receiver for MPI transfert.
96  */
97 template<class T>
98 struct MPITRAITS
99 {
100   static MPI_Datatype MpiType;
101 };
102
103 template<>
104 MPI_Datatype MPITRAITS<double>::MpiType=MPI_DOUBLE;
105
106 template<>
107 MPI_Datatype MPITRAITS<int>::MpiType=MPI_INT;
108
109 template<class T,class CorbaSender,class servForT,class ptrForT>
110 class MPIReceiver : public Receiver<T,servForT,ptrForT>
111 {
112 private:
113   CorbaSender _mySender;
114 public:
115   MPIReceiver(CorbaSender mySender);
116   ~MPIReceiver();
117   T *getValue(long &size);
118 private:
119   T *getDistValue(long &size);
120 };
121 #endif
122
123 #ifdef HAVE_SOCKET
124
125 class XDR;
126
127 /*!
128   Receiver for transfert with sockets.
129  */
130 template<class T,int (*myFunc)(XDR*,T*),class CorbaSender,class servForT,class ptrForT>
131 class SocketReceiver : public Receiver<T,servForT,ptrForT>
132 {
133 private:
134   CorbaSender _mySender;
135   int _clientSockfd;
136   bool _senderDestruc;
137 public:
138   SocketReceiver(CorbaSender mySender);
139   ~SocketReceiver();
140   T *getValue(long &size);
141 private:
142   T *getDistValue(long &size);
143   void initCom();
144   void connectCom(const char *, int);
145   void closeCom();
146 };
147 #endif
148
149 #include "Receivers.cxx"
150
151 #endif
152