Orfeo Toolbox  3.16
itkExceptionObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkExceptionObject.h,v $
5  Language: C++
6  Date: $Date: 2008-10-13 15:36:31 $
7  Version: $Revision: 1.40 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 // itkExceptionObject.h is normally included through itkMacro.h, but
18 // some code includes it directly.
19 #ifndef __itkMacro_h
20 #include "itkMacro.h"
21 #else
22 
23 #ifndef __itkExceptionObject_h
24 #define __itkExceptionObject_h
25 
26 #include <string>
27 #include <stdexcept>
28 
29 #include "itkSmartPointer.h"
30 #include "itkWin32Header.h"
31 
32 
33 namespace itk
34 {
35 
54 class ITKCommon_EXPORT ExceptionObject : public std::exception
55 {
56 public:
57  typedef std::exception Superclass;
62  explicit ExceptionObject(const char *file, unsigned int lineNumber=0,
63  const char *desc="None", const char *loc="Unknown");
64  explicit ExceptionObject(const std::string& file, unsigned int lineNumber=0,
65  const std::string& desc="None",
66  const std::string& loc="Unknown");
67  ExceptionObject( const ExceptionObject &orig );
68 
70  virtual ~ExceptionObject() throw();
71 
73  ExceptionObject &operator= ( const ExceptionObject &orig );
74 
76  virtual bool operator==( const ExceptionObject &orig );
77 
78  virtual const char *GetNameOfClass() const
79  {return "ExceptionObject";}
80 
85  virtual void Print(std::ostream& os) const;
86 
90  virtual void SetLocation(const std::string& s);
91  virtual void SetDescription(const std::string& s);
92  virtual void SetLocation(const char * s);
93  virtual void SetDescription (const char *s);
94  virtual const char *GetLocation() const;
95  virtual const char *GetDescription() const;
96 
98  virtual const char *GetFile() const;
99 
101  virtual unsigned int GetLine() const;
102 
104  virtual const char* what() const throw();
105 
106 private:
132  {
133  public:
134  virtual void Register() const = 0;
135  virtual void UnRegister() const = 0;
138  };
139  class ExceptionData;
142  const ExceptionData * GetExceptionData() const;
143 };
144 
146 inline std::ostream& operator<<(std::ostream& os, ExceptionObject &e)
147 {
148  (&e)->Print(os);
149  return os;
150 }
151 
161 {
162 public:
166 
168  MemoryAllocationError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
169 
171  MemoryAllocationError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
172 
174  MemoryAllocationError(const std::string& file, unsigned int lineNumber, const std::string& desc, const std::string& loc) : ExceptionObject(file, lineNumber, desc, loc) {}
175 
177  virtual ~MemoryAllocationError() throw() {}
178 
179  virtual const char* GetNameOfClass() const
180  { return "MemoryAllocationError"; }
181 };
182 
188 {
189 public:
193 
195  RangeError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
196 
198  RangeError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
199 
201  virtual ~RangeError() throw() {}
202 
203  virtual const char *GetNameOfClass() const
204  {return "RangeError";}
205 
206 };
207 
214 {
215 public:
221 
225  InvalidArgumentError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
226 
230  InvalidArgumentError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
231 
233  virtual ~InvalidArgumentError() throw() {}
234 
235  virtual const char *GetNameOfClass() const
236  {return "InvalidArgumentError";}
237 };
238 
244 {
245 public:
249 
251  IncompatibleOperandsError(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
252 
254  IncompatibleOperandsError(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {}
255 
257  virtual ~IncompatibleOperandsError() throw() {}
258 
259  virtual const char *GetNameOfClass() const
260  {return "IncompatibleOperandsError";}
261 };
262 
268 {
269 public:
273  this->SetDescription("Filter execution was aborted by an external request"); }
274 
276  ProcessAborted(const char *file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {
277  this->SetDescription("Filter execution was aborted by an external request"); }
278 
280  ProcessAborted(const std::string& file, unsigned int lineNumber) : ExceptionObject(file, lineNumber) {
281  this->SetDescription("Filter execution was aborted by an external request"); }
282 
284  virtual ~ProcessAborted() throw() {}
285 
286  virtual const char *GetNameOfClass() const
287  {return "ProcessAborted";}
288 
289 };
290 
291 
292 } // end namespace itk
293 
294 #endif
295 
296 #endif

Generated at Sat Feb 2 2013 23:36:04 for Orfeo Toolbox with doxygen 1.8.1.1