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