libsidplayfp  1.0.3
event.h
00001 /*
00002  * This file is part of libsidplayfp, a SID player engine.
00003  *
00004  * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
00005  * Copyright 2007-2010 Antti Lankila
00006  * Copyright 2001 Simon White
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021  */
00022 
00023 #ifndef EVENT_H
00024 #define EVENT_H
00025 
00026 #include <stdint.h>
00027 
00028 #include "sidplayfp/siddefs.h"
00029 
00030 typedef int_fast64_t event_clock_t;
00031 
00038 typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t;
00039 
00040 
00050 class SID_EXTERN Event
00051 {
00052     friend class EventScheduler;
00053 
00054 private:
00056     const char * const m_name;
00057 
00059     event_clock_t triggerTime;
00060 
00062     Event *next;
00063 
00064 public:
00071     Event(const char * const name) :
00072         m_name(name) {}
00073 
00079     virtual void event() = 0;
00080 
00081 protected:
00082     ~Event() {}
00083 };
00084 
00101 class EventContext
00102 {
00103 public:
00109     virtual void cancel(Event &event) = 0;
00110 
00120     virtual void schedule(Event &event, event_clock_t cycles,
00121                           event_phase_t phase) = 0;
00122 
00129     virtual void schedule(Event &event, event_clock_t cycles) = 0;
00130 
00137     virtual bool isPending(Event &event) const = 0;
00138 
00145     virtual event_clock_t getTime(event_phase_t phase) const = 0;
00146 
00154     virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) const = 0;
00155 
00161     virtual event_phase_t phase() const = 0;
00162 
00163 protected:
00164     ~EventContext() {}
00165 };
00166 
00167 #endif // EVENT_H