Files
scandocs/uni/masterarbeit/source/moversight/ms/msg/JoinAnnounce.cc
2014-06-30 13:58:10 +02:00

158 lines
4.8 KiB
C++

#include "JoinAnnounce.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
#include "fd/NetworkFailureDetector.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Default Constructor
*/
JoinAnnounce::JoinAnnounce()
: MulticastMessage("JA", JA) {
}
/**
* @brief Destructor
*/
JoinAnnounce::~JoinAnnounce() {
}
/**
* @brief Copy constructor
* @param other The instance to copy
*/
JoinAnnounce::JoinAnnounce(const JoinAnnounce& other)
: MulticastMessage(other) {
operator =(other);
}
/**
* @brief Duplicate method. Creates a copy of the current message.
* @return The copy of the current instance.
*/
JoinAnnounce *
JoinAnnounce::dup() const {
return new JoinAnnounce(*this);
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
JoinAnnounce &
JoinAnnounce::operator=(const JoinAnnounce& other) {
if (this == &other) return *this;
MulticastMessage::operator=(other);
joinedPeerTA = other.joinedPeerTA;
peerDescription = other.peerDescription;
peerResources = other.peerResources;
return *this;
}
/**
* @brief Handles this message. To handle a message, it has first successfully validated.
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
*/
void
JoinAnnounce::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
}
/**
* @brief Handles the message delivering. To deliver a message, the message to each module which is interested in this message.
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
* @param missedPeers A list of peers, which have missed this message, as they are pending.
*/
void
JoinAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & /* missedPeers */) {
//store the message for re-synchronization
dis.getMobilitySupport().storeMessage(*this);
//process the message
dis.getMembershipService().handleJoinAnnounce(*this);
}
/**
* @brief Gets the transport address of the joined Peer
* @return Transport address of the joined peer
*/
const TransportAddress &
JoinAnnounce::getJoinedPeerTA() const {
return joinedPeerTA;
}
/**
* @brief Sets the transport address of the joined peer
* @param joinedPeerTA the transport address of the joined peer to set
*/
void
JoinAnnounce::setJoinedPeerTA(const TransportAddress & joinedPeerTA) {
this->joinedPeerTA = joinedPeerTA;
}
/**
* @brief Gets the peerDescription
* @return peer description of the joined peer
*/
const PeerDescription &
JoinAnnounce::getPeerDescription() const {
return peerDescription;
}
/**
* @brief Sets the peer description of the joined peer
* @param peerDescription The peer description to set
*/
void
JoinAnnounce::setPeerDescription(const PeerDescription& peerDescription) {
this->peerDescription = peerDescription;
}
/**
* @brief Permits access to the resource value of the peer.
* @return The resource value of the peer.
*/
const PeerResources &
JoinAnnounce::getPeerResources() const {
return peerResources;
}
/**
* @brief Sets the resources of the peer.
* @param resources A generic representation of the peer resources.
*/
void
JoinAnnounce::setPeerResources(const PeerResources & resources) {
peerResources = resources;
}
/**
* @brief Archive method.
* @param archive The archive to which the attributes are to add
*/
void
JoinAnnounce::set(Archive & archive) {
MulticastMessage::set(archive);
archive(joinedPeerTA);
archive(peerDescription);
archive(peerResources);
}
}
}