/* * File: ReferenceTimer.h * Author: jgaebler * * Created on February 15, 2013, 4:26 PM */ #pragma once #ifndef TIMEREFERENCETIMER_H #define TIMEREFERENCETIMER_H #include "common/timer/MoversightTimer.h" #include "common/MoversightService.h" #include "common/Reference.h" #include namespace ubeeme { namespace moversight { /** * @class ReferenceTimer * @brief Defines a timer that is identifiable by an reference. * * To distinguish a timer from other running timers, a reference * value is stored to identify the timer. * * @ingroup Moversight * @author Jan Gäbler */ template class ReferenceTimer : public MoversightTimer { public: // static_assert(std::is_base_of::value, // "T must be a descendant of Reference" // ); ReferenceTimer(MoversightService & aService); ReferenceTimer(const ReferenceTimer& orig); virtual ~ReferenceTimer(); virtual void timeout() = 0; ReferenceTimer& operator=(const ReferenceTimer & other); virtual void setReference(const T & ref); T getReference(); }; /** * @brief Constructor * @param service The service that owns that timer. */ template ReferenceTimer::ReferenceTimer(MoversightService & service) : MoversightTimer(service) { } /** * @brief Copy Constructor * @param orig The instance to copy */ template ReferenceTimer::ReferenceTimer(const ReferenceTimer & orig) : MoversightTimer(orig) { operator=(orig); } /** * @brief Destructor */ template ReferenceTimer::~ReferenceTimer() { } /** * @brief Sets the reference of the timer. * @param ref The reference to set. */ template void ReferenceTimer::setReference(const T & ref) { storage.set("reference", ref); } /** * @brief Gets the reference of the timer. * @return The reference of the timer. */ template T ReferenceTimer::getReference() { return storage.get("reference"); } /** * @brief Assignment operator * @param other The instance to copy * @return A reference to the local instance. */ template ReferenceTimer& ReferenceTimer::operator=(const ReferenceTimer & other) { if (this != &other) { MoversightTimer::operator =(other); }//End if return *this; } } } #endif /* REFERENCETIMETIMER_H */