OgreHapticsException.h

Go to the documentation of this file.
00001 /*
00002 This source file is part of OgreHaptics
00003  (a library for wrapping haptics devices for use with the open-source
00004  graphics engine OGRE, http://www.ogre3d.org)
00005 
00006 Copyright (c) 2006 - 2008 Jorrit de Vries
00007 Also see acknowledgements in Readme.html
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU Lesser General Public License
00011 as published by the Free Software Foundation; either version 2.1
00012 of the License, or (at your option) any later version.
00013 
00014 This library is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public
00020 License along with this library; if not, write to the
00021 Free Software Foundation, Inc.,
00022 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00023 */
00024 // -- Based on Ogre::Exception, original copyright follows --
00025 // 
00026 // This source file is part of OGRE
00027 //    (Object-oriented Graphics Rendering Engine)
00028 // For the latest info, see http://www.ogre3d.org/
00029 //
00030 // Copyright (c) 2000-2006 Torus Knot Software Ltd
00031 // Also see acknowledgements in Readme.html
00032 //
00033 // This program is free software; you can redistribute it and/or modify it under
00034 // the terms of the GNU Lesser General Public License as published by the Free Software
00035 // Foundation; either version 2 of the License, or (at your option) any later
00036 // version.
00037 //
00038 // This program is distributed in the hope that it will be useful, but WITHOUT
00039 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00040 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00041 //
00042 // You should have received a copy of the GNU Lesser General Public License along with
00043 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00044 // Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00045 // http://www.gnu.org/copyleft/lesser.txt.
00046 //
00047 // You may alternatively use this source under the terms of a specific version of
00048 // the OGRE Unrestricted License provided you have obtained such a license from
00049 // Torus Knot Software Ltd.
00050 #ifndef _OgreHapticsException_H__
00051 #define _OgreHapticsException_H__
00052 
00053 #include "OgreHapticsPrerequisites.h"
00054 
00055 namespace OgreHaptics {
00056 
00066     class _OgreHapticsExport Exception : public Ogre::Exception
00067     {
00068     public:
00070         enum ExceptionCodes
00071         {
00072             ERR_DUPLICATE_ITEM = 0x1101,
00073             ERR_HAPTICSAPI_ERROR,
00074             ERR_INTERNAL_ERROR,
00075             ERR_INVALID_ARGUMENTS,
00076             ERR_INVALID_OPERATION,
00077             ERR_ITEM_NOT_FOUND
00078         };
00080         Exception(int number, const String& description, const String& source);
00082         Exception(int number, const String& description, const String& source,
00083             const char* type, const char* file, long line);
00084             
00086         ~Exception() throw() {}
00087 
00092         virtual const String& getFullDescription(void) const;
00093     };
00094 
00095     class _OgreHapticsExport DuplicateItemException: public Exception
00096     {
00097     public:
00098         DuplicateItemException(int number, const String& description, const String& source, const char* file, long line)
00099             : Exception(number, description, source, "DuplicateItemException", file, line) {}
00100     };
00101 
00102     class _OgreHapticsExport HapticsAPIException : public Exception
00103     {
00104     public:
00105         HapticsAPIException(int number, const String& description, const String& source, const char* file, long line)
00106             : Exception(number, description, source, "HapticsAPIException", file, line) {}
00107     };
00108 
00109     class _OgreHapticsExport InternalErrorException : public Exception
00110     {
00111     public:
00112         InternalErrorException(int number, const String& description, const String& source, const char* file, long line)
00113             : Exception(number, description, source, "InternalErrorException", file, line) {}
00114     };
00115 
00116     class _OgreHapticsExport InvalidArgumentsException : public Exception
00117     {
00118     public:
00119         InvalidArgumentsException(int number, const String& description, const String& source, const char* file, long line)
00120             : Exception(number, description, source, "InvalidArgumentsException", file, line) {}
00121     };
00122 
00123     class _OgreHapticsExport InvalidOperationException : public Exception
00124     {
00125     public:
00126         InvalidOperationException(int number, const String& description, const String& source, const char* file, long line)
00127             : Exception(number, description, source, "InvalidOperationException", file, line) {}
00128     };
00129 
00130     class _OgreHapticsExport ItemNotFoundException : public Exception
00131     {
00132     public:
00133         ItemNotFoundException(int number, const String& description, const String& source, const char* file, long line)
00134             : Exception(number, description, source, "ItemNotFoundException", file, line) {}
00135     };
00136 
00144     class _OgreHapticsExport ExceptionFactory
00145     {
00146     public:
00147         static DuplicateItemException create(
00148             Ogre::ExceptionCodeType<Exception::ERR_DUPLICATE_ITEM> code,
00149             const String& desc,
00150             const String& src, const char* file, long line)
00151         {
00152             return DuplicateItemException(code.number, desc, src, file, line);
00153         };
00154         static HapticsAPIException create(
00155             Ogre::ExceptionCodeType<Exception::ERR_HAPTICSAPI_ERROR> code,
00156             const String& desc,
00157             const String& src, const char* file, long line)
00158         {
00159             return HapticsAPIException(code.number, desc, src, file, line);
00160         };
00161         static InternalErrorException create(
00162             Ogre::ExceptionCodeType<Exception::ERR_INTERNAL_ERROR> code,
00163             const String& desc,
00164             const String& src, const char* file, long line)
00165         {
00166             return InternalErrorException(code.number, desc, src, file, line);
00167         };
00168         static InvalidArgumentsException create(
00169             Ogre::ExceptionCodeType<Exception::ERR_INVALID_ARGUMENTS> code,
00170             const String& desc,
00171             const String& src, const char* file, long line)
00172         {
00173             return InvalidArgumentsException(code.number, desc, src, file, line);
00174         };
00175         static InvalidOperationException create(
00176             Ogre::ExceptionCodeType<Exception::ERR_INVALID_OPERATION> code,
00177             const String& desc,
00178             const String& src, const char* file, long line)
00179         {
00180             return InvalidOperationException(code.number, desc, src, file, line);
00181         };
00182         static ItemNotFoundException create(
00183             Ogre::ExceptionCodeType<Exception::ERR_ITEM_NOT_FOUND> code,
00184             const String& desc,
00185             const String& src, const char* file, long line)
00186         {
00187             return ItemNotFoundException(code.number, desc, src, file, line);
00188         };
00189     private:
00190         ExceptionFactory() {};
00191     };
00192 }
00193 
00194 #define OGREHAPTICS_EXCEPT(num, desc, src) throw OgreHaptics::ExceptionFactory::create( \
00195     Ogre::ExceptionCodeType<num>(), desc, src, __FILE__, __LINE__ );
00196 
00197 #endif

Last modified Tue Jan 6 22:31:25 2009