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

150 lines
4.7 KiB
C++

#include "RejoinAnnounce.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief DefaultConstructor
*/
RejoinAnnounce::RejoinAnnounce()
: MulticastMessage("RA", RA) {
}
/**
* @brief Destructor
*/
RejoinAnnounce::~RejoinAnnounce() {
}
/**
* @brief Copy constructor
* @param other The instance to copy
*/
RejoinAnnounce::RejoinAnnounce(const RejoinAnnounce& other)
: MulticastMessage(other) {
operator =(other);
reReachablePeer = other.reReachablePeer;
reachablePeers = other.reachablePeers;
disjoinedPeers = other.disjoinedPeers;
}
/**
* @brief Duplicate method. Creates a copy of the current message.
* @return The copy of the current instance.
*/
RejoinAnnounce *
RejoinAnnounce::dup() const {
return new RejoinAnnounce(*this);
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
RejoinAnnounce &
RejoinAnnounce::operator=(const RejoinAnnounce& other) {
if (this == &other) return *this;
MulticastMessage::operator=(other);
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
RejoinAnnounce::handleReceive(Dispatcher & dis) {
//validate the message
if( dis.getMessageValidator()->isValid( *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
RejoinAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & missedPeers) {
//deliver the message
// @NOTE why is that not in the dispatcher
if (dis.getLocalStateOperation() != LOCKED) {
dis.getMobilitySupport().handleRejoinAnnounce(*this, missedPeers);
}
}
/**
* @brief Gets the peer who is reachable again.
* @return the peerID of the peer we can reach again.
*/
const PeerID&
RejoinAnnounce::getReReachablePeerID() const {
return reReachablePeer;
}
/**
* @brief Sets the PeerID of the one who is reachable again.
* @param pID - The peer that can reached again.
*/
void
RejoinAnnounce::setReReachablePeer( const PeerID& pID) {
this->reReachablePeer = pID;
}
/**
* @brief Gets the List of reachable peers in this part of the group.
* @return PeerIDList of those reachable at the moment
*/
const PeerIDList&
RejoinAnnounce::getReachablePeers() const {
return reachablePeers;
}
/**
* @brief Sets the list of reachable Peers.
* @param pIDList - The peers reachable in this part of the group.
*/
void
RejoinAnnounce::setReachablePeers( const PeerIDList& pIDList) {
this->reachablePeers = pIDList;
}
/**
* @brief Gets the peers who became disjoined.
* @return PeerIDList of non-reachable peers
*/
const PeerIDList&
RejoinAnnounce::getDisjoinedPeers() const {
return disjoinedPeers;
}
/**
* @brief Sets the list of peers who became disjoined.
* @param pIDList - Those peers who left the group.
*/
void
RejoinAnnounce::setDisjoinedPeers( const PeerIDList& pIDList) {
this->disjoinedPeers = pIDList;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
RejoinAnnounce::set(Archive & archive) {
MulticastMessage::set(archive);
archive(reReachablePeer);
archive(reachablePeers);
archive(disjoinedPeers);
}
}
}