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-10-13 15:36:31 $
00007   Version:   $Revision: 1.40 $
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:
00133   class ReferenceCounterInterface
00134     {
00135     public:
00136       virtual void Register() const = 0;
00137       virtual void UnRegister() const = 0;
00138       ReferenceCounterInterface() {}
00139       virtual ~ReferenceCounterInterface() {}
00140     };
00141   class ExceptionData;
00142   class ReferenceCountedExceptionData;
00143   SmartPointer<const ReferenceCounterInterface> m_ExceptionData;
00144   const ExceptionData * GetExceptionData() const;
00145 };
00146 
00148 inline std::ostream& operator<<(std::ostream& os, ExceptionObject &e)
00149 {
00150   (&e)->Print(os);
00151   return os;
00152 }
00154 
00163 class MemoryAllocationError : public ExceptionObject
00164 {
00165 public:
00168   MemoryAllocationError() : ExceptionObject() {}
00169 
00171   MemoryAllocationError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00172 
00174   MemoryAllocationError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00175 
00177   MemoryAllocationError(const std::string& file, unsigned int lineNumber, const std::string& desc, const std::string& loc) : ExceptionObject(file, lineNumber, desc, loc) {}  
00178 
00180   virtual ~MemoryAllocationError() throw() {}
00181 
00182   virtual const char* GetNameOfClass() const
00183     { return "MemoryAllocationError"; }
00184 };
00185 
00190 class RangeError : public ExceptionObject
00191 {
00192 public:
00195   RangeError() : ExceptionObject() {}
00196 
00198   RangeError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00199 
00201   RangeError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00202 
00204   virtual ~RangeError() throw() {}
00205 
00206   virtual const char *GetNameOfClass() const 
00207     {return "RangeError";}
00208 
00209 };
00210 
00216 class InvalidArgumentError : public ExceptionObject
00217 {
00218 public:
00223   InvalidArgumentError() : ExceptionObject() {}
00224 
00228   InvalidArgumentError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00229 
00233   InvalidArgumentError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00234 
00236   virtual ~InvalidArgumentError() throw() {}
00237 
00238   virtual const char *GetNameOfClass() const 
00239     {return "InvalidArgumentError";}
00240 };
00241 
00246 class IncompatibleOperandsError : public ExceptionObject
00247 {
00248 public:
00251   IncompatibleOperandsError() : ExceptionObject() {}
00252 
00254   IncompatibleOperandsError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
00255 
00257   IncompatibleOperandsError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}  
00258 
00260   virtual ~IncompatibleOperandsError() throw() {}
00261 
00262   virtual const char *GetNameOfClass() const 
00263     {return "IncompatibleOperandsError";}
00264 };
00265 
00270 class ProcessAborted : public ExceptionObject
00271 {
00272 public:
00275   ProcessAborted() : ExceptionObject() {
00276     this->SetDescription("Filter execution was aborted by an external request"); }
00277 
00279   ProcessAborted(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {
00280     this->SetDescription("Filter execution was aborted by an external request"); }
00281 
00283   ProcessAborted(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {  
00284     this->SetDescription("Filter execution was aborted by an external request"); }
00285 
00287   virtual ~ProcessAborted() throw() {}
00288 
00289   virtual const char *GetNameOfClass() const 
00290     {return "ProcessAborted";}
00291 
00292 };
00293 
00294 
00295 } // end namespace itk
00296 
00297 #endif
00298 
00299 #endif
00300 

Generated at Thu May 28 09:52:46 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000