Line data Source code
1 : /**
2 : * @file ListWrapper.hpp
3 : *
4 : * ListWrapper wraps a std::vector<int> so that it can be transmitted over the network using the Unified Communications
5 : * API (iomanager)
6 : *
7 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
8 : * Licensing/copyright details are in the COPYING file that you should have
9 : * received with this code.
10 : */
11 :
12 : #ifndef LISTREV_SRC_LISTWRAPPER_HPP_
13 : #define LISTREV_SRC_LISTWRAPPER_HPP_
14 :
15 : #include "serialization/Serialization.hpp"
16 :
17 : #include <string>
18 : #include <vector>
19 :
20 : namespace dunedaq {
21 : namespace listrev {
22 : struct IntList
23 : {
24 : int list_id;
25 : int generator_id;
26 : std::vector<int> list;
27 :
28 37 : IntList() = default;
29 19 : explicit IntList(const int& id, const int& gid, std::vector<int> const& l)
30 19 : : list_id(id)
31 19 : , generator_id(gid)
32 19 : , list(l.begin(), l.end())
33 : {
34 19 : }
35 :
36 12 : DUNE_DAQ_SERIALIZE(IntList, list_id, generator_id, list);
37 : };
38 :
39 : struct ReversedList
40 : {
41 : struct Data
42 : {
43 : IntList original;
44 : IntList reversed;
45 :
46 4 : DUNE_DAQ_SERIALIZE(Data, original, reversed);
47 : };
48 : int list_id;
49 : int reverser_id;
50 : std::vector<Data> lists;
51 :
52 11 : ReversedList() = default;
53 4 : ReversedList(const int& id, const int& rid, std::vector<Data> const& ls)
54 4 : : list_id(id)
55 4 : , reverser_id(rid)
56 4 : , lists(ls.begin(), ls.end())
57 : {
58 4 : }
59 :
60 2 : DUNE_DAQ_SERIALIZE(ReversedList, list_id, reverser_id, lists);
61 : };
62 :
63 : struct CreateList
64 : {
65 : int list_id;
66 : uint16_t list_size; // NOLINT(build/unsigned)
67 :
68 : CreateList() = default;
69 3 : CreateList(const int& id, const uint16_t& size) // NOLINT(build/unsigned)
70 3 : : list_id(id)
71 3 : , list_size(size)
72 : {
73 3 : }
74 :
75 2 : DUNE_DAQ_SERIALIZE(CreateList, list_id, list_size);
76 : };
77 : struct RequestList
78 : {
79 : int list_id;
80 : std::string destination;
81 :
82 49 : RequestList() = default;
83 8 : explicit RequestList(const int& id, const std::string& dest)
84 8 : : list_id(id)
85 8 : , destination(dest)
86 : {
87 8 : }
88 :
89 2 : DUNE_DAQ_SERIALIZE(RequestList, list_id, destination);
90 : };
91 : } // namespace listrev
92 :
93 33 : DUNE_DAQ_SERIALIZABLE(listrev::IntList, "IntList");
94 1 : DUNE_DAQ_SERIALIZABLE(listrev::ReversedList::Data, "ReversedListData");
95 41 : DUNE_DAQ_SERIALIZABLE(listrev::ReversedList, "ReversedList");
96 147 : DUNE_DAQ_SERIALIZABLE(listrev::CreateList, "CreateList");
97 155 : DUNE_DAQ_SERIALIZABLE(listrev::RequestList, "RequestList");
98 : } // namespace dunedaq
99 :
100 : #endif // LISTREV_SRC_LISTWRAPPER_HPP_
|