#ifndef _EVENTLISTENER_h #define _EVENTLISTENER_h #include "watchos_consts.h" #include "Queue.h" #include "Event.h" /// /// Mixin for a object which can receive events from the kernel /// class EventListener { private: Queue* m_event_queue; protected: /// /// Check whether there are any events available in the buffer /// /// True if there are events; False if no events bool hasEvent(); /// /// Fetch the next event from the buffer and return it /// /// A pointer to the next event in the buffer; shared, do not modify Event* getEvent(); /// /// Remove the last fetched event from the buffer; releases our reference to its handle /// void popEvent(); public: /// /// Initialize the ring buffer /// EventListener(); /// /// Push an event into the queue /// /// /// This is passed a kernel handle so the event system may take a reference to it (increasing the /// kernel's refcount) and eventually release it when processed (decreasing the refcount) so that /// the kernel can handle allocating/releasing this for us. /// /// void pushEvent(kernel_handle_t handle); }; #endif