1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/**
* This class is an implementation of the C++ bindings for Calcium.
* Calcium capabilities with iteration synchronization are available for a program written in C++
* by using methods belonging to the Communication class.
*
* The Communication class uses predefined declarations for some datatypes:
* <table border="0">
* <tr> <td><tt>#define IntPtr</tt>:</td> <td><tt>boost::shared_array<int_32></tt></td> </tr>
* <tr> <td><tt>#define FloatPtr</tt>:</td> <td><tt>boost::shared_array<float_32></tt></td> </tr>
* <tr> <td><tt>#define DoublePtr</tt>:</td> <td><tt>boost::shared_array<double_64></tt></td> </tr>
* <tr> <td><tt>#define BoolPtr</tt>:</td> <td><tt>boost::shared_array<bool></tt></td> </tr>
* </table>
* <P>
* Moreover, send methods are constructing shared arrays that <i>cannot</i> be modified in the calling C++
* code. To prevent this, they are declared <tt>const</tt> using the following predefined declarations:
* <table border="0">
* <tr> <td><tt>#define IntPtrConst</tt>:</td> <td><tt>boost::shared_array<const int_32></tt></td> </tr>
* <tr> <td><tt>#define FloatPtrConst</tt>:</td> <td><tt>boost::shared_array<const float_32></tt></td> </tr>
* <tr> <td><tt>#define DoublePtrConst</tt>:</td> <td><tt>boost::shared_array<const double_64></tt></td> </tr>
* <tr> <td><tt>#define BoolPtrConst</tt>:</td> <td><tt>boost::shared_array<const bool></tt></td> </tr>
* </table>
* <P>
*
* @author Hadrien Leroyer, EDF and Alain Hebert, Ecole Polytechnique
* de Montreal (2013)
*/
#if ! defined( __Communication_hxx__ )
#define __Communication_hxx__
#include <iostream>
#include "CalciumException.hxx"
extern "C" {
#include <unistd.h>
#include "calcium.h"
}
#include "Cle2000.hxx"
class Communication {
private:
void* compo_;
public:
/** use this constructor to create a new empty Communication object
*/
Communication();
/** use this constructor to create a new Communication object with an embedded component
* @param compo embedded component
*/
Communication(const Communication& compo);
virtual ~Communication();
/** initialize the Communication object and set the embedded component
* @param compo embedded Calcium component
*/
int initialize(void* compo);
/** close the Communication object
*/
int terminate();
/** send a single integer value
* @param iteration iteration index
* @param portName name of the datastream
* @param val integer value
*/
int send(const int iteration, const std::string portName, const int& val );
/** send an integer array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the integer array
* @param tab integer array
*/
int send(const int iteration, const std::string portName, const int size, IntPtrConst& tab );
/** send a single real value
* @param iteration iteration index
* @param portName name of the datastream
* @param val real value
*/
int send(const int iteration, const std::string portName, const float& val );
/** send an real array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the real array
* @param tab real array
*/
int send(const int iteration, const std::string portName, const int size, FloatPtrConst& tab );
/** send a single double precision real value
* @param iteration iteration index
* @param portName name of the datastream
* @param val double precision real value
*/
int send(const int iteration, const std::string portName, const double& val );
/** send an double precision real array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the double precision real array
* @param tab double precision real array
*/
int send(const int iteration, const std::string portName, const int size, DoublePtrConst& tab );
/** send a single boolean value
* @param iteration iteration index
* @param portName name of the datastream
* @param val boolean value
*/
int send(const int iteration, const std::string portName, const bool& val );
/** send an boolean array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the boolean array
* @param tab boolean array
*/
int send(const int iteration, const std::string portName, const int size, BoolPtrConst& tab );
/** receive a single integer value
* @param iteration iteration index
* @param portName name of the datastream
* @param val integer value
*/
int recv(int& iteration, const std::string portName, int& val );
/** receive an integer array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the integer array
* @param tab integer array
*/
int recv(int& iteration, const std::string portName, const int size, IntPtr& tab );
/** receive a single real value
* @param iteration iteration index
* @param portName name of the datastream
* @param val real value
*/
int recv(int& iteration, const std::string portName, float& val );
/** receive an real array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the real array
* @param tab real array
*/
int recv(int& iteration, const std::string portName, const int size, FloatPtr& tab );
/** receive a single double precision real value
* @param iteration iteration index
* @param portName name of the datastream
* @param val double precision real value
*/
int recv(int& iteration, const std::string portName, double& val );
/** receive an double precision real array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the double precision real array
* @param tab double precision real array
*/
int recv(int& iteration, const std::string portName, const int size, DoublePtr& tab );
/** receive a single boolean value
* @param iteration iteration index
* @param portName name of the datastream
* @param val boolean value
*/
int recv(int& iteration, const std::string portName, bool& val );
/** receive a boolean array
* @param iteration iteration index
* @param portName name of the datastream
* @param size size of the oolean array
* @param tab boolean array
*/
int recv(int& iteration, const std::string portName, const int size, BoolPtr& tab );
};
#endif //#if ! defined( __Communication_hxx__ )
|