#ifndef EVENT_H #define EVENT_H #include template class Event { public: virtual void fire(const time_t &cur_time) {}; /* callback */ }; template class Timeout { private: time_t fire_time; Event *handler; public: Timeout(time_t when, Event *what) : fire_time(when), handler(what) {} const time_t& time() const { return fire_time; } Event& event() const { return *handler; } bool operator<(const Timeout &that) const { return this->time() < that.time(); } bool operator>(const Timeout &that) const { return this->time() > that.time(); } }; #endif