deskflow/src/lib/arch/Arch.h
Chris Rizzitello ed1217e9cc
Use Deskflow Name (#7519)
* Use Deskflow Name

* Remove business-oriented options from issue templates

* Remove business-oriented workflow

* Bump version to 3.0.0 (to avoid confusion with previously used version numbers 1.x & 2.x)

* Update readme to reflect new project name and goals

* Found some more "synergy" to rename

* Rename `synlib` to `app`

* Rename `syntool` to `deskflow-legacy`

* Rename `synwinhk` to `dfwhook`

* Rename dirs from synergy to deskflow

* Rename more "Synergy" files

* Rename app bundle ID

* Fixed copyright typo

* Rename only title in serial key dialog (to be moved downstream later)

* Preserve original serial key window for moving downstream

* Restore dialogs ready for moving downstream

* Rename `QDeskflowApplication` to `DeskflowApplication` (the Q is confusing)

* Restore Volker's original project name

* Fixed mimetype

* Fixed weird grammar

* Fixed (more) weird grammar

* Broken link, restoring (but we should move all links out of source)

* Broken link, restoring (but we should move all links out of source)

* Add write permission to valgrind-analysis.yml

* Restore AUR conflicts

* Apply Clang format

* Update ChangeLog

* Back out version change

---------

Co-authored-by: Nick Bolton <nick@symless.com>
2024-09-17 20:00:25 +01:00

142 lines
4.3 KiB
C++

/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// TODO: consider whether or not to use either encapsulation (as below)
// or inheritance (as it is now) for the ARCH stuff.
//
// case for encapsulation:
// pros:
// - compiler errors for missing pv implementations are not absolutely bonkers.
// - function names don't have to be so verbose.
// - easier to understand and debug.
// - ctors in IArch implementations can call other implementations.
// cons:
// - slightly more code for calls to ARCH.
// - you'll have to modify each ARCH call.
//
// also, we may want to consider making each encapsulated
// class lazy-loaded so that apps like the daemon don't load
// stuff when they don't need it.
#pragma once
#include "common/common.h"
#if SYSAPI_WIN32
#include "arch/win32/ArchConsoleWindows.h"
#include "arch/win32/ArchDaemonWindows.h"
#include "arch/win32/ArchFileWindows.h"
#include "arch/win32/ArchLogWindows.h"
#include "arch/win32/ArchMultithreadWindows.h"
#include "arch/win32/ArchNetworkWinsock.h"
#include "arch/win32/ArchSleepWindows.h"
#include "arch/win32/ArchStringWindows.h"
#include "arch/win32/ArchSystemWindows.h"
#include "arch/win32/ArchTaskBarWindows.h"
#include "arch/win32/ArchTimeWindows.h"
#elif SYSAPI_UNIX
#include "arch/unix/ArchConsoleUnix.h"
#include "arch/unix/ArchDaemonUnix.h"
#include "arch/unix/ArchFileUnix.h"
#include "arch/unix/ArchLogUnix.h"
#include "arch/unix/ArchNetworkBSD.h"
#include "arch/unix/ArchSleepUnix.h"
#include "arch/unix/ArchStringUnix.h"
#include "arch/unix/ArchSystemUnix.h"
#include "arch/unix/ArchTaskBarXWindows.h"
#include "arch/unix/ArchTimeUnix.h"
#if HAVE_PTHREAD
#include "arch/unix/ArchMultithreadPosix.h"
#endif
#endif
/*!
\def ARCH
This macro evaluates to the singleton Arch object.
*/
#define ARCH (Arch::getInstance())
//! Delegating implementation of architecture dependent interfaces
/*!
This class is a centralized interface to all architecture dependent
interface implementations (except miscellaneous functions). It
instantiates an implementation of each interface and delegates calls
to each method to those implementations. Clients should use the
\c ARCH macro to access this object. Clients must also instantiate
exactly one of these objects before attempting to call any method,
typically at the beginning of \c main().
*/
class Arch : public ARCH_CONSOLE,
public ARCH_DAEMON,
public ARCH_FILE,
public ARCH_LOG,
public ARCH_MULTITHREAD,
public ARCH_NETWORK,
public ARCH_SLEEP,
public ARCH_STRING,
public ARCH_SYSTEM,
public ARCH_TASKBAR,
public ARCH_TIME {
public:
Arch();
Arch(Arch *arch);
virtual ~Arch();
//! Call init on other arch classes.
/*!
Some arch classes depend on others to exist first. When init is called
these classes will have ARCH available for use.
*/
virtual void init();
//
// accessors
//
//! Return the singleton instance
/*!
The client must have instantiated exactly once Arch object before
calling this function.
*/
static Arch *getInstance();
static void setInstance(Arch *s) { s_instance = s; }
private:
static Arch *s_instance;
};
//! Convenience object to lock/unlock an arch mutex
class ArchMutexLock {
public:
ArchMutexLock(ArchMutex mutex) : m_mutex(mutex) { ARCH->lockMutex(m_mutex); }
ArchMutexLock(ArchMutexLock const &) = delete;
ArchMutexLock(ArchMutexLock &&) = delete;
~ArchMutexLock() { ARCH->unlockMutex(m_mutex); }
ArchMutexLock &operator=(ArchMutexLock const &) = delete;
ArchMutexLock &operator=(ArchMutexLock &&) = delete;
private:
ArchMutex m_mutex;
};