/vol/vipdata/irtk/common++/include/irtkException.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkException.h 2 2008-12-23 12:40:14Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2008-12-23 12:40:14 +0000 (Tue, 23 Dec 2008) $
00008   Version   : $Revision: 2 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKEXCEPTION_H
00014 
00015 #define _IRTKEXCEPTION_H
00016 
00017 #include <string>
00018 
00019 #include <irtkObject.h>
00020 
00022 class irtkException : public irtkObject
00023 {
00024 public:
00032   irtkException(const std::string& message, const std::string& fileName = "",
00033                 unsigned int line = 0);
00034 
00036   const std::string& GetMessage() const;
00037 
00039   const std::string& GetFileName() const;
00040 
00042   unsigned int GetLine() const;
00043 
00047   friend std::ostream& operator<<(std::ostream& os, const irtkException& ex);
00048 
00049 protected:
00051   std::string _Message;
00052 
00054   std::string _FileName;
00055 
00057   unsigned int _Line;
00058 };
00059 
00060 inline irtkException::irtkException(const std::string& strMessage,
00061                                     const std::string& fileName, unsigned int line)
00062 {
00063   _Message = strMessage;
00064   _FileName = fileName;
00065   _Line = line;
00066 }
00067 
00068 inline const std::string& irtkException::GetMessage() const
00069 {
00070   return _Message;
00071 }
00072 
00073 inline const std::string& irtkException::GetFileName() const
00074 {
00075   return _FileName;
00076 }
00077 
00078 inline unsigned int irtkException::GetLine() const
00079 {
00080   return _Line;
00081 }
00082 
00083 #endif // _IRTKEXCEPTION_H
00084