Deskflow 1.22.0.197
Keyboard and mouse sharing utility
|
Event queue interface. More...
#include <IEventQueue.h>
Classes | |
class | TimerEvent |
Public Types | |
using | EventHandler = std::function<void(const Event &)> |
Public Member Functions | |
manipulators | |
virtual void | loop ()=0 |
Loop the event queue until quit. | |
virtual void | adoptBuffer (IEventQueueBuffer *)=0 |
Set the buffer. | |
virtual bool | getEvent (Event &event, double timeout=-1.0)=0 |
Remove event from queue. | |
virtual bool | dispatchEvent (const Event &event)=0 |
Dispatch an event. | |
virtual void | addEvent (const Event &event)=0 |
Add event to queue. | |
virtual EventQueueTimer * | newTimer (double duration, void *target)=0 |
Create a recurring timer. | |
virtual EventQueueTimer * | newOneShotTimer (double duration, void *target)=0 |
Create a one-shot timer. | |
virtual void | deleteTimer (EventQueueTimer *)=0 |
Destroy a timer. | |
virtual void | addHandler (EventTypes type, void *target, const EventHandler &handler)=0 |
Register an event handler for an event type. | |
virtual void | removeHandler (EventTypes type, void *target)=0 |
Unregister an event handler for an event type. | |
virtual void | removeHandlers (void *target)=0 |
Unregister all event handlers for an event target. | |
virtual void | waitForReady () const =0 |
Wait for event queue to become ready. | |
accessors | |
virtual bool | isEmpty () const =0 |
Test if queue is empty. | |
virtual void * | getSystemTarget ()=0 |
Get the system event type target. | |
Public Member Functions inherited from IInterface | |
virtual | ~IInterface ()=default |
Interface destructor does nothing. |
Event queue interface.
An event queue provides a queue of Events. Clients can block waiting on any event becoming available at the head of the queue and can place new events at the end of the queue. Clients can also add and remove timers which generate events periodically.
using IEventQueue::EventHandler = std::function<void(const Event &)> |
|
pure virtual |
|
pure virtual |
Register an event handler for an event type.
Registers an event handler for type
and target
. The handler
is adopted. Any existing handler for the type,target pair is deleted. dispatchEvent()
will invoke handler
for any event for target
of type type
. If no such handler exists it will use the handler for target
and type kUnknown
if it exists.
Implemented in EventQueue.
|
pure virtual |
Set the buffer.
Replace the current event queue buffer. Any queued events are discarded. The queue takes ownership of the buffer.
Implemented in EventQueue.
|
pure virtual |
Destroy a timer.
Destroys a previously created timer. The timer is removed from the queue and will not generate event, even if the timer has expired.
Implemented in EventQueue.
|
pure virtual |
Dispatch an event.
Looks up the dispatcher for the event's target and invokes it. Returns true iff a dispatcher exists for the target.
The caller must ensure that the target of the event is not removed by removeHandler() or removeHandlers().
Implemented in EventQueue.
|
pure virtual |
Remove event from queue.
Returns the next event on the queue into event
. If no event is available then blocks for up to timeout
seconds, or forever if timeout
is negative. Returns true iff an event was available.
Implemented in EventQueue.
|
pure virtual |
Get the system event type target.
Returns the target to use for dispatching EventTypes::System
events.
Implemented in EventQueue.
|
pure virtual |
Test if queue is empty.
Returns true iff the queue has no events in it, including timer events.
Implemented in EventQueue.
|
pure virtual |
Loop the event queue until quit.
Dequeues and dispatches events until the kQuit event is found.
Implemented in EventQueue.
|
pure virtual |
Create a one-shot timer.
Creates and returns a one-shot timer. An event is returned when the timer expires and the timer is removed from further handling. When a timer event is returned the data points to a TimerEvent
. The c_count member of the TimerEvent
is always 1. The client must pass the returned timer to deleteTimer()
(whether or not the timer has expired) to release the timer. The returned timer event uses the given target
. If target
is nullptr it uses the returned timer as the target.
Implemented in EventQueue.
|
pure virtual |
Create a recurring timer.
Creates and returns a timer. An event is returned after duration
seconds and the timer is reset to countdown again. When a timer event is returned the data points to a TimerEvent
. The client must pass the returned timer to deleteTimer()
(whether or not the timer has expired) to release the timer. The returned timer event uses the given target
. If target
is nullptr it uses the returned timer as the target.
Events for a single timer don't accumulate in the queue, even if the client reading events can't keep up. Instead, the m_count
member of the TimerEvent
indicates how many events for the timer would have been put on the queue since the last event for the timer was removed (or since the timer was added).
Implemented in EventQueue.
|
pure virtual |
Unregister an event handler for an event type.
Unregisters an event handler for the type
, target
pair and deletes it.
Implemented in EventQueue.
|
pure virtual |
Unregister all event handlers for an event target.
Unregisters all event handlers for the target
and deletes them.
Implemented in EventQueue.
|
pure virtual |
Wait for event queue to become ready.
Blocks on the current thread until the event queue is ready for events to be added.
Implemented in EventQueue.