PeriodicTaskBase.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef COIL_PERIODICTASKBASE_H
00021 #define COIL_PERIODICTASKBASE_H
00022 
00023 #include <coil/TimeValue.h>
00024 #include <coil/TimeMeasure.h>
00025 #include <coil/Task.h>
00026 
00027 namespace coil
00028 {
00042   class TaskFuncBase
00043   {
00044   public:
00060     virtual ~TaskFuncBase() {}
00061 
00077     virtual int operator()() = 0;
00078   };
00079   
00093   template <typename T, typename F = int (*)()>
00094   class TaskFunc
00095     : public TaskFuncBase
00096   {
00097   public:
00119     TaskFunc(T* obj, F func)
00120       : m_obj(obj), m_func(func)
00121     {
00122     }
00123 
00139     virtual ~TaskFunc() {}
00140 
00156     virtual int operator()()
00157     {
00158       return (m_obj->*m_func)();
00159     }
00160 
00168     T* m_obj;
00169 
00177     F m_func;
00178   };
00179 
00193   class PeriodicTaskBase
00194     : public coil::Task
00195   {
00196   public:
00212     virtual ~PeriodicTaskBase(){};
00213 
00229     virtual void activate() = 0;
00230 
00246     virtual void finalize() = 0;
00247 
00263     virtual int suspend(void) = 0;
00264 
00280     virtual int resume(void) = 0;
00281 
00297     virtual void signal() = 0;
00298 
00320     virtual bool setTask(TaskFuncBase* func, bool delete_in_dtor = true) = 0;
00321 
00347     template <class O, class F>
00348     bool setTask(O* obj, F fun)
00349     {
00350       return this->setTask(new TaskFunc<O, F>(obj, fun));
00351     }
00352 
00372     virtual void setPeriod(double period) = 0;
00373 
00393     virtual void setPeriod(coil::TimeValue& period) = 0;
00394 
00414     virtual void executionMeasure(bool value) = 0;
00415 
00435     virtual void executionMeasureCount(int n) = 0;
00436 
00456     virtual void periodicMeasure(bool value) = 0;
00457 
00477     virtual void periodicMeasureCount(int n) = 0;
00478 
00494     virtual coil::TimeMeasure::Statistics getExecStat() = 0;
00495 
00511     virtual coil::TimeMeasure::Statistics getPeriodStat() = 0;
00512 
00513   };
00514 }; // namespace coil
00515 
00516 #endif // COIL_PERIODICTASKBASE_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:38