Orfeo Toolbox  4.0
itkExceptionObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkMacro_h
19 #error "Do not include itkExceptionObject.h directly, include itkMacro.h instead."
20 #else // __itkMacro.h
21 
22 #ifndef __itkExceptionObject_h
23 #define __itkExceptionObject_h
24 
25 #include <string>
26 #include <stdexcept>
27 
28 #include "itkSmartPointer.h"
29 
30 namespace itk
31 {
51 class ITKCommon_EXPORT ExceptionObject:public std::exception
52 {
53 public:
54  typedef std::exception Superclass;
59  explicit ExceptionObject(const char *file, unsigned int lineNumber = 0,
60  const char *desc = "None", const char *loc = "Unknown");
61  explicit ExceptionObject(const std::string & file, unsigned int lineNumber = 0,
62  const std::string & desc = "None",
63  const std::string & loc = "Unknown");
64  ExceptionObject(const ExceptionObject & orig);
65 
67  virtual ~ExceptionObject()
68  throw( );
69 
71  ExceptionObject & operator=(const ExceptionObject & orig);
72 
74  virtual bool operator==(const ExceptionObject & orig);
75 
76  virtual const char * GetNameOfClass() const
77  { return "ExceptionObject"; }
78 
83  virtual void Print(std::ostream & os) const;
84 
88  virtual void SetLocation(const std::string & s);
89 
90  virtual void SetDescription(const std::string & s);
91 
92  virtual void SetLocation(const char *s);
93 
94  virtual void SetDescription(const char *s);
95 
96  virtual const char * GetLocation() const;
97 
98  virtual const char * GetDescription() const;
99 
101  virtual const char * GetFile() const;
102 
104  virtual unsigned int GetLine() const;
105 
107  virtual const char * what() const
108  throw( );
109 
110 private:
137  {
138 public:
139  virtual void Register() const = 0;
140 
141  virtual void UnRegister() const = 0;
142 
145  };
146  class ExceptionData;
149  const ExceptionData * GetExceptionData() const;
150 };
151 
153 inline std::ostream & operator<<(std::ostream & os, ExceptionObject & e)
154 {
155  ( &e )->Print(os);
156  return os;
157 }
158 
169 {
170 public:
174 
176  MemoryAllocationError(const char *file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
177 
179  MemoryAllocationError(const std::string & file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
180 
182  MemoryAllocationError(const std::string & file,
183  unsigned int lineNumber,
184  const std::string & desc,
185  const std::string & loc):ExceptionObject(file, lineNumber, desc, loc) {}
186 
189  throw( ) {}
190 
191  virtual const char * GetNameOfClass() const
192  { return "MemoryAllocationError"; }
193 };
194 
201 {
202 public:
206 
208  RangeError(const char *file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
209 
211  RangeError(const std::string & file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
212 
214  virtual ~RangeError()
215  throw( ) {}
216 
217  virtual const char * GetNameOfClass() const
218  { return "RangeError"; }
219 };
220 
228 {
229 public:
235 
239  InvalidArgumentError(const char *file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
240 
244  InvalidArgumentError(const std::string & file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
245 
248  throw( ) {}
249 
250  virtual const char * GetNameOfClass() const
251  { return "InvalidArgumentError"; }
252 };
253 
260 {
261 public:
265 
267  IncompatibleOperandsError(const char *file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
268 
270  IncompatibleOperandsError(const std::string & file, unsigned int lineNumber):ExceptionObject(file, lineNumber) {}
271 
274  throw( ) {}
275 
276  virtual const char * GetNameOfClass() const
277  { return "IncompatibleOperandsError"; }
278 };
279 
286 {
287 public:
291  {
292  this->SetDescription("Filter execution was aborted by an external request");
293  }
294 
296  ProcessAborted(const char *file, unsigned int lineNumber):ExceptionObject(file, lineNumber)
297  {
298  this->SetDescription("Filter execution was aborted by an external request");
299  }
300 
302  ProcessAborted(const std::string & file, unsigned int lineNumber):ExceptionObject(file, lineNumber)
303  {
304  this->SetDescription("Filter execution was aborted by an external request");
305  }
306 
308  virtual ~ProcessAborted()
309  throw( ) {}
310 
311  virtual const char * GetNameOfClass() const
312  { return "ProcessAborted"; }
313 };
314 } // end namespace itk
315 
316 #endif //__itkExceptionObject_h
317 
318 #endif //__itkMacro_h

Generated at Sat Mar 8 2014 14:35:02 for Orfeo Toolbox with doxygen 1.8.3.1