el h / SimpleGUI

Fork of SimpleGUI by Duncan McIntyre

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EventDispatcher.h Source File

EventDispatcher.h

00001 #ifndef SIMPLEGUI_EVENT_DISPATCHER_H
00002 #define SIMPLEGUI_EVENT_DISPATCHER_H
00003 
00004 #include "rtos.h"
00005 
00006 #include "EventListener.h"
00007 #include "LinkedList.h"
00008 
00009 class EventDispatcher
00010 {
00011 
00012 
00013 public:
00014 
00015     EventDispatcher();
00016 
00017     void attachListener(EventListener* l);
00018     void detachListener(EventListener* l);
00019     void dispatchEvent(Event e);
00020     
00021     /**
00022     * Normally called from a separate thread to queue an event for later processing by the main thread
00023     **/
00024     void queueEvent(const Event e);
00025     
00026     /**
00027     * Should be called on the main thread
00028     **/
00029     void pumpEvents();
00030 
00031 private:
00032 
00033     LinkedList<EventListener> _listeners;
00034     Mail<Event, 64> _mailbox;
00035 
00036 };
00037 
00038 #endif