PCMException.h

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
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 General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #ifndef __PCM_EXCEPTION_H__
00029 #  define __PCM_EXCEPTION_H__
00030 
00031 //
00032 // Inner includes
00033 //
00034 
00035 #  include "PCMPremeditations.h"
00036 
00037 //
00038 // Macro definitions
00039 //
00040 
00042 #  define Except(type, func, desc) throw(ParCompMark::Exception(Exception::type, desc, __FILE__, func, __LINE__ ))
00044 #  define Assert(cond, type, func) if(!(cond)) Except(Exception::type, func, "Assertion error: " #cond)
00045 
00046 namespace ParCompMark
00047 {
00048 
00061   class Exception
00062   {
00063 
00064         //
00065         // Unit test class
00066         //
00067 #  ifdef PARCOMPMARK_TEST
00068         friend class ParCompMarkTest::TestException;
00069 #  endif
00070 
00071         //
00072         // Enumerations
00073         //
00074 
00075    public:
00076 
00078         enum ExceptionType
00079         {
00080 
00082          INTERNAL_ERROR,
00083 
00085          NULL_POINTER_ERROR,
00086 
00088          INVALID_NAME_ERROR,
00089 
00091          INVALID_ENUM_ERROR,
00092 
00094          INVALID_VALUE_ERROR,
00095 
00097          INVALID_OBJECT_ERROR,
00098 
00100          INVALID_CLASS_ERROR,
00101 
00103          INVALID_OPERATION_ERROR,
00104 
00106          OPERATION_NOT_SUPPORTED_ERROR,
00107 
00109          OUT_OF_MEMORY_ERROR,
00110 
00112          FILE_IO_ERROR,
00113 
00115          FILE_FORMAT_ERROR,
00116 
00118          USER_BREAK_ERROR,
00119 
00121          SCRIPT_ERROR,
00122 
00124          XLIB_ERROR
00125         };
00126 
00127         //
00128         // Class variables
00129         //
00130 
00132 
00133 
00134    protected:
00135 
00141         static Exception *mLastException;
00142 
00144 
00145         //
00146         // Variables
00147         //
00148 
00150 
00151 
00152    protected:
00153 
00159         ExceptionType mType;
00160 
00166         std::string mDescription;
00167 
00173         std::string mFileName;
00174 
00180         std::string mFunctionName;
00181 
00187         u32 mLineNumber;
00188 
00190 
00191         //
00192         // Constructors & destructor
00193         //
00194 
00196 
00197 
00198    public:
00199 
00208         Exception(const ExceptionType & type = INTERNAL_ERROR, const std::string & description =
00209                  "unknown", const std::string & fileName = "unknown", const std::string & functionName =
00210                  "unknown", const u32 & lineNumber = 0);
00211 
00213 
00214         //
00215         // Getters & setters
00216         //
00217 
00219 
00220 
00221    public:
00222 
00228         const Exception::ExceptionType & getType() const;
00229 
00235         const std::string & getDescription() const;
00236 
00242         const std::string & getFileName() const;
00243 
00249         const std::string & getFunctionName() const;
00250 
00256         const u32 & getLineNumber() const;
00257 
00263         static Exception *getLastException();
00264 
00266 
00267         //
00268         // Class methods
00269         //
00270 
00272 
00273 
00274    public:
00275 
00281         static std::string translateType(const Exception::ExceptionType & type);
00282 
00284 
00285   };
00286 
00287   //
00288   // Include header implementation
00289   //
00290 
00291 #  include "PCMException_impl.h"
00292 
00293 }
00294 
00295 #endif