YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Event.hpp
Go to the documentation of this file.
1
#ifndef YAPOG_EVENT_HPP
2
# define YAPOG_EVENT_HPP
3
4
# include <functional>
5
# include <memory>
6
7
# include <boost/signals2.hpp>
8
9
# include "
YAPOG/Macros.hpp
"
10
# include "
YAPOG/Collection/Map.hpp
"
11
# include "
YAPOG/System/String.hpp
"
12
13
namespace
yap
14
{
15
class
YAPOG_LIB
EmptyEventArgs
{ };
16
17
template
<
typename
T>
18
class
ConstChangeEventArgs
19
{
20
public
:
ConstChangeEventArgs
(
const
T& old,
const
T& current)
21
:
Old
(old),
Current
(current) { }
22
const
T&
Old
,
Current
;
23
};
24
25
template
<
typename
T>
26
class
ChangeEventArgs
27
{
28
public
:
ChangeEventArgs
(T& old, T& current)
29
:
Old
(old),
Current
(current) { }
30
T&
Old
,
Current
;
31
};
32
33
template
<
typename
SenderType,
34
typename
ArgsType =
const
EmptyEventArgs
&,
35
typename
ReturnType =
void
>
36
class
Event
37
{
38
DISALLOW_COPY
(
Event
);
39
40
typedef
boost::signals2::signal<
41
ReturnType (SenderType, ArgsType)>
SignalType
;
42
typedef
typename
SignalType::slot_type
HandlerType
;
43
44
public
:
45
46
Event
();
47
~Event
();
48
49
Event
&
operator+=
(
HandlerType
handler);
50
51
void
AddHandler
(
const
String
& name,
HandlerType
handler);
52
void
RemoveHandler
(
const
String
& name);
53
54
ReturnType
operator()
(SenderType sender, ArgsType args);
55
56
private
:
57
58
typedef
boost::signals2::scoped_connection
ConnectionType
;
59
60
SignalType
sig_
;
61
62
collection::Map<String, std::shared_ptr<ConnectionType>
>
handlers_
;
63
};
64
}
// namespace yap
65
66
# include "
YAPOG/System/Event/Event.hxx
"
67
68
#endif // YAPOG_EVENT_HPP
YAPOG
include
YAPOG
System
Event
Event.hpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1