Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IEventQueue.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
4 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
5 * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8
9#pragma once
10
11#include "base/Event.h"
12#include "base/EventTypes.h"
13#include "common/IInterface.h"
14
15#include <functional>
16#include <string>
17
19
20// Opaque type for timer info. This is defined by subclasses of
21// IEventQueueBuffer.
22class EventQueueTimer;
23
25
31class IEventQueue : public IInterface
32{
33public:
34 using EventHandler = std::function<void(const Event &)>;
36 {
37 public:
39 uint32_t m_count;
40 };
41
43
44
46
49 virtual void loop() = 0;
50
52
56 virtual void adoptBuffer(IEventQueueBuffer *) = 0;
57
59
64 virtual bool getEvent(Event &event, double timeout = -1.0) = 0;
65
67
74 virtual bool dispatchEvent(const Event &event) = 0;
75
77
80 virtual void addEvent(const Event &event) = 0;
81
83
98 virtual EventQueueTimer *newTimer(double duration, void *target) = 0;
99
101
111 virtual EventQueueTimer *newOneShotTimer(double duration, void *target) = 0;
112
114
118 virtual void deleteTimer(EventQueueTimer *) = 0;
119
121
128 virtual void addHandler(EventTypes type, void *target, const EventHandler &handler) = 0;
129
131
135 virtual void removeHandler(EventTypes type, void *target) = 0;
136
138
141 virtual void removeHandlers(void *target) = 0;
142
144
148 virtual void waitForReady() const = 0;
149
151
153
155
159 virtual bool isEmpty() const = 0;
160
162
165 virtual void *getSystemTarget() = 0;
166
168};
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:39
static int type
Definition ArchNetworkWinsock.cpp:44
Definition SimpleEventQueueBuffer.cpp:13
Event.
Definition Event.h:27
Event queue buffer interface.
Definition IEventQueueBuffer.h:21
Definition IEventQueue.h:36
EventQueueTimer * m_timer
The timer.
Definition IEventQueue.h:38
uint32_t m_count
Number of repeats.
Definition IEventQueue.h:39
Event queue interface.
Definition IEventQueue.h:32
virtual void addHandler(EventTypes type, void *target, const EventHandler &handler)=0
Register an event handler for an event type.
virtual EventQueueTimer * newTimer(double duration, void *target)=0
Create a recurring timer.
virtual void waitForReady() const =0
Wait for event queue to become ready.
std::function< void(const Event &)> EventHandler
Definition IEventQueue.h:34
virtual bool getEvent(Event &event, double timeout=-1.0)=0
Remove event from queue.
virtual bool isEmpty() const =0
Test if queue is empty.
virtual void removeHandler(EventTypes type, void *target)=0
Unregister an event handler for an event type.
virtual void addEvent(const Event &event)=0
Add event to queue.
virtual EventQueueTimer * newOneShotTimer(double duration, void *target)=0
Create a one-shot timer.
virtual void removeHandlers(void *target)=0
Unregister all event handlers for an event target.
virtual void deleteTimer(EventQueueTimer *)=0
Destroy a timer.
virtual bool dispatchEvent(const Event &event)=0
Dispatch an event.
virtual void * getSystemTarget()=0
Get the system event type target.
virtual void loop()=0
Loop the event queue until quit.
virtual void adoptBuffer(IEventQueueBuffer *)=0
Set the buffer.
Base class of interfaces.
Definition IInterface.h:18
EventTypes
Definition EventTypes.h:13