Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file four_int_values.hpp |
3 |
|
|
o * @author Vincent Berenz |
4 |
|
|
* @license License BSD-3-Clause |
5 |
|
|
* @copyright Copyright (c) 2019, New York University and Max Planck |
6 |
|
|
Gesellschaft. |
7 |
|
|
* @date 2019-05-22 |
8 |
|
|
* |
9 |
|
|
* @brief Defines a messages to be sent throw the shared memory |
10 |
|
|
*/ |
11 |
|
|
|
12 |
|
|
#pragma once |
13 |
|
|
|
14 |
|
|
#include <iostream> |
15 |
|
|
#include "shared_memory/serializer.hpp" |
16 |
|
|
|
17 |
|
|
namespace shared_memory |
18 |
|
|
{ |
19 |
|
|
/** |
20 |
|
|
* Example of an instance that can be serialized. |
21 |
|
|
* Notice: |
22 |
|
|
* There is a default constructor |
23 |
|
|
* There is a serialize function |
24 |
|
|
* It is friend to private_serialization |
25 |
|
|
*/ |
26 |
|
1081 |
class Four_int_values |
27 |
|
|
{ |
28 |
|
|
public: |
29 |
|
|
Four_int_values(); |
30 |
|
|
Four_int_values(int a, int b, int c, int d); |
31 |
|
|
int get_id() const; |
32 |
|
|
void set_id(int id); |
33 |
|
|
|
34 |
|
|
public: |
35 |
|
|
template <class Archive> |
36 |
|
2070 |
void serialize(Archive &archive) |
37 |
|
|
{ |
38 |
|
2070 |
archive(id_, values_); |
39 |
|
2070 |
} |
40 |
|
|
|
41 |
|
|
public: |
42 |
|
|
// stored values are all equals, in same order |
43 |
|
|
bool equal(const Four_int_values &other) const; |
44 |
|
|
|
45 |
|
|
// equal, + same id |
46 |
|
|
bool same(const Four_int_values &other) const; |
47 |
|
|
|
48 |
|
|
public: |
49 |
|
|
void print() const; |
50 |
|
|
|
51 |
|
|
private: |
52 |
|
|
static int next_id(); |
53 |
|
|
|
54 |
|
|
private: |
55 |
|
|
friend private_serialization; |
56 |
|
|
|
57 |
|
|
std::vector<int> values_; |
58 |
|
|
int id_; |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
} // namespace shared_memory |
62 |
|
|
|