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

113 lines
3.6 KiB
C++

/*
* File: ReducedRoster.cc
* Author: gschneid
*
* Created on September 11, 2012, 5:25 PM
*/
#include "ReducedRoster.h"
#include "common/Exception.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor.
*/
ReducedRoster::ReducedRoster(): ExteriorMessage("RRO", RRO) {
}
/**
* @brief Copy constructor.
* @param orig The original ReducedRoster instance to copy.
*/
ReducedRoster::ReducedRoster( const ReducedRoster& other)
: ExteriorMessage(other) {
operator=(other);
}
/**
* @brief Destructor.
*/
ReducedRoster::~ReducedRoster() {
}
/**
* @brief Duplication method
* @return a copy of the instance
*/
ReducedRoster *
ReducedRoster::dup() const{
return new ReducedRoster(*this);
}
ReducedRoster&
ReducedRoster::operator=( const ReducedRoster& other) {
ExteriorMessage::operator=(other);
reachablePeersQueue = other.reachablePeersQueue;
disjoinedPeerIdList = other.disjoinedPeerIdList;
return *this;
}
/**
* @brief Sets the list of peers that left during partition time.
* @param disjoinedPeerIDList - the peers who are not longer in the secondary group.
*/
void
ReducedRoster::setDisjoinedPeerIdList( const PeerIDList& disjoinedPeerIDList) {
disjoinedPeerIdList = disjoinedPeerIDList;
}
/**
* @brief Gets the list of peers that left during partition time.
* @return disjoinedPeerIDList - the peers who are not longer in the secondary group.
*/
const PeerIDList&
ReducedRoster::getDisjoinedPeerIdList() const {
return disjoinedPeerIdList;
}
/**
* @brief Sets the maps of peers who are active in this part of the group and their (maybe changed) transportaddress.
* @param reachablePeersInGroup - map, that maps the peerIDs and the TAs of the active peers in this part of the group.
*/
void
ReducedRoster::setReachablePeersQueue( const PeerIDToTaMap& reachablePeersInGroup) {
reachablePeersQueue = reachablePeersInGroup;
}
/**
* @brief Gets the maps of peers who are active in this part of the group and their (maybe changed) transportaddress.
* @return map, that maps the peerIDs and the TAs of the active peers in this part of the group.
*/
const PeerIDToTaMap&
ReducedRoster::getReachablePeersQueue() const {
return reachablePeersQueue;
}
/**
* @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
ReducedRoster::handleReceive(Dispatcher& dis) {
if( dis.getMessageValidator()->isValid( *this)) {
dis.getMobilitySupport().handleReducedRoster(this);
}
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
ReducedRoster::set(Archive & archive) {
ExteriorMessage::set(archive);
archive(disjoinedPeerIdList);
archive(reachablePeersQueue);
}
}
}