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