Open
Graph Drawing
Framework

 v.2010.10
 

exceptions.h

Go to the documentation of this file.
00001 /*
00002  * $Revision: 2027 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2010-09-01 11:55:17 +0200 (Wed, 01 Sep 2010) $ 
00007  ***************************************************************/
00008  
00052 #ifdef _MSC_VER
00053 #pragma once
00054 #endif
00055 
00056 #include <stdio.h>
00057 #include <ogdf/basic/basic.h>
00058 
00059 
00060 #ifndef OGDF_EXCEPTIONS_H
00061 #define OGDF_EXCEPTIONS_H
00062 
00063 
00064 namespace ogdf {
00065 
00066 #ifdef OGDF_DEBUG
00067 
00072 #define OGDF_THROW_WITH_INFO
00073 #endif
00074 
00075 #ifdef OGDF_THROW
00076 #undef OGDF_THROW
00077 #endif
00078 
00079 #ifndef OGDF_THROW_WITH_INFO
00080 #define OGDF_THROW_PARAM(CLASS, PARAM) throw CLASS ( PARAM )
00081 #define OGDF_THROW(CLASS)              throw CLASS ( )
00082 #else
00083 
00084 
00091 #define OGDF_THROW_PARAM(CLASS, PARAM) throw CLASS ( PARAM , __FILE__ , __LINE__ )
00092 
00093 
00098 #define OGDF_THROW(CLASS)              throw CLASS ( __FILE__ , __LINE__ )
00099 #endif
00100 
00101 
00103 
00106     enum PreconditionViolatedCode {
00107         pvcUnknown,
00108         pvcSelfLoop,          
00109         pvcTreeHierarchies,   
00110         pvcAcyclicHierarchies,
00111         pvcSingleSource,      
00112         pvcUpwardPlanar,      
00113         pvcTree,              
00114         pvcForest,            
00115         pvcOrthogonal,        
00116         pvcPlanar,            
00117         pvcClusterPlanar,     
00118         pvcNoCopy,            
00119         pvcConnected,         
00120         pvcBiconnected,         
00121         pvcSTOP               // INSERT NEW CODES BEFORE pvcSTOP!
00122     }; // enum PreconditionViolatedCode
00123 
00124 
00126 
00129     enum AlgorithmFailureCode {
00130         afcUnknown,
00131         afcIllegalParameter, 
00132         afcNoFlow,           
00133         afcSort,             
00134         afcLabel,            
00135         afcExternalFace,     
00136         afcForbiddenCrossing,
00137         afcTimelimitExceeded,
00138         afcNoSolutionFound,  
00139         afcSTOP              // INSERT NEW CODES BEFORE afcSTOP!
00140     }; // enum AlgorithmFailureCode
00141 
00142 
00143 
00145 
00148     enum LibraryNotSupportedCode {
00149         lnscUnknown,
00150         lnscCoin,                          
00151         lnscAbacus,                        
00152         lnscFunctionNotImplemented,        
00153         lnscMissingCallbackImplementation, //
00154         lnscSTOP                           // INSERT NEW CODES BEFORE nscSTOP!
00155     }; // enum AlgorithmFailureCode
00156 
00157 
00158 
00160     class OGDF_EXPORT Exception { 
00161 
00162     private:
00163 
00164         const char *m_file; 
00165         int         m_line; 
00166 
00167     public:
00169 
00173         Exception(const char *file = NULL, int line = -1) : 
00174           m_file(file),
00175           m_line(line)
00176         {}
00177 
00179 
00182         const char *file() { return m_file; }
00183         
00185 
00188         int line() { return m_line; }
00189     };
00190 
00191 
00193     class OGDF_EXPORT DynamicCastFailedException : public Exception {
00194 
00195     public:
00197         DynamicCastFailedException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00198     };
00199 
00200 
00202     class OGDF_EXPORT InsufficientMemoryException : public Exception {
00203 
00204     public:
00206         InsufficientMemoryException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00207     };
00208 
00209 
00211 
00217     class OGDF_EXPORT NoStdComparerException : public Exception {
00218 
00219     public:
00221         NoStdComparerException(const char *file = NULL, int line = -1) : Exception(file, line) {}
00222     };
00223 
00224 
00226     class OGDF_EXPORT PreconditionViolatedException : public Exception 
00227     {
00228     public:
00230         PreconditionViolatedException(PreconditionViolatedCode code,
00231             const char *file = NULL,
00232             int line = -1) :
00233         Exception(file, line),
00234         m_exceptionCode(code)
00235         {}
00236 
00238         PreconditionViolatedException(
00239             const char *file = NULL,
00240             int line = -1) :
00241         Exception(file, line),
00242         m_exceptionCode(pvcUnknown)
00243         {}
00244 
00246         PreconditionViolatedCode exceptionCode() const { return m_exceptionCode; }
00247 
00248     private:
00249         PreconditionViolatedCode m_exceptionCode; 
00250     }; // class PreconditionViolatedException
00251 
00252 
00253 
00255     class OGDF_EXPORT AlgorithmFailureException : public Exception
00256     {
00257     public:
00258 
00260         AlgorithmFailureException(AlgorithmFailureCode code,
00261             const char *file = NULL,
00262             int line = -1) :
00263         Exception(file, line),
00264         m_exceptionCode(code)
00265         {}
00266 
00268         AlgorithmFailureException(
00269             const char *file = NULL,
00270             int line = -1) :
00271         Exception(file, line),
00272         m_exceptionCode(afcUnknown)
00273         {}
00274 
00276         AlgorithmFailureCode exceptionCode() const { return m_exceptionCode; }
00277 
00278     private:
00279         AlgorithmFailureCode m_exceptionCode; 
00280     }; // class AlgorithmFailureException
00281 
00282 
00283 
00285     class OGDF_EXPORT LibraryNotSupportedException : public Exception {
00286         public:
00288             LibraryNotSupportedException(LibraryNotSupportedCode code,
00289                 const char *file = NULL,
00290                 int line = -1) :
00291             Exception(file, line),
00292             m_exceptionCode(code)
00293             {}
00294                 
00296             LibraryNotSupportedException(
00297                 const char *file = NULL,
00298                 int line = -1) :
00299             Exception(file, line),
00300             m_exceptionCode(lnscUnknown)
00301             {}
00302 
00304         LibraryNotSupportedCode exceptionCode() const { return m_exceptionCode; }
00305 
00306     private:
00307         LibraryNotSupportedCode m_exceptionCode; 
00308     }; // class LibraryNotSupportedException
00309 
00310 } // end namespace ogdf
00311 
00312 
00313 #endif