7#ifndef MINHTON_MESSAGE_MESSAGE_H_
8#define MINHTON_MESSAGE_MESSAGE_H_
17#include "minhton/core/node_info.h"
18#include "minhton/message/message_header.h"
19#include "minhton/message/message_logging.h"
20#include "minhton/message/types.h"
51 T getFullMessage()
const;
58 void validate()
const;
66 return static_cast<const T *
>(
this)->header_;
70 return static_cast<const T *
>(
this)->header_.getSender();
74 return static_cast<const T *
>(
this)->header_.getTarget();
78 return *
static_cast<const T *
>(
this);
82bool MinhtonMessage<T>::validateHeader(
const MinhtonMessageHeader &header)
const {
84 (header.getTarget().getPhysicalNodeInfo().isInitialized() ||
85 header.getTarget().getLogicalNodeInfo().isInitialized());
88template <
typename T>
void MinhtonMessage<T>::validate()
const {
89 if (!(validateHeader(
static_cast<const T *
>(
this)->header_))) {
90 throw std::invalid_argument(
"Invalid MINHTON message header");
92 if (!(
static_cast<const T *
>(
this)->validateImpl())) {
93 throw std::invalid_argument(
"Invalid MINHTON message payload");
98 static_cast<T *
>(
this)->header_.setTarget(new_target);
NodeInfo getTarget() const
Definition message.h:73
NodeInfo getSender() const
Definition message.h:69
void setTarget(NodeInfo new_target)
Definition message.h:97
MinhtonMessageHeader getHeader() const
Definition message.h:65
Definition node_info.h:24
minhton::PhysicalNodeInfo getPhysicalNodeInfo() const
Definition node_info.cpp:32
bool isInitialized() const
Definition physical_node_info.cpp:73
Definition minhton_watchdog_ns3.cpp:24