PeriodicTaskBase.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef COIL_PERIODICTASKBASE_H
21 #define COIL_PERIODICTASKBASE_H
22 
23 #include <coil/TimeValue.h>
24 #include <coil/TimeMeasure.h>
25 #include <coil/Task.h>
26 
27 namespace coil
28 {
43  {
44  public:
60  virtual ~TaskFuncBase() {}
61 
77  virtual int operator()() = 0;
78  };
79 
93  template <typename T, typename F = int (*)()>
94  class TaskFunc
95  : public TaskFuncBase
96  {
97  public:
119  TaskFunc(T* obj, F func)
120  : m_obj(obj), m_func(func)
121  {
122  }
123 
139  virtual ~TaskFunc() {}
140 
156  virtual int operator()()
157  {
158  return (m_obj->*m_func)();
159  }
160 
168  T* m_obj;
169 
178  };
179 
194  : public coil::Task
195  {
196  public:
212  virtual ~PeriodicTaskBase(){};
213 
229  virtual void activate() = 0;
230 
246  virtual void finalize() = 0;
247 
263  virtual int suspend(void) = 0;
264 
280  virtual int resume(void) = 0;
281 
297  virtual void signal() = 0;
298 
320  virtual bool setTask(TaskFuncBase* func, bool delete_in_dtor = true) = 0;
321 
347  template <class O, class F>
348  bool setTask(O* obj, F fun)
349  {
350  return this->setTask(new TaskFunc<O, F>(obj, fun));
351  }
352 
372  virtual void setPeriod(double period) = 0;
373 
393  virtual void setPeriod(coil::TimeValue& period) = 0;
394 
414  virtual void executionMeasure(bool value) = 0;
415 
435  virtual void executionMeasureCount(int n) = 0;
436 
456  virtual void periodicMeasure(bool value) = 0;
457 
477  virtual void periodicMeasureCount(int n) = 0;
478 
494  virtual coil::TimeMeasure::Statistics getExecStat() = 0;
495 
511  virtual coil::TimeMeasure::Statistics getPeriodStat() = 0;
512 
513  };
514 }; // namespace coil
515 
516 #endif // COIL_PERIODICTASKBASE_H
virtual ~TaskFuncBase()
Destructor.
TaskFuncBase class.
Structure for time statistics.
Definition: TimeMeasure.h:63
TaskFunc template class.
TimeValue class.
Definition: TimeValue.h:40
virtual int operator()()=0
Functor.
virtual ~TaskFunc()
Destructor.
TaskFunc(T *obj, F func)
Constructor.
PeriodicTaskBase class.
bool setTask(O *obj, F fun)
Setting task execution function.
Task class.
virtual int operator()()
Functor.
virtual ~PeriodicTaskBase()
Destructor.
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:54