aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Timer.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Timer.hh')
-rw-r--r--src/FbTk/Timer.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh
index 4b5a10e..376eac0 100644
--- a/src/FbTk/Timer.hh
+++ b/src/FbTk/Timer.hh
@@ -66,6 +66,9 @@ public:
66 void setTimeout(const timeval &val); 66 void setTimeout(const timeval &val);
67 void setTimeout(unsigned int secs, unsigned int usecs); 67 void setTimeout(unsigned int secs, unsigned int usecs);
68 void setCommand(const RefCount<Slot<void> > &cmd); 68 void setCommand(const RefCount<Slot<void> > &cmd);
69 template<typename Functor>
70 void setFunctor(const Functor &functor)
71 { setCommand(RefCount<Slot<void> >(new SlotImpl<Functor, void>(functor))); }
69 void setInterval(int val) { m_interval = val; } 72 void setInterval(int val) { m_interval = val; }
70 /// start timing 73 /// start timing
71 void start(); 74 void start();
@@ -111,10 +114,21 @@ private:
111class DelayedCmd: public Command<void> { 114class DelayedCmd: public Command<void> {
112public: 115public:
113 DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout = 200000); 116 DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout = 200000);
117
118 // this constructor has inverted order of parameters to avoid ambiguity with the previous
119 // constructor
120 template<typename Functor>
121 DelayedCmd(unsigned int timeout, const Functor &functor) {
122 initTimer(timeout);
123 m_timer.setFunctor(functor);
124 }
125
114 void execute(); 126 void execute();
115 static Command<void> *parse(const std::string &command, 127 static Command<void> *parse(const std::string &command,
116 const std::string &args, bool trusted); 128 const std::string &args, bool trusted);
117private: 129private:
130 void initTimer(unsigned int timeout);
131
118 Timer m_timer; 132 Timer m_timer;
119}; 133};
120 134