Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2007 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 #include <marsyas/sched/EvEvent.h> 00020 #include <marsyas/sched/TmTimer.h> 00021 #include <marsyas/sched/EvExpr.h> 00022 00023 using std::ostringstream; 00024 using namespace Marsyas; 00025 00026 EvEvent::EvEvent() { } 00027 00028 EvEvent::EvEvent(std::string t, std::string n) 00029 { 00030 name_=n; 00031 type_=t; 00032 } 00033 00034 EvEvent::~EvEvent() { } 00035 00036 std::string 00037 EvEvent::getType() const 00038 { 00039 return type_; 00040 } 00041 00042 std::string 00043 EvEvent::getName() const 00044 { 00045 return name_; 00046 } 00047 00048 std::string 00049 EvEvent::getPrefix() const 00050 { 00051 return type_ + "/" + name_; 00052 } 00053 00054 void 00055 EvEvent::setName(std::string n) 00056 { 00057 name_=n; 00058 } 00059 00060 mrs_natural 00061 EvEvent::getTime() const 00062 { 00063 return time_; 00064 } 00065 00066 void 00067 EvEvent::setTime(mrs_natural t) 00068 { 00069 time_=t; 00070 } 00071 00072 mrs_natural 00073 EvEvent::getRepeatCount() 00074 { 00075 return repeat_.getCount(); 00076 } 00077 00078 std::string 00079 EvEvent::getRepeatInterval() 00080 { 00081 return repeat_.getInterval(); 00082 } 00083 00084 Repeat 00085 EvEvent::getRepeat() 00086 { 00087 return repeat_; 00088 } 00089 00090 void 00091 EvEvent::setRepeat(Repeat r) 00092 { 00093 repeat_=r; 00094 } 00095 00096 bool 00097 EvEvent::repeat() 00098 { 00099 return repeat_.repeat(); 00100 } 00101 00102 std::string 00103 EvEvent::repeat_interval(std::string interval) 00104 { 00105 return interval; 00106 } 00107 00108 00109 /* Note there is a potential problem if time_ is much less than current 00110 scheduler time, then it may do a bunch of quick events (depending on 00111 repetition_time_) until it catches up to current time. */ 00112 void 00113 EvEvent::doRepeat() 00114 { 00115 if (repeat()) { 00116 repeat_--; 00117 if (timer_ != NULL) { 00118 std::string t = getRepeatInterval(); 00119 time_ = getTime() + timer_->intervalsize(t); 00120 // printf("time=%ld interval=%ld\n",time_,timer_->intervalsize(repetition.interval)); 00121 // time_ = time_ + timer_->intervalsize(repetition.interval); 00122 } 00123 else { 00124 // otherwise kill it 00125 repeat_.setInfinite(false); 00126 repeat_.setCount(0); 00127 } 00128 } 00129 } 00130 00131 void 00132 EvEvent::setTimer(TmTimer* t) 00133 { 00134 timer_=t; 00135 } 00136 00137 void 00138 EvEvent::updctrl(std::string cname, TmControlValue value) 00139 { 00140 (void) cname; (void) value; // FIXME These values are unused 00141 MRSWARN("EvEvent::updControl(string,TmControlValue) not supported by this event"); 00142 } 00143 00144 bool 00145 EvEvent::checkupd(std::string c1, std::string c2, TmControlValue v, mrs_natural t) 00146 { 00147 return (c1==c2 && v.getType()==t); 00148 } 00149 /* 00150 ostream& Marsyas::operator<< (ostream& o, EvEvent& e) { 00151 // sys.put(o); 00152 o << "EvEvent<" << e.getCName() << "," << e.getValue() << ">"; 00153 return o; 00154 } 00155 */