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_SCHEDULER_H 00020 #define MARSYAS_SCHEDULER_H 00021 00022 #include <marsyas/sched/TmTimer.h> 00023 #include <marsyas/sched/TmTime.h> 00024 #include <marsyas/sched/TmControlValue.h> 00025 #include <marsyas/sched/TmParam.h> 00026 00027 #include <string> 00028 #include <vector> 00029 00030 namespace Marsyas 00031 { 00040 class Scheduler { 00041 protected: 00042 00043 TmTimer** timers_; 00044 int timers_count_; 00045 // map<std::string,vector<VScheduler> > schedulers; 00046 00047 public: 00048 // map<std::string,vector<std::string> > synonyms_; 00049 00050 // Constructors 00051 Scheduler(); 00052 virtual ~Scheduler(); 00053 00054 // Naming methods 00055 void setName(std::string name); 00056 std::string getType(); 00057 std::string getName(); 00058 std::string getPrefix(); 00059 00060 void tick(); 00061 bool eventPending(); 00062 00063 void addTimer(TmTimer* t); 00064 void addTimer(std::string class_name, std::string identifier); 00065 void addTimer(std::string class_name, std::string identifier, std::vector<TmParam> params); 00066 00067 void updtimer(std::string tmr_id, TmControlValue value); 00068 void updtimer(std::string tmr_id, TmParam& param); 00069 void updtimer(std::string tmr_id, std::vector<TmParam> params); 00070 00071 static void split_cname(std::string cname, std::string* head, std::string* tail); 00072 bool removeTimer(std::string name); 00073 void removeAll(); 00074 private: 00075 void appendTimer(TmTimer* s); 00076 TmTimer* findTimer(std::string name); 00077 public: 00078 // post to default timer 00079 void post(std::string event_time, Repeat rep, EvEvent* me); 00080 void post(std::string event_time, EvEvent* me); 00081 00082 // post to user defined timer 00083 void post(TmTime t, Repeat r, EvEvent* me); 00084 void post(std::string time, std::string timer_name, Repeat r, EvEvent* me); 00085 00086 mrs_natural getTime(std::string timer); 00087 00088 // the usual stream IO 00089 // friend ostream& operator<<(ostream&, Scheduler&); 00090 // friend istream& operator>>(istream&, Scheduler&); 00091 }; 00092 00093 }//namespace Marsyas 00094 00095 #endif