libsidplayfp 2.6.0
EventCallback.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright (C) 2011-2015 Leandro Nini
5 * Copyright (C) 2009 Antti S. Lankila
6 * Copyright (C) 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 EVENTCALLBACK_H
24#define EVENTCALLBACK_H
25
26#include "Event.h"
27
28#include "sidcxx11.h"
29
30
31namespace libsidplayfp
32{
33
34template< class This >
35class EventCallback final : public Event
36{
37private:
38 typedef void (This::*Callback) ();
39
40private:
41 This &m_this;
42 Callback const m_callback;
43
44private:
45 void event() override { (m_this.*m_callback)(); }
46
47public:
48 EventCallback(const char* const name, This &object, Callback callback) :
49 Event(name),
50 m_this(object),
51 m_callback(callback)
52 {}
53};
54
55}
56
57#endif // EVENTCALLBACK_H
Definition EventCallback.h:36
Definition Event.h:39
const char * name() const
Definition Event.h:72