From 5c83dee70a1e089b23a5c901455f61e99e30f0dd Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 10 Jul 2011 00:10:48 +0200 Subject: FbTk::Timer accepts Slots instead of Commands as the former are more general --- src/FbTk/Timer.cc | 8 ++++---- src/FbTk/Timer.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index cb9ac59..13bfc05 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc @@ -59,7 +59,7 @@ Timer::Timer():m_timing(false), m_once(false), m_interval(0) { } -Timer::Timer(RefCount > &handler): +Timer::Timer(const RefCount > &handler): m_handler(handler), m_timing(false), m_once(false), @@ -90,7 +90,7 @@ void Timer::setTimeout(unsigned int secs, unsigned int usecs) { m_timeout.tv_usec = usecs; } -void Timer::setCommand(RefCount > &cmd) { +void Timer::setCommand(const RefCount > &cmd) { m_handler = cmd; } @@ -122,7 +122,7 @@ void Timer::makeEndTime(timeval &tm) const { void Timer::fireTimeout() { if (m_handler) - m_handler->execute(); + (*m_handler)(); } void Timer::updateTimers(int fd) { @@ -284,7 +284,7 @@ Command *DelayedCmd::parse(const std::string &command, REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void); -DelayedCmd::DelayedCmd(RefCount > &cmd, unsigned int timeout) { +DelayedCmd::DelayedCmd(const RefCount > &cmd, unsigned int timeout) { timeval to; // defaults to 200ms to.tv_sec = timeout/1000000; to.tv_usec = timeout % 1000000; diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh index e61d77f..4b5a10e 100644 --- a/src/FbTk/Timer.hh +++ b/src/FbTk/Timer.hh @@ -56,7 +56,7 @@ namespace FbTk { class Timer { public: Timer(); - explicit Timer(RefCount > &handler); + explicit Timer(const RefCount > &handler); virtual ~Timer(); void fireOnce(bool once) { m_once = once; } @@ -65,7 +65,7 @@ public: /// set timeout void setTimeout(const timeval &val); void setTimeout(unsigned int secs, unsigned int usecs); - void setCommand(RefCount > &cmd); + void setCommand(const RefCount > &cmd); void setInterval(int val) { m_interval = val; } /// start timing void start(); @@ -96,7 +96,7 @@ private: typedef std::list TimerList; static TimerList m_timerlist; ///< list of all timers, sorted by next trigger time (start + timeout) - RefCount > m_handler; ///< what to do on a timeout + RefCount > m_handler; ///< what to do on a timeout bool m_timing; ///< clock running? bool m_once; ///< do timeout only once? @@ -110,7 +110,7 @@ private: /// executes a command after a specified timeout class DelayedCmd: public Command { public: - DelayedCmd(RefCount > &cmd, unsigned int timeout = 200000); + DelayedCmd(const RefCount > &cmd, unsigned int timeout = 200000); void execute(); static Command *parse(const std::string &command, const std::string &args, bool trusted); -- cgit v0.11.2