1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __DATA_MESSAGE_H__ |
8 |
|
|
#define __DATA_MESSAGE_H__ |
9 |
|
|
|
10 |
|
|
#include "data_stream.h" |
11 |
|
|
|
12 |
|
|
///Save data in a message |
13 |
|
|
/** @param[out] iter : message to be written |
14 |
|
|
* @param data : data to be saved in the message |
15 |
|
|
* @return true on success, false otherwise |
16 |
|
|
*/ |
17 |
|
|
template<typename Stream, typename T> |
18 |
|
89 |
bool data_message_save(Stream &iter, T & data){ |
19 |
|
89 |
return DataStream<Stream, DataStreamMode::WRITE, T>::data_stream(iter, data); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
///Save data in a message |
23 |
|
|
/** @param[out] iter : message to be written |
24 |
|
|
* @param data : data to be saved in the message |
25 |
|
|
* @return true on success, false otherwise |
26 |
|
|
*/ |
27 |
|
|
template<typename Stream, typename T> |
28 |
|
|
bool data_message_save(Stream &iter, const T & data){ |
29 |
|
|
return DataStream<Stream, DataStreamMode::WRITE, T>::data_stream(iter, (T&)data); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
///Save data in a message |
33 |
|
|
/** @param[out] iter : message to be written |
34 |
|
|
* @param data : data to be saved in the message |
35 |
|
|
* @param nbElement : number of elements to be saved |
36 |
|
|
* @return true on success, false otherwise |
37 |
|
|
*/ |
38 |
|
|
template<typename Stream, typename T> |
39 |
|
2156 |
bool data_message_save(Stream &iter, T * data, size_t nbElement){ |
40 |
|
2156 |
return DataStream<Stream, DataStreamMode::WRITE, T>::data_stream(iter, data, nbElement); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
///Save data in a message |
44 |
|
|
/** @param[out] iter : message to be written |
45 |
|
|
* @param data : data to be saved in the message |
46 |
|
|
* @param nbElement : number of elements to be saved |
47 |
|
|
* @return true on success, false otherwise |
48 |
|
|
*/ |
49 |
|
|
template<typename Stream, typename T> |
50 |
|
|
bool data_message_save(Stream &iter, const T * data, size_t nbElement){ |
51 |
|
|
return DataStream<Stream, DataStreamMode::WRITE, T>::data_stream(iter, (T*)data, nbElement); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
///Load data from a message |
55 |
|
|
/** @param[out] iter : message to be read |
56 |
|
|
* @param[out] data : data to be loaded from the message |
57 |
|
|
* @return true on success, false otherwise |
58 |
|
|
*/ |
59 |
|
|
template<typename T> |
60 |
|
45 |
bool data_message_load(char*&iter, T & data){ |
61 |
|
45 |
return DataStream<char*, DataStreamMode::READ, T>::data_stream(iter, data); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
///Load data from a message |
65 |
|
|
/** @param[out] iter : message to be read |
66 |
|
|
* @param[out] data : data to be loaded from the message |
67 |
|
|
* @param nbElement : number of elements to be loaded |
68 |
|
|
* @return true on success, false otherwise |
69 |
|
|
*/ |
70 |
|
|
template<typename T> |
71 |
|
1078 |
bool data_message_load(char*&iter, T * data, size_t nbElement){ |
72 |
|
1078 |
return DataStream<char*, DataStreamMode::READ, T>::data_stream(iter, data, nbElement); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
#endif |