source: vendor/synergy/current/lib/arch/XArch.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 4.9 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef XARCH_H
16#define XARCH_H
17
18#include "common.h"
19#include "stdstring.h"
20
21//! Generic thread exception
22/*!
23Exceptions derived from this class are used by the multithreading
24library to perform stack unwinding when a thread terminates. These
25exceptions must always be rethrown by clients when caught.
26*/
27class XThread { };
28
29//! Thread exception to cancel
30/*!
31Thrown to cancel a thread. Clients must not throw this type, but
32must rethrow it if caught (by XThreadCancel, XThread, or ...).
33*/
34class XThreadCancel : public XThread { };
35
36/*!
37\def RETHROW_XTHREAD
38Convenience macro to rethrow an XThread exception but ignore other
39exceptions. Put this in your catch (...) handler after necessary
40cleanup but before leaving or returning from the handler.
41*/
42#define RETHROW_XTHREAD \
43 try { throw; } catch (XThread&) { throw; } catch (...) { }
44
45//! Lazy error message string evaluation
46/*!
47This class encapsulates platform dependent error string lookup.
48Platforms subclass this type, taking an appropriate error code
49type in the c'tor and overriding eval() to return the error
50string for that error code.
51*/
52class XArchEval {
53public:
54 XArchEval() { }
55 virtual ~XArchEval() { }
56
57 virtual XArchEval* clone() const throw() = 0;
58
59 virtual std::string eval() const throw() = 0;
60};
61
62//! Generic exception architecture dependent library
63class XArch {
64public:
65 XArch(XArchEval* adoptedEvaluator) : m_eval(adoptedEvaluator) { }
66 XArch(const std::string& msg) : m_eval(NULL), m_what(msg) { }
67 XArch(const XArch& e) : m_eval(e.m_eval != NULL ? e.m_eval->clone() : NULL),
68 m_what(e.m_what) { }
69 ~XArch() { delete m_eval; }
70
71 std::string what() const throw();
72
73private:
74 XArchEval* m_eval;
75 mutable std::string m_what;
76};
77
78// Macro to declare XArch derived types
79#define XARCH_SUBCLASS(name_, super_) \
80class name_ : public super_ { \
81public: \
82 name_(XArchEval* adoptedEvaluator) : super_(adoptedEvaluator) { } \
83 name_(const std::string& msg) : super_(msg) { } \
84}
85
86//! Generic network exception
87/*!
88Exceptions derived from this class are used by the networking
89library to indicate various errors.
90*/
91XARCH_SUBCLASS(XArchNetwork, XArch);
92
93//! Operation was interrupted
94XARCH_SUBCLASS(XArchNetworkInterrupted, XArchNetwork);
95
96//! Network insufficient permission
97XARCH_SUBCLASS(XArchNetworkAccess, XArchNetwork);
98
99//! Network insufficient resources
100XARCH_SUBCLASS(XArchNetworkResource, XArchNetwork);
101
102//! No support for requested network resource/service
103XARCH_SUBCLASS(XArchNetworkSupport, XArchNetwork);
104
105//! Network I/O error
106XARCH_SUBCLASS(XArchNetworkIO, XArchNetwork);
107
108//! Network address is unavailable or not local
109XARCH_SUBCLASS(XArchNetworkNoAddress, XArchNetwork);
110
111//! Network address in use
112XARCH_SUBCLASS(XArchNetworkAddressInUse, XArchNetwork);
113
114//! No route to address
115XARCH_SUBCLASS(XArchNetworkNoRoute, XArchNetwork);
116
117//! Socket not connected
118XARCH_SUBCLASS(XArchNetworkNotConnected, XArchNetwork);
119
120//! Remote read end of socket has closed
121XARCH_SUBCLASS(XArchNetworkShutdown, XArchNetwork);
122
123//! Remote end of socket has disconnected
124XARCH_SUBCLASS(XArchNetworkDisconnected, XArchNetwork);
125
126//! Remote end of socket refused connection
127XARCH_SUBCLASS(XArchNetworkConnectionRefused, XArchNetwork);
128
129//! Remote end of socket is not responding
130XARCH_SUBCLASS(XArchNetworkTimedOut, XArchNetwork);
131
132//! Generic network name lookup erros
133XARCH_SUBCLASS(XArchNetworkName, XArchNetwork);
134
135//! The named host is unknown
136XARCH_SUBCLASS(XArchNetworkNameUnknown, XArchNetworkName);
137
138//! The named host is known but has no address
139XARCH_SUBCLASS(XArchNetworkNameNoAddress, XArchNetworkName);
140
141//! Non-recoverable name server error
142XARCH_SUBCLASS(XArchNetworkNameFailure, XArchNetworkName);
143
144//! Temporary name server error
145XARCH_SUBCLASS(XArchNetworkNameUnavailable, XArchNetworkName);
146
147//! The named host is known but no supported address
148XARCH_SUBCLASS(XArchNetworkNameUnsupported, XArchNetworkName);
149
150//! Generic daemon exception
151/*!
152Exceptions derived from this class are used by the daemon
153library to indicate various errors.
154*/
155XARCH_SUBCLASS(XArchDaemon, XArch);
156
157//! Could not daemonize
158XARCH_SUBCLASS(XArchDaemonFailed, XArchDaemon);
159
160//! Could not install daemon
161XARCH_SUBCLASS(XArchDaemonInstallFailed, XArchDaemon);
162
163//! Could not uninstall daemon
164XARCH_SUBCLASS(XArchDaemonUninstallFailed, XArchDaemon);
165
166//! Attempted to uninstall a daemon that was not installed
167XARCH_SUBCLASS(XArchDaemonUninstallNotInstalled, XArchDaemonUninstallFailed);
168
169
170#endif
Note: See TracBrowser for help on using the repository browser.