COSA
An Object-Oriented Platform for Arduino Programming
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Listener.hh
Go to the documentation of this file.
1
21
#ifndef COSA_LISTENER_HH
22
#define COSA_LISTENER_HH
23
24
#include "
Cosa/Linkage.hh
"
25
32
template
<
typename
T>
33
class
Listener
:
public
Link
{
34
public
:
39
Listener
(T
key
) :
40
Link
(),
41
m_key(key)
42
{}
43
48
T
key
()
const
49
{
50
return
(m_key);
51
}
52
57
void
key
(T
key
)
58
{
59
m_key =
key
;
60
}
61
67
bool
match
(T
key
)
const
68
{
69
return
(m_key == key);
70
}
71
80
static
void
dispatch
(
Head
* head, T
key
, uint8_t type, uint16_t value);
81
82
private
:
84
T m_key;
85
};
86
87
template
<
typename
T>
88
void
89
Listener<T>::dispatch
(
Head
* head, T
key
, uint8_t type, uint16_t value)
90
{
91
Linkage
* link = head->
succ
();
92
while
(link != head) {
93
Listener<T>
* listener = (
Listener<T>
*) link;
94
if
(listener->
match
(key)) listener->
on_event
(type, value);
95
link = link->
succ
();
96
}
97
}
98
#endif
Listener::match
bool match(T key) const
Definition:
Listener.hh:67
Linkage.hh
Link
Definition:
Linkage.hh:115
Listener::dispatch
static void dispatch(Head *head, T key, uint8_t type, uint16_t value)
Definition:
Listener.hh:89
Linkage
Definition:
Linkage.hh:36
Listener
Definition:
Listener.hh:33
Listener::key
T key() const
Definition:
Listener.hh:48
Listener::key
void key(T key)
Definition:
Listener.hh:57
Listener::Listener
Listener(T key)
Definition:
Listener.hh:39
Linkage::succ
Linkage * succ() const
Definition:
Linkage.hh:51
Event::Handler::on_event
virtual void on_event(uint8_t type, uint16_t value)
Definition:
Event.hh:107
Head
Definition:
Linkage.hh:132
cores
cosa
Cosa
Listener.hh
Generated on Thu Aug 31 2017 17:02:02 for COSA by
1.8.11