last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998-2004 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 00042 /** 00043 * \file cvrException.h 00044 * Defines base class for all exceptions in the CVR-Lib. 00045 * If you compile the library with the symbol _DEBUG_EXCEPTION defined 00046 * the process of creating an exception will print an error message 00047 * in std::cerr. This should help you finding problems with systems 00048 * that cannot cope with C++ exception (e.g. Java). 00049 * \author Pablo Alvarado 00050 * \date 07.04.99 00051 * 00052 * $Id: cvrException.h,v 1.5 2007/04/04 19:18:29 alvarado Exp $ 00053 */ 00054 00055 #ifndef _CVR_EXCEPTION_H 00056 #define _CVR_EXCEPTION_H 00057 00058 #include "cvrObject.h" 00059 #include <exception> 00060 #include <string> 00061 00062 namespace cvr { 00063 /** 00064 * Base class for all CVR-Libexceptions 00065 */ 00066 class exception : public object,public std::exception { 00067 public: 00068 /** 00069 * Constructor with an optional string. 00070 * @param excName name of the exception. These string will be copied and 00071 * can be accessed with the "what()" method 00072 */ 00073 exception(const char* excName = "exception"); 00074 00075 /** 00076 * Constructor with an optional string. 00077 * @param excName name of the exception. These string will be copied and 00078 * can be accessed with the "what()" method 00079 */ 00080 exception(const std::string& excName); 00081 00082 /** 00083 * Copy constructor 00084 */ 00085 exception(const exception& other); 00086 00087 /** 00088 * Destructor 00089 */ 00090 virtual ~exception() throw (); 00091 00092 /** 00093 * Returns the name of this type 00094 */ 00095 virtual const std::string& name() const; 00096 00097 /** 00098 * Exception string 00099 * 00100 * @return The internal string with the information set at construction 00101 * time. 00102 */ 00103 virtual const char* what() const throw (); 00104 00105 /** 00106 * Copy member 00107 */ 00108 exception& copy(const exception& other); 00109 00110 /** 00111 * Clone this object 00112 */ 00113 virtual exception* clone() const; 00114 00115 /** 00116 * Create new instance of this object 00117 */ 00118 virtual exception* newInstance() const; 00119 00120 /** 00121 * Alias for copy operator 00122 */ 00123 exception& operator=(const exception& other); 00124 00125 protected: 00126 /** 00127 * The exception message. 00128 * 00129 * This string will be returned with the method what() and is set at 00130 * construction time. 00131 */ 00132 std::string exceptionName_; 00133 }; 00134 00135 } 00136 00137 #endif 00138