SOLA
Loading...
Searching...
No Matches
message_header.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 MINHTON_MESSAGE_HEADER_H_
8#define MINHTON_MESSAGE_HEADER_H_
9
10#include <cstdint>
11#include <map>
12
13#include "minhton/core/constants.h"
14#include "minhton/core/node_info.h"
15#include "minhton/message/message_logging.h"
16#include "minhton/message/types.h"
17#include "solanet/serializer/serialize.h"
18
19namespace minhton {
25public:
26 MinhtonMessageHeader() = default;
27 MinhtonMessageHeader(NodeInfo sender, NodeInfo target, uint64_t ref_event_id = 0);
28 uint64_t getEventId() const;
29 uint64_t getRefEventId() const;
30 NodeInfo getSender() const;
31 NodeInfo getTarget() const;
32 MessageType getMessageType() const;
33
34 void setSender(const NodeInfo &sender);
35 void setTarget(const NodeInfo &target);
36 void setEventId(uint64_t event_id);
37 void setRefEventId(uint64_t ref_event_id);
38 void setMessageType(MessageType type);
39
43 MessageLoggingInfo getMessageLoggingInfo(bool receive) const;
44
45 void setAdditionalLoggingInfo(const MessageLoggingAdditionalInfo &additional_info);
46 MessageLoggingAdditionalInfo getAdditionalLoggingInfo() const;
47
50 bool validate() const;
51
52 SERIALIZE(sender_, target_, message_type_, ref_event_id_, event_id_, additional_logging_info_);
53
54private:
55 NodeInfo sender_;
56 NodeInfo target_;
57 MessageType message_type_ = MessageType::kInit;
58 uint64_t ref_event_id_ = 0;
59 uint64_t event_id_ = 0;
60 MessageLoggingAdditionalInfo additional_logging_info_;
61};
62
63std::string getMessageTypeString(MessageType type);
64} // namespace minhton
65#endif
Definition message_header.h:24
MessageLoggingInfo getMessageLoggingInfo(bool receive) const
Definition message_header.cpp:100
bool validate() const
Definition message_header.cpp:121
Definition node_info.h:24
Definition minhton_watchdog_ns3.cpp:24
MessageType
Definition types.h:17
Definition message_logging.h:13
Definition message_logging.h:23