Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkExceptionObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkExceptionObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-06-13 07:20:05 $
00007   Version:   $Revision: 1.39 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 // itkExceptionObject.h is normally included through itkMacro.h, but
00018 // some code includes it directly.
00019 #ifndef __itkMacro_h
00020 #include "itkMacro.h"
00021 #else
00022 
00023 #ifndef __itkExceptionObject_h
00024 #define __itkExceptionObject_h
00025 
00026 #include <string>
00027 #include <stdexcept>
00028 
00029 #include "itkSmartPointer.h"
00030 #include "itkWin32Header.h"
00031 
00032 
00033 namespace itk
00034 {
00035 
00054 class ITKCommon_EXPORT ExceptionObject : public std::exception
00055 {
00056 public:
00057   typedef std::exception Superclass;
00061   ExceptionObject();
00062   explicit ExceptionObject(const char *file, unsigned int lineNumber=0,
00063                   const char *desc="None", const char *loc="Unknown");
00064   explicit ExceptionObject(const std::string& file, unsigned int lineNumber=0,
00065                   const std::string& desc="None",
00066                   const std::string& loc="Unknown");
00067   ExceptionObject( const ExceptionObject &orig );
00069 
00071   virtual ~ExceptionObject() throw();
00072 
00074   ExceptionObject &operator= ( const ExceptionObject &orig );
00075 
00077   virtual bool operator==( const ExceptionObject &orig );
00078 
00079   virtual const char *GetNameOfClass() const 
00080     {return "ExceptionObject";}
00081 
00086   virtual void Print(std::ostream& os) const;
00087 
00091   virtual void SetLocation(const std::string& s);
00092   virtual void SetDescription(const std::string& s);
00093   virtual void SetLocation(const char * s);
00094   virtual void SetDescription (const char *s);
00095   virtual const char *GetLocation()    const;
00096   virtual const char *GetDescription() const;
00098 
00100   virtual const char *GetFile()    const;
00101 
00103   virtual unsigned int GetLine() const;
00104 
00106   virtual const char* what() const throw();
00107 
00108 private:
00131   class ReferenceCounterInterface
00132   {
00133   public:
00134     virtual void Register() const = 0;
00135     virtual void UnRegister() const = 0;
00136     ReferenceCounterInterface() {};
00137     virtual ~ReferenceCounterInterface() {};
00138   };
00139   class ExceptionData;
00140   class ReferenceCountedExceptionData;
00141   SmartPointer<const ReferenceCounterInterface> m_ExceptionData;
00142   const ExceptionData * GetExceptionData() const;
00143 };
00145 
00147 inline std::ostream& operator<<(std::ostream& os, ExceptionObject &e)
00148 {
00149   (&e)->Print(os);
00150   return os;
00151 }
00153 
00162 class MemoryAllocationError : public ExceptionObject
00163 {
00164 public:
00167   MemoryAllocationError() : ExceptionObject() {}
00168 
00170   MemoryAllocationError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00171 
00173   MemoryAllocationError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00174 
00176   MemoryAllocationError(const std::string& file, unsigned int lineNumber, const std::string& desc, const std::string& loc) : ExceptionObject(file, lineNumber, desc, loc) {}  
00177 
00179   virtual ~MemoryAllocationError() throw() {}
00180 
00181   virtual const char* GetNameOfClass() const
00182     { return "MemoryAllocationError"; }
00183 };
00184 
00189 class RangeError : public ExceptionObject
00190 {
00191 public:
00194   RangeError() : ExceptionObject() {}
00195 
00197   RangeError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00198 
00200   RangeError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00201 
00203   virtual ~RangeError() throw() {}
00204 
00205   virtual const char *GetNameOfClass() const 
00206     {return "RangeError";}
00207 
00208 };
00209 
00215 class InvalidArgumentError : public ExceptionObject
00216 {
00217 public:
00222   InvalidArgumentError() : ExceptionObject() {}
00223 
00227   InvalidArgumentError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00228 
00232   InvalidArgumentError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00233 
00235   virtual ~InvalidArgumentError() throw() {}
00236 
00237   virtual const char *GetNameOfClass() const 
00238     {return "InvalidArgumentError";}
00239 };
00240 
00245 class IncompatibleOperandsError : public ExceptionObject
00246 {
00247 public:
00250   IncompatibleOperandsError() : ExceptionObject() {}
00251 
00253   IncompatibleOperandsError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00254 
00256   IncompatibleOperandsError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00257 
00259   virtual ~IncompatibleOperandsError() throw() {}
00260 
00261   virtual const char *GetNameOfClass() const 
00262     {return "IncompatibleOperandsError";}
00263 };
00264 
00269 class ProcessAborted : public ExceptionObject
00270 {
00271 public:
00274   ProcessAborted() : ExceptionObject() {
00275     this->SetDescription("Filter execution was aborted by an external request"); }
00276 
00278   ProcessAborted(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {
00279     this->SetDescription("Filter execution was aborted by an external request"); }
00280 
00282   ProcessAborted(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {  
00283     this->SetDescription("Filter execution was aborted by an external request"); }
00284 
00286   virtual ~ProcessAborted() throw() {}
00287 
00288   virtual const char *GetNameOfClass() const 
00289     {return "ProcessAborted";}
00290 
00291 };
00292 
00293 
00294 } // end namespace itk
00295 
00296 #endif
00297 
00298 #endif
00299 

Generated at Tue Jul 29 19:52:55 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000