latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiException.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 07.04.99 00030 * revisions ..: $Id: ltiException.h,v 1.2 2006/02/07 18:08:19 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_EXCEPTION_H 00034 #define _LTI_EXCEPTION_H 00035 00036 #include "ltiObject.h" 00037 #include <exception> 00038 #include <string> 00039 00040 namespace lti { 00041 /** 00042 * Base class for all lti-library exceptions 00043 */ 00044 class exception 00045 : public object,public std::exception { 00046 public: 00047 /** 00048 * constructor. 00049 * @param excName name of the exception. These string will be copied and 00050 * can be accessed with the "what()" method 00051 */ 00052 exception(const char* excName = "exception"); 00053 00054 /** 00055 * constructor. 00056 * @param excName name of the exception. These string will be copied and 00057 * can be accessed with the "what()" method 00058 */ 00059 exception(const std::string& excName); 00060 00061 /** 00062 * copy constructor 00063 */ 00064 exception(const exception& other); 00065 00066 /** 00067 * destructor 00068 */ 00069 virtual ~exception() throw (); 00070 00071 /** 00072 * name of this type 00073 */ 00074 virtual const char* getTypeName() const; 00075 00076 /** 00077 * name of the exception 00078 */ 00079 virtual const char* what() const throw (); 00080 00081 /** 00082 * copy member 00083 */ 00084 inline exception& copy(const exception& other) { 00085 // call the standard copy member: 00086 (*dynamic_cast<std::exception*>(this))=other; 00087 exceptionName = other.what(); 00088 return (*this); 00089 }; 00090 00091 /** 00092 * clone this object 00093 */ 00094 virtual exception* clone() const; 00095 00096 /** 00097 * alias for copy operator! 00098 */ 00099 inline exception& operator=(const exception& other) { 00100 return copy(other); 00101 }; 00102 00103 protected: 00104 /** 00105 * the exception message. 00106 * This string will be returned with the method what() 00107 */ 00108 std::string exceptionName; 00109 }; 00110 00111 /** 00112 * allocException is thrown if a memory allocation problem occurs 00113 */ 00114 class allocException : public exception { 00115 public: 00116 allocException() : exception("memory allocation error") {}; 00117 virtual const char* getTypeName() const; 00118 }; 00119 } 00120 00121 #endif