Deskflow 1.26.0.207
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
Arch.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) 2002 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8#include <QtSystemDetection>
9// Consider whether or not to use either encapsulation (as below)
10// or inheritance (as it is now) for the ARCH stuff.
11//
12// case for encapsulation:
13// pros:
14// - compiler errors for missing pv implementations are not absolutely bonkers.
15// - function names don't have to be so verbose.
16// - easier to understand and debug.
17// - ctors in IArch implementations can call other implementations.
18// cons:
19// - slightly more code for calls to ARCH.
20// - you'll have to modify each ARCH call.
21//
22// also, we may want to consider making each encapsulated
23// class lazy-loaded so that apps like the daemon don't load
24// stuff when they don't need it.
25
26#pragma once
27
28#if defined(Q_OS_WIN)
33#else
37#endif
38
43#define ARCH (Arch::getInstance())
44
46
55#if defined(Q_OS_WIN)
56class Arch : public ARCH_DAEMON, public ARCH_LOG, public ARCH_MULTITHREAD, public ARCH_NETWORK
57#else
58class Arch : public ARCH_LOG, public ARCH_MULTITHREAD, public ARCH_NETWORK
59#endif
60{
61public:
62 Arch();
63 ~Arch() override = default;
64
65#if defined(Q_OS_WIN)
67
71 void init() override;
72#endif
73
74 //
75 // accessors
76 //
77
79
83 static Arch *getInstance();
84
89 static void sleep(double timeout);
90
96 static double time();
97
98private:
99 static Arch *s_instance;
100};
101
104{
105public:
106 explicit ArchMutexLock(ArchMutex mutex) : m_mutex(mutex)
107 {
108 ARCH->lockMutex(m_mutex);
109 }
110 ArchMutexLock(ArchMutexLock const &) = delete;
113 {
114 ARCH->unlockMutex(m_mutex);
115 }
116
119
120private:
121 ArchMutex m_mutex;
122};
#define ARCH_DAEMON
Definition ArchDaemonWindows.h:21
#define ARCH_LOG
Definition ArchLogUnix.h:13
#define ARCH_MULTITHREAD
Definition ArchMultithreadPosix.h:16
#define ARCH_NETWORK
Definition ArchNetworkBSD.h:18
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:40
#define ARCH
Definition Arch.h:43
ArchMutexImpl * ArchMutex
Opaque mutex type. An opaque type representing a mutex.
Definition IArchMultithread.h:40
ArchMutexLock & operator=(ArchMutexLock const &)=delete
ArchMutexLock & operator=(ArchMutexLock &&)=delete
ArchMutexLock(ArchMutexLock &&)=delete
~ArchMutexLock()
Definition Arch.h:112
ArchMutexLock(ArchMutexLock const &)=delete
ArchMutexLock(ArchMutex mutex)
Definition Arch.h:106
Delegating implementation of architecture dependent interfaces.
Definition Arch.h:60
static double time()
time
Definition Arch.cpp:52
static Arch * getInstance()
Return the singleton instance.
Definition Arch.cpp:37
~Arch() override=default
Arch()
Definition Arch.cpp:23
static void sleep(double timeout)
blocks calling thread for timout seconds
Definition Arch.cpp:43