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

164 lines
4.5 KiB
C++

#include "RosterMessage.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
*/
RosterMessage::RosterMessage() : ExteriorMessage("RO", RO){
}
/**
* @brief Copy constructor
* @param other The instance to copy.
*/
RosterMessage::RosterMessage(const RosterMessage& other) : ExteriorMessage(other) {
operator=(other);
}
/**
* @brief Destructor
*/
RosterMessage::~RosterMessage() {
}
/**
* @brief Creates a copy of the current instance.
* @return The copy of the current instance.
*/
RosterMessage *
RosterMessage::dup() const {
return new RosterMessage(*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
RosterMessage::handleReceive(Dispatcher& dis) {
if (dis.getMessageValidator()->isValid( *this)) {
dis.getMembershipService().handleRosterMessage(this);
}
}
/**
* @brief Assignment operator
* @param other The instance to assign
* @return a reference to this instance
*/
RosterMessage&
RosterMessage::operator=(const RosterMessage& other) {
if( this == &other) return *this;
ExteriorMessage::operator=(other);
viewID = other.viewID;
nextPeerID = other.nextPeerID;
joinedPeerID = other.joinedPeerID;
mDescList = other.mDescList;
return *this;
}
/**
* @brief Gets the current viewId
* @return the current viewID
*/
const ViewID &
RosterMessage::getViewID() const {
return viewID;
}
/**
* @brief Sets the current viewId
* @param viewID The current viewId
*/
void
RosterMessage::setViewID(const ViewID& viewID) {
this->viewID = viewID;
}
/**
* @brief Gets the nextPeerID
* @return the next PeerID
*/
const PeerID &
RosterMessage::getNextPeerID() const {
return nextPeerID;
}
/**
* @brief Sets the nextPeerID
* @param nextPeerID The PeerID of the next peer to be set
*/
void
RosterMessage::setNextPeerID( const PeerID& nextPeerID) {
this->nextPeerID = nextPeerID;
}
/**
* @brief Gets the joined peer id
* @return peerID of the newly joined peer
*/
const PeerID &
RosterMessage::getJoinedPeerID() const {
return joinedPeerID;
}
/**
* @brief Sets the peerID of the newly joined peer
* @param joinedPeerID the peerID to be set
*/
void
RosterMessage::setJoinedPeerID( const PeerID& joinedPeerID) {
this->joinedPeerID = joinedPeerID;
}
/**
* @brief Returns the memberDescriptionList
* @return The member description list.
*/
const MemberDescriptionList &
RosterMessage::getMemberDescriptionList() const {
return mDescList;
}
/**
* @brief Sets the member description list.
* @param descList The member description list to set.
*/
void
RosterMessage::setMemberDescriptionList(MemberDescriptionList descList) {
mDescList = descList;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
RosterMessage::set(Archive & archive) {
ExteriorMessage::set(archive);
archive(viewID);
archive(nextPeerID);
archive(joinedPeerID);
if (archive.isReading()) {
std::vector<MemberDescription> tempMemDescList;
archive(tempMemDescList);
MemberDescriptionList t;
t.add(tempMemDescList);
setMemberDescriptionList(t);
} else {
std::vector<MemberDescription> tempMemDescList = getMemberDescriptionList().getInternal();
archive(tempMemDescList);
}
}
}
}