/* * File: MoversightTimer.h * Author: jgaebler * * Created on Febrary 14, 2011, 11:05 AM */ #pragma once #ifndef MOVERSIGHTTIMER_H #define MOVERSIGHTTIMER_H #include "common/Defines.h" #include "common/container/HeterogeneousMap.h" #include "common/time/GenericTime.h" #include "MoversightTimerSettings.h" #if OMNETPP #include #else #include "core/timer/abstract_timer.h" #endif namespace ubeeme { namespace moversight { class MoversightService; #if OMNETPP class MoversightTimer : public cMessage { #else class MoversightTimer : public ubeeme::AbstractTimer { #endif public: MoversightTimer(MoversightService & aService); virtual ~MoversightTimer(); /** * @brief Duplicates a timer instance. * @return The created timer instance copy. */ virtual MoversightTimer * dup() = 0; /** * @brief If the timer is fired, this method is called and the timer * handled. * The actual timer implementation call the handling routine in the * service, associated with that timer. * * @note Each timer have to implement that operation. The actual * service method is called by casting the stored timer in the * expected instance or access the desired module via the dispatcher * without any casts. */ virtual void timeout() = 0; void fire(); /** * @brief Starts the timer. */ virtual void start(); /** * @brief Stops the timer. */ virtual void stop(); /** * @brief Restarts the timer. */ virtual void restart(); virtual bool isRunning(); virtual GenericTime getTimeout(); virtual void setTimeout(GenericTime timeout); virtual size_t getNumberOfRetries() const; virtual void setNumberOfRetries(size_t numberOfRetries); virtual void resetNumberOfRetries(); protected: /** * @brief A reference to the issuing service. */ MoversightService & service; size_t numberOfRetries; size_t numberOfRetriesStartValue; GenericTime timeoutValue; //protect to avoid usage and instantiation bool operator==(const MoversightTimer&); MoversightTimer(const MoversightTimer& other); MoversightTimer& operator=(const MoversightTimer& other); HeterogeneousMap storage; }; } } #endif /* MOVERSIGHTTIMER_H */