libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
periodictask.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright (c) Aldebaran Robotics 2013 All Rights Reserved
4 */
5 #ifndef _QI_PERIODICTASK_HPP_
6 #define _QI_PERIODICTASK_HPP_
7 
8 #include <string>
9 
10 #include <boost/function.hpp>
11 #include <boost/utility.hpp>
12 
13 #include <qi/atomic.hpp>
14 #include <qi/future.hpp>
15 #include <qi/stats.hpp>
16 #include <qi/trackable.hpp>
17 
18 namespace qi
19 {
20  struct PeriodicTaskPrivate;
23  class QI_API PeriodicTask: public boost::noncopyable
24  {
25  public:
26  typedef boost::function<void()> Callback;
27 
28  PeriodicTask();
29 
30  ~PeriodicTask();
31 
33 
37  void setCallback(const Callback& cb);
38 #ifdef DOXYGEN
39  template<typename T, typename ARG0> PeriodicTask& setCallback(const T& callable, ARG0 tracked, ...);
40 #else
41  #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
42  template<typename AF, typename ARG0 comma ATYPEDECL> \
43  inline void setCallback(const AF& fun, const ARG0& arg0 comma ADECL) \
44  { \
45  setCallback(::qi::bind<void()>(fun, arg0 comma AUSE)); \
46  }
48 #undef genCall
49 #endif
50 
59  void setUsPeriod(qi::int64_t usPeriod);
60 
65  void start(bool immediate = true);
66 
71  void trigger();
72 
78  void stop();
79 
83  void asyncStop();
84 
88  void compensateCallbackTime(bool compensate);
89 
91  void setName(const std::string& name);
92 
94  bool isRunning() const;
95 
100  bool isStopping() const;
101  private:
102  boost::shared_ptr<PeriodicTaskPrivate> _p;
103  };
104 
105 }
106 #endif
int64_t int64_t
Cross-platform signed integer of length 64 bits (8 bytes).
Definition: types.hpp:33
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
Definition: trackable.hxx:94
boost::function< void()> Callback
#define QI_GEN(f)
Definition: preproc.hpp:471
#define QI_API
Definition: api.hpp:24