FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
Timer.h
1 /**********************************************************\
2 Original Author: Mital Vora <mital.d.vora@gmail.com>
3 
4 Created: Mar 26, 2011
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 \**********************************************************/
12 
13 #pragma once
14 #ifndef H_FB_TIMER
15 #define H_FB_TIMER
16 
17 #include <string>
18 #include <boost/function.hpp>
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/enable_shared_from_this.hpp>
21 #include <boost/system/error_code.hpp>
22 
23 #include "FBPointers.h"
24 
25 namespace FB {
26 
27  FB_FORWARD_PTR(Timer);
28  class TimerPimpl;
29 
39  class Timer : public boost::enable_shared_from_this<Timer>
40  {
41  typedef boost::function<void (void)> TimerCallbackFunc;
42 
43  private:
44  const long duration;
45  const bool recursive;
46  TimerCallbackFunc cb;
47  boost::scoped_ptr<TimerPimpl> pimpl;
48 
49  Timer(long _duration, bool _recursive, TimerCallbackFunc _callback);
50  void callback(const boost::system::error_code& error);
51 
52  public:
53  ~Timer();
54 
55  void start();
56  bool stop();
57 
58  static TimerPtr getTimer(long _duration, bool _recursive, TimerCallbackFunc _callback);
59  };
60 };
61 
62 #endif
63 
Timer Utility.
Definition: Timer.h:39