libsidplayfp  2.0.2
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 
31 namespace libsidplayfp
32 {
33 
34 template< class This >
35 class EventCallback final : public Event
36 {
37 private:
38  typedef void (This::*Callback) ();
39 
40 private:
41  This &m_this;
42  Callback const m_callback;
43 
44 private:
45  void event() override { (m_this.*m_callback)(); }
46 
47 public:
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
libsidplayfp::Event::Event
Event(const char *const name)
Definition: Event.h:59
libsidplayfp::Event
Definition: Event.h:39
libsidplayfp::EventCallback
Definition: EventCallback.h:36