162 lines
4.5 KiB
C++
162 lines
4.5 KiB
C++
|
|
#include "RejoinRoster.h"
|
|
|
|
#include "Dispatcher.h"
|
|
#include "common/validator/MessageValidator.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Default Constructor
|
|
*/
|
|
RejoinRoster::RejoinRoster() : ExteriorMessage("RJRO", RJRO) {
|
|
}
|
|
|
|
/**
|
|
* @brief Copy constructor
|
|
* @param other The instance to copy
|
|
*/
|
|
RejoinRoster::RejoinRoster(const RejoinRoster &other) : ExteriorMessage(other) {
|
|
operator=(other);
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
RejoinRoster::~RejoinRoster() {
|
|
}
|
|
|
|
/**
|
|
* @brief Duplicate method. Creates a copy of the current message.
|
|
* @return The copy of the current instance.
|
|
*/
|
|
RejoinRoster *
|
|
RejoinRoster::dup() const {
|
|
return new RejoinRoster(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator
|
|
* @param other The instance to assign.
|
|
* @return A reference to the local instance.
|
|
*/
|
|
RejoinRoster &
|
|
RejoinRoster::operator=(const RejoinRoster& other) {
|
|
if (this == &other) return *this;
|
|
ExteriorMessage::operator=(other);
|
|
|
|
viewID = other.viewID;
|
|
nextPeerID = other.nextPeerID;
|
|
mDescList = other.mDescList;
|
|
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
|
|
RejoinRoster::handleReceive(Dispatcher & dis) {
|
|
dis.getMobilitySupport().handleRejoinRoster(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Gets the next viewID
|
|
* @return next viewID
|
|
*/
|
|
const ViewID&
|
|
RejoinRoster::getViewID() const {
|
|
return viewID;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the nextViewID
|
|
* @param nextViewID The viewID to be set
|
|
*/
|
|
void
|
|
RejoinRoster::setViewID(const ViewID& nextViewID) {
|
|
this->viewID = nextViewID;
|
|
}
|
|
|
|
/**
|
|
* @brief Gets the next PeerID
|
|
* @return the next PeerID
|
|
*/
|
|
const PeerID&
|
|
RejoinRoster::getNextPeerID() const {
|
|
return nextPeerID;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the next PeerID
|
|
* @param nextPeerID the peerId to be set
|
|
*/
|
|
void
|
|
RejoinRoster::setNextPeerID(const PeerID& nextPeerID) {
|
|
this->nextPeerID = nextPeerID;
|
|
}
|
|
|
|
/**
|
|
* Gets the List of memberdescriptions.
|
|
* @return List of memberdescriptions.
|
|
*/
|
|
const MemberDescriptionList &
|
|
RejoinRoster::getMemberDescriptionList() const {
|
|
return mDescList;
|
|
}
|
|
|
|
/**
|
|
* Sets the lists of memberdescriptions.
|
|
* @param descList - The list of memberdescriptions to set.
|
|
*/
|
|
void
|
|
RejoinRoster::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&
|
|
RejoinRoster::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
|
|
RejoinRoster::setDisconnectedPeers( const PeerIDList& disPeers) {
|
|
disconnectedPeers = disPeers;
|
|
}
|
|
|
|
/**
|
|
* @brief Archive method
|
|
* @param archive The archive to which the attributes are to add
|
|
*/
|
|
void
|
|
RejoinRoster::set( Archive& archive) {
|
|
ExteriorMessage::set(archive);
|
|
|
|
archive(viewID);
|
|
archive(nextPeerID);
|
|
archive(disconnectedPeers);
|
|
|
|
MemberDescriptionList mDescList;
|
|
if(archive.isReading()) {
|
|
archive(mDescList.getInternal());
|
|
setMemberDescriptionList(mDescList);
|
|
} else {
|
|
std::vector<MemberDescription> v = mDescList.getInternal();
|
|
archive(v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|