Deskflow
1.26.0.418
Keyboard and mouse sharing utility
Toggle main menu visibility
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 Synergy App 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)
29
#include "
arch/win32/ArchDaemonWindows.h
"
30
#include "
arch/win32/ArchLogWindows.h
"
31
#include "
arch/win32/ArchMultithreadWindows.h
"
32
#include "
arch/win32/ArchNetworkWinsock.h
"
33
#else
34
#include "
arch/unix/ArchLogUnix.h
"
35
#include "
arch/unix/ArchMultithreadPosix.h
"
36
#include "
arch/unix/ArchNetworkBSD.h
"
37
#endif
38
43
#define ARCH (Arch::getInstance())
44
46
55
#if defined(Q_OS_WIN)
56
class
Arch
:
public
ARCH_DAEMON
,
public
ARCH_LOG
,
public
ARCH_MULTITHREAD
,
public
ARCH_NETWORK
57
#else
58
class
Arch
:
public
ARCH_LOG
,
public
ARCH_MULTITHREAD
,
public
ARCH_NETWORK
59
#endif
60
{
61
public
:
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
98
private
:
99
static
Arch
*s_instance;
100
};
101
103
class
ArchMutexLock
104
{
105
public
:
106
explicit
ArchMutexLock
(
ArchMutex
mutex) : m_mutex(mutex)
107
{
108
ARCH
->lockMutex(m_mutex);
109
}
110
ArchMutexLock
(
ArchMutexLock
const
&) =
delete
;
111
ArchMutexLock
(
ArchMutexLock
&&) =
delete
;
112
~ArchMutexLock
()
113
{
114
ARCH
->unlockMutex(m_mutex);
115
}
116
117
ArchMutexLock
&
operator=
(
ArchMutexLock
const
&) =
delete
;
118
ArchMutexLock
&
operator=
(
ArchMutexLock
&&) =
delete
;
119
120
private
:
121
ArchMutex
m_mutex;
122
};
ArchDaemonWindows.h
ARCH_DAEMON
#define ARCH_DAEMON
Definition
ArchDaemonWindows.h:21
ArchLogUnix.h
ARCH_LOG
#define ARCH_LOG
Definition
ArchLogUnix.h:13
ArchLogWindows.h
ArchMultithreadPosix.h
ARCH_MULTITHREAD
#define ARCH_MULTITHREAD
Definition
ArchMultithreadPosix.h:16
ArchMultithreadWindows.h
ArchNetworkBSD.h
ARCH_NETWORK
#define ARCH_NETWORK
Definition
ArchNetworkBSD.h:18
timeout
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition
ArchNetworkWinsock.cpp:41
ArchNetworkWinsock.h
ARCH
#define ARCH
Definition
Arch.h:43
ArchMutex
ArchMutexImpl * ArchMutex
Opaque mutex type. An opaque type representing a mutex.
Definition
IArchMultithread.h:40
ArchMutexLock::operator=
ArchMutexLock & operator=(ArchMutexLock const &)=delete
ArchMutexLock::operator=
ArchMutexLock & operator=(ArchMutexLock &&)=delete
ArchMutexLock::ArchMutexLock
ArchMutexLock(ArchMutexLock &&)=delete
ArchMutexLock::~ArchMutexLock
~ArchMutexLock()
Definition
Arch.h:112
ArchMutexLock::ArchMutexLock
ArchMutexLock(ArchMutexLock const &)=delete
ArchMutexLock::ArchMutexLock
ArchMutexLock(ArchMutex mutex)
Definition
Arch.h:106
Arch
Delegating implementation of architecture dependent interfaces.
Definition
Arch.h:60
Arch::time
static double time()
time
Definition
Arch.cpp:52
Arch::getInstance
static Arch * getInstance()
Return the singleton instance.
Definition
Arch.cpp:37
Arch::~Arch
~Arch() override=default
Arch::Arch
Arch()
Definition
Arch.cpp:23
Arch::sleep
static void sleep(double timeout)
blocks calling thread for timout seconds
Definition
Arch.cpp:43
src
lib
arch
Arch.h
Generated by
1.18.0