00001 // $Id: IntervalTimer.hh 1781 2011-04-11 12:10:19Z tho $ 00002 // 00003 // Copyright (C) 2007 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #ifndef HH_SENF_PPI_IntervalTimer_ 00027 #define HH_SENF_PPI_IntervalTimer_ 1 00028 00029 // Custom includes 00030 #include <senf/Scheduler/ClockService.hh> 00031 #include <senf/Scheduler/TimerEvent.hh> 00032 #include "Events.hh" 00033 00034 //#include "IntervalTimer.mpp" 00035 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00036 00037 namespace senf { 00038 namespace ppi { 00039 00044 struct IntervalTimerEventInfo 00045 { 00046 ClockService::clock_type expected; 00047 ClockService::clock_type intervalStart; 00048 unsigned number; 00049 }; 00050 00060 class IntervalTimer 00061 : public EventImplementation<IntervalTimerEventInfo> 00062 { 00063 public: 00064 //-//////////////////////////////////////////////////////////////////////// 00066 //\{ 00067 00068 explicit IntervalTimer(ClockService::clock_type interval, 00069 unsigned eventsPerInterval=1); 00070 IntervalTimer(); 00071 00072 //\} 00073 //-//////////////////////////////////////////////////////////////////////// 00074 00075 void interval(ClockService::clock_type interval, unsigned eventsPerInterval=1); 00076 std::pair<ClockService::clock_type, unsigned> interval() const; 00077 00078 protected: 00079 00080 private: 00081 virtual void v_enable(); 00082 virtual void v_disable(); 00083 00084 void schedule(); 00085 void cb(); 00086 00087 ClockService::clock_type interval_; 00088 unsigned eventsPerInterval_; 00089 IntervalTimerEventInfo info_; 00090 scheduler::TimerEvent timer_; 00091 }; 00092 00093 }} 00094 00095 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00096 #include "IntervalTimer.cci" 00097 //#include "IntervalTimer.ct" 00098 //#include "IntervalTimer.cti" 00099 #endif 00100 00101 00102 // Local Variables: 00103 // mode: c++ 00104 // fill-column: 100 00105 // comment-column: 40 00106 // c-file-style: "senf" 00107 // indent-tabs-mode: nil 00108 // ispell-local-dictionary: "american" 00109 // compile-command: "scons -u test" 00110 // End: