00001
00002
00003
00004
00005
00006
00007
00008
00042 #ifdef _MSC_VER
00043 #pragma once
00044 #endif
00045
00046 #include <stdio.h>
00047 #include <ogdf/basic/basic.h>
00048
00049
00050 #ifndef OGDF_EXCEPTIONS_H
00051 #define OGDF_EXCEPTIONS_H
00052
00053
00054 namespace ogdf {
00055
00056 #ifdef OGDF_DEBUG
00057
00062 #define OGDF_THROW_WITH_INFO
00063 #endif
00064
00065 #ifdef OGDF_THROW
00066 #undef OGDF_THROW
00067 #endif
00068
00069 #ifndef OGDF_THROW_WITH_INFO
00070 #define OGDF_THROW_PARAM(CLASS, PARAM) throw CLASS ( PARAM )
00071 #define OGDF_THROW(CLASS) throw CLASS ( )
00072 #else
00073
00074
00081 #define OGDF_THROW_PARAM(CLASS, PARAM) throw CLASS ( PARAM , __FILE__ , __LINE__ )
00082
00083
00088 #define OGDF_THROW(CLASS) throw CLASS ( __FILE__ , __LINE__ )
00089 #endif
00090
00091
00093
00096 enum PreconditionViolatedCode {
00097 pvcUnknown,
00098 pvcSelfLoop,
00099 pvcTreeHierarchies,
00100 pvcAcyclicHierarchies,
00101 pvcSingleSource,
00102 pvcUpwardPlanar,
00103 pvcTree,
00104 pvcForest,
00105 pvcOrthogonal,
00106 pvcPlanar,
00107 pvcClusterPlanar,
00108 pvcNoCopy,
00109 pvcConnected,
00110 pvcBiconnected,
00111 pvcSTOP
00112 };
00113
00114
00116
00119 enum AlgorithmFailureCode {
00120 afcUnknown,
00121 afcIllegalParameter,
00122 afcNoFlow,
00123 afcSort,
00124 afcLabel,
00125 afcExternalFace,
00126 afcForbiddenCrossing,
00127 afcTimelimitExceeded,
00128 afcNoSolutionFound,
00129 afcSTOP
00130 };
00131
00132
00133
00135
00138 enum LibraryNotSupportedCode {
00139 lnscUnknown,
00140 lnscCoin,
00141 lnscAbacus,
00142 lnscFunctionNotImplemented,
00143 lnscMissingCallbackImplementation,
00144 lnscSTOP
00145 };
00146
00147
00148
00150 class OGDF_EXPORT Exception {
00151
00152 private:
00153
00154 const char *m_file;
00155 int m_line;
00156
00157 public:
00159
00163 Exception(const char *file = NULL, int line = -1) :
00164 m_file(file),
00165 m_line(line)
00166 {}
00167
00169
00172 const char *file() { return m_file; }
00173
00175
00178 int line() { return m_line; }
00179 };
00180
00181
00183 class OGDF_EXPORT DynamicCastFailedException : public Exception {
00184
00185 public:
00187 DynamicCastFailedException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00188 };
00189
00190
00192 class OGDF_EXPORT InsufficientMemoryException : public Exception {
00193
00194 public:
00196 InsufficientMemoryException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00197 };
00198
00199
00201
00207 class OGDF_EXPORT NoStdComparerException : public Exception {
00208
00209 public:
00211 NoStdComparerException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00212 };
00213
00214
00216 class OGDF_EXPORT PreconditionViolatedException : public Exception
00217 {
00218 public:
00220 PreconditionViolatedException(PreconditionViolatedCode code,
00221 const char *file = NULL,
00222 int line = -1) :
00223 Exception(file, line),
00224 m_exceptionCode(code)
00225 {}
00226
00228 PreconditionViolatedException(
00229 const char *file = NULL,
00230 int line = -1) :
00231 Exception(file, line),
00232 m_exceptionCode(pvcUnknown)
00233 {}
00234
00236 PreconditionViolatedCode exceptionCode() const { return m_exceptionCode; }
00237
00238 private:
00239 PreconditionViolatedCode m_exceptionCode;
00240 };
00241
00242
00243
00245 class OGDF_EXPORT AlgorithmFailureException : public Exception
00246 {
00247 public:
00248
00250 AlgorithmFailureException(AlgorithmFailureCode code,
00251 const char *file = NULL,
00252 int line = -1) :
00253 Exception(file, line),
00254 m_exceptionCode(code)
00255 {}
00256
00258 AlgorithmFailureException(
00259 const char *file = NULL,
00260 int line = -1) :
00261 Exception(file, line),
00262 m_exceptionCode(afcUnknown)
00263 {}
00264
00266 AlgorithmFailureCode exceptionCode() const { return m_exceptionCode; }
00267
00268 private:
00269 AlgorithmFailureCode m_exceptionCode;
00270 };
00271
00272
00273
00275 class OGDF_EXPORT LibraryNotSupportedException : public Exception {
00276 public:
00278 LibraryNotSupportedException(LibraryNotSupportedCode code,
00279 const char *file = NULL,
00280 int line = -1) :
00281 Exception(file, line),
00282 m_exceptionCode(code)
00283 {}
00284
00286 LibraryNotSupportedException(
00287 const char *file = NULL,
00288 int line = -1) :
00289 Exception(file, line),
00290 m_exceptionCode(lnscUnknown)
00291 {}
00292
00294 LibraryNotSupportedCode exceptionCode() const { return m_exceptionCode; }
00295
00296 private:
00297 LibraryNotSupportedCode m_exceptionCode;
00298 };
00299
00300 }
00301
00302
00303 #endif