SOLA
Loading...
Searching...
No Matches
minhcast_message.h
1// Copyright The SOLA Contributors
2//
3// Licensed under the MIT License.
4// For details on the licensing terms, see the LICENSE file.
5// SPDX-License-Identifier: MIT
6
7#ifndef NATTER_MINHCAST_MINHCAST_MESSAGE_H_
8#define NATTER_MINHCAST_MINHCAST_MESSAGE_H_
9
10#include <cstdint>
11#include <string>
12#include <tuple>
13#include <utility>
14
15#include "forwarding_limit.h"
16#include "natter/minhcast_level_number.h"
17#include "solanet/serializer/serialize.h"
18#include "solanet/uuid.h"
19
20namespace natter::minhcast {
22public:
23 MinhcastMessage() = default;
24 MinhcastMessage(std::string topic, solanet::UUID message_id,
25 std::tuple<solanet::UUID, minhcast::LevelNumber> initial_node,
26 std::tuple<solanet::UUID, minhcast::LevelNumber> last_node, std::string content,
27 uint32_t round, ForwardingLimit forwarding_limit, bool inner = false)
28 : topic_(std::move(topic)),
29 message_id_(std::move(message_id)),
30 initial_node_(std::move(initial_node)),
31 last_node_(std::move(last_node)),
32 content_(std::move(content)),
33 round_(round),
34 forwarding_limit_(std::move(forwarding_limit)),
35 inner_(inner) {}
36
37 std::string getTopic() const { return topic_; }
38 solanet::UUID getMessageID() const { return message_id_; }
39 solanet::UUID getInitialNodeUUID() const { return std::get<0>(initial_node_); }
40 solanet::UUID getLastNodeUUID() const { return std::get<0>(last_node_); }
41 minhcast::LevelNumber getInitialNodePos() const { return std::get<1>(initial_node_); }
42 minhcast::LevelNumber getLastNodePos() const { return std::get<1>(last_node_); }
43 std::string getContent() const { return content_; }
44 uint32_t getRound() const { return round_; }
45 bool isInnerForward() const { return inner_; }
46 ForwardingLimit getForwardingLimit() const { return forwarding_limit_; }
47
48 SERIALIZE(topic_, message_id_, initial_node_, last_node_, content_, round_, forwarding_limit_,
49 inner_);
50
51private:
52 std::string topic_;
53 solanet::UUID message_id_;
54 std::tuple<solanet::UUID, minhcast::LevelNumber> initial_node_;
55 std::tuple<solanet::UUID, minhcast::LevelNumber> last_node_;
56 std::string content_;
57 uint32_t round_ = 0;
58 ForwardingLimit forwarding_limit_;
59
60 bool inner_ = false;
61};
62} // namespace natter::minhcast
63
64#endif // DAISI_MINHCAST_MESSAGE_H_
Definition forwarding_limit.h:19
Definition minhcast_message.h:21