#include "GTMessage.h" #include "Dispatcher.h" #include "common/validator/MessageValidator.h" #include "fd/NetworkFailureDetector.h" namespace ubeeme { namespace moversight { /** * @brief Constructor. * @param msg The related multicast message that becomes deliverable * with that message. The meta data fields are populated from that * message. * @param sourceID PeerID of the source peer. */ GTMessage::GTMessage(const MulticastMessage & msg, const PeerID & sourceID) : MoversightMessage("GT", GT) { setMessageReference(msg.getMessageReference()); setViewID(msg.getViewID()); setSourceID(sourceID); setLastHop(sourceID); setSequ(msg.getSequ()); setLT(msg.getLT()); } /** * @brief Default Constructor. */ GTMessage::GTMessage() : MoversightMessage("GT", GT) { } /** * @brief Copy Constructor. * @param orig The instance to copy. */ GTMessage::GTMessage(const GTMessage & orig) : MoversightMessage(orig) { operator=(orig); } /** * @brief destructor */ GTMessage::~GTMessage() { } /** * @brief Duplicates the Message. * @return Duplicated message. */ GTMessage* GTMessage::dup() const { return new GTMessage(*this); } /** * @brief Assignment operator. * @param other The instance to assign. * @return A reference to the this instance. */ GTMessage& GTMessage::operator=(const GTMessage& other) { if (this != &other) { MoversightMessage::operator=(other); } return *this; } /** * @brief Handles this message. To handle a message, it has first to be successfully validated. * @param dis A reference to the dispatcher, used to forward this message to the handling modules. */ void GTMessage::handleReceive(Dispatcher& dis) { //validate the message if (dis.getMessageValidator()->isValid(*this)) { //notify the NFD about ongoing traffic dis.getNetworkFailureDetector().handleMessage(this); //handle the message dis.getMessageTransfer().handleMessage(this); }//End if } } }