2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2014-11-02 12:12:05 +00:00
|
|
|
* Copyright (C) 2012 Synergy Si Ltd.
|
2012-09-04 02:09:56 +00:00
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
2012-06-10 16:50:54 +00:00
|
|
|
*
|
|
|
|
* 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 COPYING 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.
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "common/common.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
#if SYSAPI_WIN32
|
2014-02-28 12:36:45 +00:00
|
|
|
# include "arch/win32/ArchConsoleWindows.h"
|
|
|
|
# include "arch/win32/ArchDaemonWindows.h"
|
|
|
|
# include "arch/win32/ArchFileWindows.h"
|
|
|
|
# include "arch/win32/ArchLogWindows.h"
|
|
|
|
# include "arch/win32/ArchMiscWindows.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"
|
|
|
|
# include "arch/win32/ArchPluginWindows.h"
|
|
|
|
# include "arch/win32/ArchInternetWindows.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
#elif SYSAPI_UNIX
|
2014-02-28 12:36:45 +00:00
|
|
|
# include "arch/unix/ArchConsoleUnix.h"
|
|
|
|
# include "arch/unix/ArchDaemonUnix.h"
|
|
|
|
# include "arch/unix/ArchFileUnix.h"
|
|
|
|
# include "arch/unix/ArchLogUnix.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
# if HAVE_PTHREAD
|
2014-02-28 12:36:45 +00:00
|
|
|
# include "arch/unix/ArchMultithreadPosix.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
# endif
|
2014-02-28 12:36:45 +00:00
|
|
|
# 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"
|
|
|
|
# include "arch/unix/ArchPluginUnix.h"
|
|
|
|
# include "arch/unix/ArchInternetUnix.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\def ARCH
|
2014-11-11 13:51:47 +00:00
|
|
|
This macro evaluates to the singleton Arch object.
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
2014-11-11 13:51:47 +00:00
|
|
|
#define ARCH (Arch::getInstance())
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
//! 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().
|
|
|
|
*/
|
2014-11-11 13:51:47 +00:00
|
|
|
class Arch : public ARCH_CONSOLE,
|
2012-06-10 16:50:54 +00:00
|
|
|
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:
|
2014-11-11 13:51:47 +00:00
|
|
|
Arch();
|
2015-01-14 17:24:45 +00:00
|
|
|
Arch(Arch* arch);
|
2014-11-11 13:51:47 +00:00
|
|
|
virtual ~Arch();
|
2012-07-10 01:51:51 +00:00
|
|
|
|
|
|
|
//! Call init on other arch classes.
|
|
|
|
/*!
|
|
|
|
Some arch classes depend on others to exist first. When init is called
|
|
|
|
these clases will have ARCH available for use.
|
|
|
|
*/
|
|
|
|
virtual void init();
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// accessors
|
|
|
|
//
|
|
|
|
|
|
|
|
//! Return the singleton instance
|
|
|
|
/*!
|
2014-11-11 13:51:47 +00:00
|
|
|
The client must have instantiated exactly once Arch object before
|
2012-06-10 16:50:54 +00:00
|
|
|
calling this function.
|
|
|
|
*/
|
2014-11-11 13:51:47 +00:00
|
|
|
static Arch* getInstance();
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
ARCH_PLUGIN& plugin() const { return (ARCH_PLUGIN&)m_plugin; }
|
2014-02-04 19:41:29 +00:00
|
|
|
ARCH_INTERNET& internet() const { return (ARCH_INTERNET&)m_internet; }
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
private:
|
2014-11-11 13:51:47 +00:00
|
|
|
static Arch* s_instance;
|
2012-06-10 16:50:54 +00:00
|
|
|
ARCH_PLUGIN m_plugin;
|
2014-02-04 19:41:29 +00:00
|
|
|
ARCH_INTERNET m_internet;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Convenience object to lock/unlock an arch mutex
|
2014-11-11 13:51:47 +00:00
|
|
|
class ArchMutexLock {
|
2012-06-10 16:50:54 +00:00
|
|
|
public:
|
2014-11-11 13:51:47 +00:00
|
|
|
ArchMutexLock(ArchMutex mutex) : m_mutex(mutex)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
ARCH->lockMutex(m_mutex);
|
|
|
|
}
|
2014-11-11 13:51:47 +00:00
|
|
|
~ArchMutexLock()
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
ARCH->unlockMutex(m_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-11 13:51:47 +00:00
|
|
|
ArchMutex m_mutex;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|