Marsyas  0.5.0-beta1
/Users/jleben/code/marsyas/src/marsyas/sched/EvEvent.h
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 
00020 #ifndef MARSYAS_EV_EVENT_H
00021 #define MARSYAS_EV_EVENT_H
00022 
00023 #include <marsyas/sched/Repeat.h>
00024 #include <marsyas/sched/TmControlValue.h>
00025 
00026 #include <iostream>
00027 
00028 namespace Marsyas
00029 {
00036 class TmTimer;
00037 
00038 class marsyas_EXPORT EvEvent {
00039 protected:
00041   std::string type_;
00045   std::string name_;
00046 
00048   mrs_natural time_;
00050   Repeat repeat_;
00052   TmTimer* timer_;
00053 
00054 public:
00055   EvEvent();
00056   EvEvent(std::string t, std::string n);
00057 
00058   virtual ~EvEvent();
00059 
00063   std::string getType() const;
00067   std::string getName() const;
00071   std::string getPrefix() const;
00075   void setName(std::string n);
00076 
00081   virtual void dispatch()=0;
00082 
00087   virtual EvEvent* clone()=0;
00088 
00094   virtual void setTimer(TmTimer* t);
00098   mrs_natural getTime() const;
00102   void setTime(mrs_natural t);
00103 
00104 
00108   virtual bool repeat();
00112   virtual void setRepeat(Repeat r);
00116   virtual mrs_natural getRepeatCount();
00124   virtual std::string getRepeatInterval();
00128   Repeat getRepeat();
00129 
00137   virtual std::string repeat_interval(std::string interval);
00138 
00144   void doRepeat();
00145 
00146 
00154   virtual void updctrl(std::string cname, TmControlValue value);
00174   bool checkupd(std::string c1, std::string c2, TmControlValue v, mrs_natural t);
00175 
00176   friend class EvEventDispatchComparator;
00177 
00178   // the usual stream IO
00179   friend std::ostream& operator<<(std::ostream&, EvEvent&);
00180   friend std::istream& operator>>(std::istream&, EvEvent&);
00181 };
00182 
00189 class EvEventDispatchComparator {
00190 public:
00191   bool operator()(EvEvent* a, EvEvent* b) {
00192     return (a->getTime()) < (b->getTime());
00193   }
00194 };
00195 
00196 }//namespace Marsyas
00197 
00198 #endif