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

149 lines
4.9 KiB
C++

#include "ReconnectAnnounce.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
#include "fd/NetworkFailureDetector.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Default Constructor.
*/
ReconnectAnnounce::ReconnectAnnounce()
: MulticastMessage( "RCA", RCA) {
}
/**
* @brief Destructor.
*/
ReconnectAnnounce::~ReconnectAnnounce() {
}
/**
* @brief Copy Constructor.
* @param other The instance to copy.
*/
ReconnectAnnounce::ReconnectAnnounce( const ReconnectAnnounce& other)
: MulticastMessage( other) {
operator=( other);
}
/**
* @brief Duplicate method. Creates a copy of the current message.
* @return The copy of the current instance.
*/
ReconnectAnnounce *
ReconnectAnnounce::dup() const {
return new ReconnectAnnounce(*this);
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
ReconnectAnnounce &
ReconnectAnnounce::operator=(const ReconnectAnnounce& other) {
if( this == &other) return *this;
MulticastMessage::operator=(other);
reconnectedPeers = other.reconnectedPeers;
disconnectedPeers = other.disconnectedPeers;
reachableSecondary = other.reachableSecondary;
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
ReconnectAnnounce::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
ReconnectAnnounce::handleDeliver( Dispatcher& dis, const PeerIDList& missedPeers) {
dis.getMobilitySupport().handleReconnectAnnounce(*this, missedPeers);
}
/**
* @brief Gets the Ids of the reconnected peers
* @return PeerIDList of the reconnected Peers
*/
const PeerIDToTaMap&
ReconnectAnnounce::getReconnectedPeers() const {
return reconnectedPeers;
}
/**
* @brief Sets the PeerID of the reconnected peer
* @param reconnectedPeerIDs The PeerID of the reconnected Peer to set
*/
void
ReconnectAnnounce::setReconnectedPeers( const PeerIDToTaMap& reconnectedPeerIDs) {
reconnectedPeers = reconnectedPeerIDs;
}
/**
* @brief Gets the list of peers who are no longer members of this group.
* @return the peerIDList of those peers.
*/
const PeerIDList&
ReconnectAnnounce::getDisconnectedPeers() const {
return disconnectedPeers;
}
/**
* @brief Gets the list of peers who are no longer members of this group.
* @param pIDList - The peerIDList of those peers.
*/
void
ReconnectAnnounce::setDisconnectedPeers( const PeerIDList& pIDList) {
disconnectedPeers = pIDList;
}
/**
* @brief Sets the peerID of the one reachable in the other partition.
* @param reachable PeerID of the reachable peer in the other partition.
*/
void
ReconnectAnnounce::setReachablePeerID( const PeerID& reachable) {
reachableSecondary = reachable;
}
/**
* @brief Gets the peerID of the one reachable in the other partition.
* @return PeerID of the reachable peer in the other partition.
*/
const PeerID&
ReconnectAnnounce::getReachablePeerID() const {
return reachableSecondary;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
ReconnectAnnounce::set(Archive & archive) {
MulticastMessage::set(archive);
archive(disconnectedPeers);
archive(reconnectedPeers);
archive(reachableSecondary);
}
}
}