Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2005 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef MARSYAS_TM_TIMER_H 00020 #define MARSYAS_TM_TIMER_H 00021 00022 #include <marsyas/common_header.h> 00023 #include <marsyas/sched/TmParam.h> 00024 #include <marsyas/sched/TmControlValue.h> 00025 #include <marsyas/sched/EvEvent.h> 00026 #include <marsyas/Heap.h> 00027 00028 #include <map> 00029 #include <iostream> 00030 #include <string> 00031 #include <vector> 00032 00033 namespace Marsyas 00034 { 00042 class marsyas_EXPORT TmTimer 00043 { 00044 private: 00046 Heap<EvEvent, EvEventDispatchComparator> pq_; 00048 std::map<std::string, EvEvent*> events_; 00049 std::map<std::string, EvEvent*>::iterator events_iter_; 00050 00051 protected: 00053 std::string type_; 00054 00056 std::string name_; 00057 00059 unsigned long cur_time_; 00060 00061 // mrs_natural granularity_; 00062 // mrs_natural next_trigger_; 00063 00064 protected: 00070 void init(); 00071 00072 public: 00073 // Constructors 00076 TmTimer(std::string type, std::string name); 00080 TmTimer(const TmTimer& t); 00081 virtual ~TmTimer(); 00082 00086 std::string getType(); 00090 std::string getName(); 00094 std::string getPrefix(); 00095 00096 // virtual TmTimer* clone()=0; 00097 00101 mrs_natural getTime(); 00102 00108 void tick(); 00112 virtual void updtime(); 00113 00114 // timer methods 00122 virtual mrs_natural readTimeSrc()=0; 00123 // virtual mrs_natural getElapsedTimeSinceLastTick()=0; 00131 virtual void trigger(); 00141 virtual mrs_natural intervalsize(std::string interval)=0; 00142 00147 virtual void updtimer(std::string cname, TmControlValue value); 00148 00152 void updtimer(TmParam& param); 00153 00157 void updtimer(std::vector<TmParam> params); 00158 00164 void post(std::string event_time, Repeat rep, EvEvent* me); 00169 void post(std::string event_time, EvEvent* me); 00175 void post(EvEvent* e); 00176 00180 bool eventPending(); 00181 00190 void dispatch(); 00191 00192 // the usual stream IO 00193 // friend ostream& operator<<(ostream&, Scheduler&); 00194 // friend istream& operator>>(istream&, Scheduler&); 00195 }; 00196 00197 }//namespace Marsyas 00198 00199 #endif