COSA
An Object-Oriented Platform for Arduino Programming
Listener< T > Class Template Reference

#include <Listener.hh>

Inheritance diagram for Listener< T >:
Inheritance graph
Collaboration diagram for Listener< T >:
Collaboration graph

Public Member Functions

 Listener (T key)
 
key () const
 
void key (T key)
 
bool match (T key) const
 
void detach ()
 
Linkagesucc () const
 
Linkagepred () const
 
void attach (Linkage *pred)
 
virtual void on_event (uint8_t type, uint16_t value)
 

Static Public Member Functions

static void dispatch (Head *head, T key, uint8_t type, uint16_t value)
 

Protected Attributes

Linkagem_succ
 
Linkagem_pred
 

Detailed Description

template<typename T>
class Listener< T >

Template class for event listener. Allows dispatch of events onto a keyed set of listeners. The key data type must have assignment and at least operation== defined.

Parameters
[in]Tkey type.

Definition at line 33 of file Listener.hh.

Constructor & Destructor Documentation

template<typename T>
Listener< T >::Listener ( key)
inline

Construct Listener.

Parameters
[in]keydefault value for key.

Definition at line 39 of file Listener.hh.

Member Function Documentation

void Linkage::attach ( Linkage pred)
inlineinherited

Attach given linkage as predecessor. Will check and detach if already attached.

Parameters
[in]predlinkage to attach.
Note
atomic

Definition at line 71 of file Linkage.hh.

void Link::detach ( )
inlineinherited

Detach this link. Unlink from any list.

Definition at line 125 of file Linkage.hh.

template<typename T >
void Listener< T >::dispatch ( Head head,
key,
uint8_t  type,
uint16_t  value 
)
static

Dispatch given event type/value to all listeners in queue which match the given key.

Parameters
[in]headof queue.
[in]keyto match.
[in]typeof event.
[in]valuefor event.

Definition at line 89 of file Listener.hh.

template<typename T>
T Listener< T >::key ( ) const
inline

Return Listener key value.

Returns
key.

Definition at line 48 of file Listener.hh.

template<typename T>
void Listener< T >::key ( key)
inline

Set Listener key value.

Parameters
[in]keynew value.

Definition at line 57 of file Listener.hh.

template<typename T>
bool Listener< T >::match ( key) const
inline

Match Listener key with given value. Return true(1) if equal else false(0).

Returns
bool.

Definition at line 67 of file Listener.hh.

virtual void Event::Handler::on_event ( uint8_t  type,
uint16_t  value 
)
inlinevirtualinherited

Default null event handler. Should be redefined by sub-classes. Called by Event::dispatch().

Parameters
[in]typethe event type.
[in]valuethe event value.

Reimplemented in Menu::RotaryController, Rotary::Dial< T >, AnalogPin, Job, TWI::Slave, ProtoThread, AnalogPins, and Periodic.

Definition at line 107 of file Event.hh.

Linkage* Linkage::pred ( ) const
inlineinherited

Return predecessor in sequence.

Returns
predecessor linkage.

Definition at line 60 of file Linkage.hh.

Linkage* Linkage::succ ( ) const
inlineinherited

Return successor in sequence.

Returns
successor linkage.

Definition at line 51 of file Linkage.hh.

Member Data Documentation

Linkage* Linkage::m_pred
protectedinherited

Definition at line 94 of file Linkage.hh.

Linkage* Linkage::m_succ
protectedinherited

Double linked list pointers.

Definition at line 93 of file Linkage.hh.


The documentation for this class was generated from the following file: