Foundation classes for a basic GUI implementing simple widgets and events

Dependents:   TouchScreenGUIDemo

Events/EventDispatcher.h

Committer:
duncanFrance
Date:
2016-05-28
Revision:
18:d849f3ada858
Parent:
12:63db16fea709

File content as of revision 18:d849f3ada858:

#ifndef SIMPLEGUI_EVENT_DISPATCHER_H
#define SIMPLEGUI_EVENT_DISPATCHER_H

#include "rtos.h"

#include "EventListener.h"
#include "LinkedList.h"

class EventDispatcher
{


public:

    EventDispatcher();

    void attachListener(EventListener* l);
    void detachListener(EventListener* l);
    void dispatchEvent(Event e);
    
    /**
    * Normally called from a separate thread to queue an event for later processing by the main thread
    **/
    void queueEvent(const Event e);
    
    /**
    * Should be called on the main thread
    **/
    void pumpEvents();

private:

    LinkedList<EventListener> _listeners;
    Mail<Event, 64> _mailbox;

};

#endif