event.h
/*
* This file is part of libsidplayfp, a SID player engine.
*
* Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
* Copyright 2007-2010 Antti Lankila
* Copyright 2001 Simon White
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef EVENT_H
#define EVENT_H
#include <stdint.h>
#include "sidplayfp/siddefs.h"
typedef int_fast64_t event_clock_t;
typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t;
class SID_EXTERN Event
{
friend class EventScheduler;
private:
const char * const m_name;
event_clock_t triggerTime;
Event *next;
public:
Event(const char * const name) :
m_name(name) {}
virtual void event() = 0;
protected:
~Event() {}
};
class EventContext
{
public:
virtual void cancel(Event &event) = 0;
virtual void schedule(Event &event, unsigned int cycles,
event_phase_t phase) = 0;
virtual void schedule(Event &event, unsigned int cycles) = 0;
virtual bool isPending(Event &event) const = 0;
virtual event_clock_t getTime(event_phase_t phase) const = 0;
virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) const = 0;
virtual event_phase_t phase() const = 0;
protected:
~EventContext() {}
};
#endif // EVENT_H
EventScheduler
Definition: EventScheduler.h:55
EventContext
Definition: event.h:107
Event
Definition: event.h:50
Event::Event
Event(const char *const name)
Definition: event.h:77