Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CArch.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CARCH_H
00016 #define CARCH_H
00017 
00018 #include "IArchConsole.h"
00019 #include "IArchDaemon.h"
00020 #include "IArchFile.h"
00021 #include "IArchLog.h"
00022 #include "IArchMultithread.h"
00023 #include "IArchNetwork.h"
00024 #include "IArchSleep.h"
00025 #include "IArchString.h"
00026 #include "IArchSystem.h"
00027 #include "IArchTaskBar.h"
00028 #include "IArchTime.h"
00029 
00034 #define ARCH    (CArch::getInstance())
00035 
00036 #define ARCH_ARGS void
00037 
00039 
00048 class CArch : public IArchConsole,
00049                 public IArchDaemon,
00050                 public IArchFile,
00051                 public IArchLog,
00052                 public IArchMultithread,
00053                 public IArchNetwork,
00054                 public IArchSleep,
00055                 public IArchString,
00056                 public IArchSystem,
00057                 public IArchTaskBar,
00058                 public IArchTime {
00059 public:
00060     CArch(ARCH_ARGS* args = NULL);
00061     ~CArch();
00062 
00063     //
00064     // accessors
00065     //
00066 
00068 
00072     static CArch*       getInstance();
00073 
00074     // IArchConsole overrides
00075     virtual void        openConsole(const char*);
00076     virtual void        closeConsole();
00077     virtual void        showConsole(bool showIfEmpty);
00078     virtual void        writeConsole(const char*);
00079     virtual const char* getNewlineForConsole();
00080 
00081     // IArchDaemon overrides
00082     virtual void        installDaemon(const char* name,
00083                             const char* description,
00084                             const char* pathname,
00085                             const char* commandLine,
00086                             const char* dependencies,
00087                             bool allUsers);
00088     virtual void        uninstallDaemon(const char* name, bool allUsers);
00089     virtual int         daemonize(const char* name, DaemonFunc func);
00090     virtual bool        canInstallDaemon(const char* name, bool allUsers);
00091     virtual bool        isDaemonInstalled(const char* name, bool allUsers);
00092 
00093     // IArchFile overrides
00094     virtual const char* getBasename(const char* pathname);
00095     virtual std::string getUserDirectory();
00096     virtual std::string getSystemDirectory();
00097     virtual std::string concatPath(const std::string& prefix,
00098                             const std::string& suffix);
00099 
00100     // IArchLog overrides
00101     virtual void        openLog(const char*);
00102     virtual void        closeLog();
00103     virtual void        showLog(bool showIfEmpty);
00104     virtual void        writeLog(ELevel, const char*);
00105 
00106     // IArchMultithread overrides
00107     virtual CArchCond   newCondVar();
00108     virtual void        closeCondVar(CArchCond);
00109     virtual void        signalCondVar(CArchCond);
00110     virtual void        broadcastCondVar(CArchCond);
00111     virtual bool        waitCondVar(CArchCond, CArchMutex, double timeout);
00112     virtual CArchMutex  newMutex();
00113     virtual void        closeMutex(CArchMutex);
00114     virtual void        lockMutex(CArchMutex);
00115     virtual void        unlockMutex(CArchMutex);
00116     virtual CArchThread newThread(ThreadFunc, void*);
00117     virtual CArchThread newCurrentThread();
00118     virtual CArchThread copyThread(CArchThread);
00119     virtual void        closeThread(CArchThread);
00120     virtual void        cancelThread(CArchThread);
00121     virtual void        setPriorityOfThread(CArchThread, int n);
00122     virtual void        testCancelThread();
00123     virtual bool        wait(CArchThread, double timeout);
00124     virtual bool        isSameThread(CArchThread, CArchThread);
00125     virtual bool        isExitedThread(CArchThread);
00126     virtual void*       getResultOfThread(CArchThread);
00127     virtual ThreadID    getIDOfThread(CArchThread);
00128     virtual void        setSignalHandler(ESignal, SignalFunc, void*);
00129     virtual void        raiseSignal(ESignal);
00130 
00131     // IArchNetwork overrides
00132     virtual CArchSocket newSocket(EAddressFamily, ESocketType);
00133     virtual CArchSocket copySocket(CArchSocket s);
00134     virtual void        closeSocket(CArchSocket s);
00135     virtual void        closeSocketForRead(CArchSocket s);
00136     virtual void        closeSocketForWrite(CArchSocket s);
00137     virtual void        bindSocket(CArchSocket s, CArchNetAddress addr);
00138     virtual void        listenOnSocket(CArchSocket s);
00139     virtual CArchSocket acceptSocket(CArchSocket s, CArchNetAddress* addr);
00140     virtual bool        connectSocket(CArchSocket s, CArchNetAddress name);
00141     virtual int         pollSocket(CPollEntry[], int num, double timeout);
00142     virtual void        unblockPollSocket(CArchThread thread);
00143     virtual size_t      readSocket(CArchSocket s, void* buf, size_t len);
00144     virtual size_t      writeSocket(CArchSocket s,
00145                             const void* buf, size_t len);
00146     virtual void        throwErrorOnSocket(CArchSocket);
00147     virtual bool        setNoDelayOnSocket(CArchSocket, bool noDelay);
00148     virtual bool        setReuseAddrOnSocket(CArchSocket, bool reuse);
00149     virtual std::string     getHostName();
00150     virtual CArchNetAddress newAnyAddr(EAddressFamily);
00151     virtual CArchNetAddress copyAddr(CArchNetAddress);
00152     virtual CArchNetAddress nameToAddr(const std::string&);
00153     virtual void            closeAddr(CArchNetAddress);
00154     virtual std::string     addrToName(CArchNetAddress);
00155     virtual std::string     addrToString(CArchNetAddress);
00156     virtual EAddressFamily  getAddrFamily(CArchNetAddress);
00157     virtual void            setAddrPort(CArchNetAddress, int port);
00158     virtual int             getAddrPort(CArchNetAddress);
00159     virtual bool            isAnyAddr(CArchNetAddress);
00160     virtual bool            isEqualAddr(CArchNetAddress, CArchNetAddress);
00161 
00162     // IArchSleep overrides
00163     virtual void        sleep(double timeout);
00164 
00165     // IArchString overrides
00166     virtual int         vsnprintf(char* str,
00167                             int size, const char* fmt, va_list ap);
00168     virtual int         convStringMBToWC(wchar_t*,
00169                             const char*, UInt32 n, bool* errors);
00170     virtual int         convStringWCToMB(char*,
00171                             const wchar_t*, UInt32 n, bool* errors);
00172     virtual EWideCharEncoding
00173                         getWideCharEncoding();
00174 
00175     // IArchSystem overrides
00176     virtual std::string getOSName() const;
00177     virtual std::string getPlatformName() const;
00178 
00179     // IArchTaskBar
00180     virtual void        addReceiver(IArchTaskBarReceiver*);
00181     virtual void        removeReceiver(IArchTaskBarReceiver*);
00182     virtual void        updateReceiver(IArchTaskBarReceiver*);
00183 
00184     // IArchTime overrides
00185     virtual double      time();
00186 
00187 private:
00188     static CArch*       s_instance;
00189 
00190     IArchConsole*       m_console;
00191     IArchDaemon*        m_daemon;
00192     IArchFile*          m_file;
00193     IArchLog*           m_log;
00194     IArchMultithread*   m_mt;
00195     IArchNetwork*       m_net;
00196     IArchSleep*         m_sleep;
00197     IArchString*        m_string;
00198     IArchSystem*        m_system;
00199     IArchTaskBar*       m_taskbar;
00200     IArchTime*          m_time;
00201 };
00202 
00204 class CArchMutexLock {
00205 public:
00206     CArchMutexLock(CArchMutex mutex) : m_mutex(mutex)
00207     {
00208         ARCH->lockMutex(m_mutex);
00209     }
00210     ~CArchMutexLock()
00211     {
00212         ARCH->unlockMutex(m_mutex);
00213     }
00214 
00215 private:
00216     CArchMutex          m_mutex;
00217 };
00218 
00219 #endif

Generated on Fri Nov 6 00:21:13 2009 for synergy-plus by  doxygen 1.3.9.1