Deskflow 1.26.0.134
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
34#include "arch/ArchDaemonNone.h"
38#endif
39
44#define ARCH (Arch::getInstance())
45
47
56class Arch : public ARCH_DAEMON, public ARCH_LOG, public ARCH_MULTITHREAD, public ARCH_NETWORK
57{
58public:
59 Arch();
60 ~Arch() override = default;
61
62#if defined(Q_OS_WIN)
64
68 void init() override;
69#endif
70
71 //
72 // accessors
73 //
74
76
80 static Arch *getInstance();
81
86 static void sleep(double timeout);
87
93 static double time();
94
95private:
96 static Arch *s_instance;
97};
98
101{
102public:
103 explicit ArchMutexLock(ArchMutex mutex) : m_mutex(mutex)
104 {
105 ARCH->lockMutex(m_mutex);
106 }
107 ArchMutexLock(ArchMutexLock const &) = delete;
110 {
111 ARCH->unlockMutex(m_mutex);
112 }
113
116
117private:
118 ArchMutex m_mutex;
119};
#define ARCH_DAEMON
Definition ArchDaemonNone.h:13
#define ARCH_LOG
Definition ArchLogUnix.h:12
#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:44
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:109
ArchMutexLock(ArchMutexLock const &)=delete
ArchMutexLock(ArchMutex mutex)
Definition Arch.h:103
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