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

105 lines
2.6 KiB
C++

/*
* File: AwaitRejoinTimer.cc
* Author: gschneid
* Author: jgaebler
*
* Created on October 2, 2012, 8:53 AM
*/
#include "AwaitRejoinTimer.h"
#include "Moversight.h"
#include "Dispatcher.h"
#include "mob/MobilitySupport.h"
namespace ubeeme {
namespace moversight {
#undef DEBUG
#define DEBUG(msg) if ( nd.module.isPrintDebugNFD()) MOV_DEBUG << "ART@" << mob.dispatcher.getLocalID() << " "<<msg<<endl;
/**
* @brief Creates a Hello Timer (type = ARC_TIMER, name= AwaitRejoinTimer, timeout= arcTimeout)
*/
AwaitRejoinTimer::AwaitRejoinTimer(MobilitySupport & aMob) : ReferenceTimer<PeerID>(aMob) {
#if OMNETPP
setName("AR_TIMER");
#endif
setNumberOfRetries(PD_NUMBER_OF_MAX_RETRIES);
setTimeout(AR_TIMEOUT);
}
/**
* @brief Copy constructor.
* @param other The instance to copy.
*/
AwaitRejoinTimer::AwaitRejoinTimer(const AwaitRejoinTimer& other) : ReferenceTimer<PeerID>(other.service) {
#if OMNETPP
setName(other.getName());
#endif
operator=(other);
}
/**
* @brief Destructor
*/
AwaitRejoinTimer::~AwaitRejoinTimer() {
}
/**
* @brief Assignment operator
* @param other The instance to copy
* @return A reference to the local instance.
*/
AwaitRejoinTimer &
AwaitRejoinTimer::operator=(const AwaitRejoinTimer & other) {
if (this != &other) {
ReferenceTimer<PeerID>::operator =(other);
}//End if
return *this;
}
/**
* @brief If the timer is fired, this method is called and the timer
* handled.
*/
void
AwaitRejoinTimer::timeout() {
dynamic_cast<MobilitySupport&> (service).handleAwaitRejoinTimer(this);
}
/**
* @brief A duplicate method. Duplicates the current timer.
* @return A reference to the new created timer.
*/
AwaitRejoinTimer*
AwaitRejoinTimer::dup() {
return new AwaitRejoinTimer(*this);
}
/**
* @brief Sets if this peer has started the rejoin.
* @param pStarter - true if yes, false otherwise
*/
void
AwaitRejoinTimer::setStartedRejoin(bool pStarter) {
storage.set<bool>("starter", pStarter);
}
/**
* @brief Has this peer started the rejoin.
* @return true if yes, false otherwise
*/
bool
AwaitRejoinTimer::startedRejoin() {
return storage.get<bool>("starter");
}
};
};