91 lines
2.3 KiB
C++
91 lines
2.3 KiB
C++
/*
|
|
* File: NDTimer.cc
|
|
* Author: gschneid
|
|
* Author: jgaebler
|
|
*
|
|
* Created on October 2, 2012, 8:53 AM
|
|
*/
|
|
|
|
#include "fd/partition/timer/NDTimer.h"
|
|
|
|
#include "Moversight.h"
|
|
#include "Dispatcher.h"
|
|
#include "fd/partition/NeighborhoodDetector.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
#undef DEBUG
|
|
#define DEBUG(msg) if ( nd.module.isPrintDebugNFD()) MOV_DEBUG << "NDT@" << nd.dispatcher.getLocalID() << " "<<msg<<endl;
|
|
|
|
/**
|
|
* @brief Creates a Hello Timer (type = ND_TIMER, name= NDTimer, timeout= nd_timeout)
|
|
* @param aNd the PartitionDetector, which owns this timer instance
|
|
*/
|
|
NDTimer::NDTimer(NeighborhoodDetector & aNd) : MoversightTimer(aNd), nd(aNd) {
|
|
#if OMNETPP
|
|
setName("NDTimer");
|
|
#endif
|
|
GenericTime t(ND_TIMEOUT);
|
|
setTimeout(t);
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief Copy constructor.
|
|
* @param other The instance to copy.
|
|
*/
|
|
NDTimer::NDTimer(const NDTimer& other):MoversightTimer(other.nd), nd(other.nd) {
|
|
#if OMNETPP
|
|
setName(other.getName());
|
|
#endif
|
|
//setTimeout(other.getTimeout());
|
|
receiverIDs = other.receiverIDs;
|
|
MoversightTimer::operator =(other);
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
NDTimer::~NDTimer() {
|
|
}
|
|
|
|
/**
|
|
* @brief If the timer is fired, this method is called and the timer
|
|
* handled.
|
|
*/
|
|
void
|
|
NDTimer::timeout(){
|
|
dynamic_cast<NeighborhoodDetector&>(service).handleNDTimer(this);
|
|
}
|
|
|
|
/**
|
|
* @brief A duplicate method. Duplicates the current timer.
|
|
* @return A reference to the new created timer.
|
|
*/
|
|
NDTimer*
|
|
NDTimer::dup() {
|
|
return new NDTimer(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Gets the list of peer who shall receive this message.
|
|
* @return PeerIDlist of the receivers.
|
|
*/
|
|
PeerIDList
|
|
NDTimer::getReceiverIDs() {
|
|
return receiverIDs;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the peerIDs of those who shall receive the message.
|
|
* @param newIDs - The peerIDList of the receivers.
|
|
*/
|
|
void
|
|
NDTimer::setReceiverIDs(PeerIDList newIDs) {
|
|
receiverIDs = newIDs;
|
|
}
|
|
|
|
};
|
|
};
|