Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * exception.h - basic exception 00004 * 00005 * Generated: Thu Feb 09 13:02:37 2006 (from FireVision) 00006 * Copyright 2005-2006 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __CORE_EXCEPTION_H_ 00025 #define __CORE_EXCEPTION_H_ 00026 00027 // needed for va_list 00028 #include <cstdarg> 00029 #include <exception> 00030 00031 namespace fawkes { 00032 00033 00034 class Mutex; 00035 00036 class Exception : public std::exception { 00037 public: 00038 00039 Exception(const char *format, ...) throw(); 00040 Exception(int errno, const char *format, ...) throw(); 00041 Exception(const Exception &exc) throw(); 00042 virtual ~Exception() throw(); 00043 00044 virtual void raise(); 00045 void prepend(const char *format, ...) throw(); 00046 void append(const char *format, ...) throw(); 00047 void append_va(const char *format, va_list va) throw(); 00048 void append(const Exception &e) throw(); 00049 void print_trace() throw(); 00050 void print_backtrace() const throw(); 00051 char * generate_backtrace() const throw(); 00052 00053 int get_errno() throw(); 00054 00055 void set_type_id(const char *id); 00056 const char * type_id() const; 00057 00058 virtual const char* what() const throw(); 00059 00060 Exception& operator=(const Exception &exc) throw(); 00061 00062 protected: 00063 /** Internal exception message list */ 00064 struct message_list_t { 00065 message_list_t *next; /**< pointer to next element, NULL if last element */ 00066 char *msg; /**< pointer to message, may not be NULL, will be freed 00067 * in dtor */ 00068 }; 00069 00070 public: 00071 class iterator 00072 { 00073 friend class Exception; 00074 private: 00075 iterator(message_list_t *message_list); 00076 public: 00077 iterator(const iterator &i); 00078 iterator(); 00079 00080 iterator & operator++ (); // prefix 00081 iterator operator++ (int inc); // postfix 00082 00083 bool operator== (const iterator & i) const; 00084 bool operator!= (const iterator & i) const; 00085 00086 const char * operator* () const; 00087 iterator & operator= (const iterator & i); 00088 00089 private: 00090 message_list_t *mlist; 00091 }; 00092 00093 iterator begin() throw(); 00094 iterator end() throw(); 00095 00096 protected: 00097 Exception() throw(); 00098 00099 void append_nolock(const char *format, ...) throw(); 00100 void append_nolock_va(const char *format, va_list va) throw(); 00101 void append_nolock_nocopy(char *msg) throw(); 00102 void prepend_nolock_va(const char *format, va_list va) throw(); 00103 void copy_messages(const Exception &exc) throw(); 00104 00105 message_list_t *messages; 00106 message_list_t *messages_iterator; 00107 message_list_t *messages_end; 00108 Mutex *messages_mutex; 00109 00110 int _errno; 00111 00112 private: 00113 const char *__type_id; 00114 }; 00115 00116 00117 } // end namespace fawkes 00118 00119 #endif