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

179 lines
5.7 KiB
C++

#include "RejoinRosterAnnounce.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
#include "fd/NetworkFailureDetector.h"
namespace ubeeme {
namespace moversight {
/**
* @brief DefaultConstructor
*/
RejoinRosterAnnounce::RejoinRosterAnnounce()
: MulticastMessage("ROA", ROA) { }
/**
* @brief Destructor
*/
RejoinRosterAnnounce::~RejoinRosterAnnounce() { }
/**
* @brief Copy constructor
* @param other The instance to copy
*/
RejoinRosterAnnounce::RejoinRosterAnnounce(const RejoinRosterAnnounce& other)
: MulticastMessage(other) {
operator =(other);
}
/**
* @brief Duplicate method. Creates a copy of the current message.
* @return The copy of the current instance.
*/
RejoinRosterAnnounce *
RejoinRosterAnnounce::dup() const {
return new RejoinRosterAnnounce(*this);
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
RejoinRosterAnnounce &
RejoinRosterAnnounce::operator=(const RejoinRosterAnnounce& other) {
if (this == &other) return *this;
MulticastMessage::operator=(other);
this->newViewID = other.newViewID;
this->nextPeerID = other.nextPeerID;
this->mDescList = other.mDescList;
this->disconnectedPeers = other.disconnectedPeers;
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
RejoinRosterAnnounce::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);
}
}
/**
* @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
RejoinRosterAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & missedPeers) {
dis.getMobilitySupport().handleRejoinRosterAnnounce(*this, missedPeers);
}
/**
* @brief Gets the next viewID
* @return next viewID
*/
const ViewID&
RejoinRosterAnnounce::getNewViewID() const {
return newViewID;
}
/**
* @brief Sets the nextViewID
* @param nextViewID The viewID to be set
*/
void
RejoinRosterAnnounce::setNewViewID(const ViewID& newViewID) {
this->newViewID = newViewID;
}
/**
* @brief Gets the next PeerID
* @return the next PeerID
*/
const PeerID&
RejoinRosterAnnounce::getNextPeerID() const {
return nextPeerID;
}
/**
* @brief Sets the next PeerID
* @param nextPeerID the peerId to be set
*/
void
RejoinRosterAnnounce::setNextPeerID( const PeerID& nextPeerID) {
this->nextPeerID = nextPeerID;
}
/**
* @brief Gets the List of member descriptions.
* @return List of member descriptions.
*/
const MemberDescriptionList&
RejoinRosterAnnounce::getMemberDescriptionList() const {
return mDescList;
}
/**
* @brief Sets the lists of member descriptions.
* @param descList - The list of member descriptions to set.
*/
void
RejoinRosterAnnounce::setMemberDescriptionList( const MemberDescriptionList& descList) {
mDescList.clear();
mDescList.add( descList);
}
/**
* @brief Gets the list of disconnected peers in the primary group during partition time.
* @return peerIDlist of those who are definitely gone.
*/
const PeerIDList&
RejoinRosterAnnounce::getDisconnectedPeers() const {
return disconnectedPeers;
}
/**
* @brief Sets the list of disconnected Peers in the primary group during partition time.
* @param disPeers - the peers who left the group during partition
*/
void
RejoinRosterAnnounce::setDisconnectedPeers( const PeerIDList& disPeers) {
disconnectedPeers = disPeers;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
RejoinRosterAnnounce::set(Archive & archive) {
MulticastMessage::set(archive);
archive( (uint32&) getNewViewID());
archive( (uint32&) getNextPeerID());
archive( const_cast<PeerIDList&>( getDisconnectedPeers()));
MemberDescriptionList mDescList;
if( archive.isReading()) {
archive(mDescList.getInternal());
setMemberDescriptionList(mDescList);
} else {
mDescList = getMemberDescriptionList();
archive(mDescList.getInternal());
}
}
}
}