libsidplayfp  1.2.2
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 
30 typedef int_fast64_t event_clock_t;
31 
38 typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t;
39 
40 
50 class SID_EXTERN Event
51 {
52  friend class EventScheduler;
53 
54 private:
56  const char * const m_name;
57 
59  event_clock_t triggerTime;
60 
62  Event *next;
63 
64 public:
71  Event(const char * const name) :
72  m_name(name) {}
73 
79  virtual void event() = 0;
80 
81 protected:
82  ~Event() {}
83 };
84 
102 {
103 public:
109  virtual void cancel(Event &event) = 0;
110 
120  virtual void schedule(Event &event, event_clock_t cycles,
121  event_phase_t phase) = 0;
122 
129  virtual void schedule(Event &event, event_clock_t cycles) = 0;
130 
137  virtual bool isPending(Event &event) const = 0;
138 
145  virtual event_clock_t getTime(event_phase_t phase) const = 0;
146 
154  virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase) const = 0;
155 
161  virtual event_phase_t phase() const = 0;
162 
163 protected:
164  ~EventContext() {}
165 };
166 
167 #endif // EVENT_H
Definition: EventScheduler.h:55
virtual bool isPending(Event &event) const =0
Definition: event.h:101
virtual event_phase_t phase() const =0
virtual void schedule(Event &event, event_clock_t cycles, event_phase_t phase)=0
Definition: event.h:50
Event(const char *const name)
Definition: event.h:71
virtual event_clock_t getTime(event_phase_t phase) const =0
virtual void cancel(Event &event)=0