libsidplayfp 1.8.8
event.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2001 Simon White
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef EVENT_H
24#define EVENT_H
25
26#include <stdint.h>
27
28#include "sidplayfp/siddefs.h"
29
30typedef int_fast64_t event_clock_t;
31
38typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t;
39
40
50class SID_EXTERN Event
51{
52 friend class EventScheduler;
53
54private:
58 const char * const m_name;
59
63 event_clock_t triggerTime;
64
68 Event *next;
69
70public:
77 Event(const char * const name) :
78 m_name(name) {}
79
85 virtual void event() = 0;
86
87protected:
88 ~Event() {}
89};
90
108{
109public:
115 virtual void cancel(Event &event) = 0;
116
126 virtual void schedule(Event &event, unsigned int cycles,
127 event_phase_t phase) = 0;
128
135 virtual void schedule(Event &event, unsigned int cycles) = 0;
136
143 virtual bool isPending(Event &event) const = 0;
144
151 virtual event_clock_t getTime(event_phase_t phase) const = 0;
152
160 virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) const = 0;
161
167 virtual event_phase_t phase() const = 0;
168
169protected:
170 ~EventContext() {}
171};
172
173#endif // EVENT_H
Definition: event.h:108
virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) const =0
virtual void schedule(Event &event, unsigned int cycles)=0
virtual event_phase_t phase() const =0
virtual event_clock_t getTime(event_phase_t phase) const =0
virtual void cancel(Event &event)=0
virtual void schedule(Event &event, unsigned int cycles, event_phase_t phase)=0
virtual bool isPending(Event &event) const =0
Definition: EventScheduler.h:56
Definition: event.h:51
virtual void event()=0
Event(const char *const name)
Definition: event.h:77