Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_model
ModelTools
GenericListener.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
ivorium_core/ivorium_core.hpp
>
4
5
namespace
iv
6
{
7
8
template
<
class
Listener >
9
class
GenericListener_Index
;
10
11
//========================= GenericListener ============================
15
template
<
class
Listener >
16
class
GenericListener
17
{
18
public
:
19
iv::ClientMarker
cm
;
20
21
GenericListener
(
iv::Instance
* inst,
GenericListener_Index< Listener >
* index );
22
~GenericListener
();
23
24
iv::Instance
*
instance
()
const
;
25
29
void
Initialize
();
30
34
void
VerifyInitialization
();
35
36
private
:
37
iv::Instance
* inst;
38
GenericListener_Index< Listener >
* index;
39
bool
initialized;
40
};
41
42
//========================= GenericListener_Index ============================
46
template
<
class
Listener >
47
class
GenericListener_Index
48
{
49
public
:
50
iv::ClientMarker
cm
;
51
52
GenericListener_Index
(
iv::Instance
* inst );
53
iv::Instance
*
instance
()
const
;
54
55
// called by listeners
56
void
AddListener
( Listener * );
57
void
RemoveListener
( Listener * );
58
void
InitializeListener
( Listener * );
59
60
// called by owner
61
template
<
class
... Params >
62
void
InvokeListeners
(
void
( Listener::* member )( Params ... ), Params ... params );
63
64
65
protected
:
69
virtual
void
Listener_Initialize
( Listener * ) = 0;
70
71
private
:
72
iv::Instance
* inst;
73
iv::volatile_set< Listener * >
listeners;
74
};
75
76
}
77
78
#include "
GenericListener.inl
"