exception.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2004 00007 * 00008 * Last modified: 00009 * $Date: 2005-07-28 22:52:19 +0200 (Thu, 28 Jul 2005) $ by $Author: schulte $ 00010 * $Revision: 2072 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 namespace Gecode { 00023 00028 class Exception { 00029 private: 00030 const char* l; 00031 const char* i; 00032 public: 00034 Exception(const char* l, const char* i); 00036 const char* location(void) const; 00038 const char* info(void) const; 00039 }; 00040 00041 00048 00050 class MemoryExhausted : public Exception { 00051 public: 00053 MemoryExhausted(void); 00054 }; 00055 00057 class SpaceFailed : public Exception { 00058 public: 00060 SpaceFailed(const char* l); 00061 }; 00062 00064 class SpaceNoBranching : public Exception { 00065 public: 00067 SpaceNoBranching(void); 00068 }; 00069 00071 class SpaceIllegalAlternative : public Exception { 00072 public: 00074 SpaceIllegalAlternative(void); 00075 }; 00076 00078 00079 /* 00080 * Implementations 00081 * 00082 */ 00083 00084 /* 00085 * Base class for exceptions 00086 * 00087 */ 00088 forceinline 00089 Exception::Exception(const char* l0, const char* i0) 00090 : l(l0), i(i0) {} 00091 forceinline const char* 00092 Exception::location(void) const { 00093 return l; 00094 } 00095 forceinline const char* 00096 Exception::info(void) const { 00097 return i; 00098 } 00099 00100 00101 /* 00102 * Classes for exceptions raised by kernel 00103 * 00104 */ 00105 00106 inline 00107 MemoryExhausted::MemoryExhausted(void) 00108 : Exception("Memory","Heap memory exhausted") {} 00109 00110 inline 00111 SpaceFailed::SpaceFailed(const char* l) 00112 : Exception(l,"Attempt to invoke operation on failed space") {} 00113 00114 inline 00115 SpaceNoBranching::SpaceNoBranching(void) 00116 : Exception("Space::commit", 00117 "Attempt to commit with no branching") {} 00118 00119 inline 00120 SpaceIllegalAlternative::SpaceIllegalAlternative(void) 00121 : Exception("Space::commit", 00122 "Attempt to commit with illegal alternative") {} 00123 00124 } 00125 00126 // STATISTICS: kernel-other