Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/sched/EvExpr.cpp
Go to the documentation of this file.
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 #include <marsyas/sched/EvExpr.h>
00020 #include <marsyas/sched/Scheduler.h>
00021 #include <marsyas/system/MarSystem.h>
00022 
00023 using std::ostringstream;
00024 using namespace Marsyas;
00025 
00026 EvExpr::EvExpr(MarSystem* target, std::string e, std::string nm) : EvEvent("EvExpr",nm)
00027 {
00028   expr_=new Expr(target,Ex(e));
00029 }
00030 
00031 EvExpr::EvExpr(MarSystem* target, Ex e, Rp r, std::string nm) : EvEvent("EvExpr",nm)
00032 {
00033   expr_=new Expr(target,e,r);
00034 }
00035 
00036 EvExpr::EvExpr(MarSystem* target, ExFile ef, std::string nm) : EvEvent("EvExpr",nm)
00037 {
00038   expr_=new Expr(target,ef);
00039 }
00040 
00041 EvExpr::~EvExpr()
00042 {
00043   delete expr_;
00044 }
00045 
00046 void
00047 EvExpr::setTimer(TmTimer* t)
00048 {
00049   EvEvent::setTimer(t);
00050 //  if (getType()=="EvExpr") {
00051 //      EvExpr* e = dynamic_cast<EvExpr*>(event_);
00052 //      if (e!=NULL) {
00053 //          Expr* x=e->getExpression();
00054   if (expr_!=NULL) {
00055     expr_->setTimer(timer_);
00056     expr_->post(); // evaluate init expressions
00057   }
00058 //      }
00059 //  }
00060 }
00061 
00062 void
00063 EvExpr::dispatch()
00064 {
00065   expr_->eval();
00066 }
00067 
00068 EvExpr*
00069 EvExpr::clone()
00070 {
00071   return new EvExpr(*this);
00072 }
00073 
00074 bool
00075 EvExpr::repeat()
00076 {
00077   return expr_->repeat();
00078 }
00079 
00080 std::string
00081 EvExpr::repeat_interval()
00082 {
00083   if (expr_->has_rate()) return expr_->repeat_interval();
00084   return repeat_.getInterval();
00085 }
00086 
00087 void
00088 EvExpr::updctrl(std::string cname, TmControlValue value)
00089 {
00090   (void) cname; (void) value; // FIXME These values are unused
00091   MRSWARN("EvExpr:updControl(string,TmControlValue)  updctrl not supported");
00092 }