VTK
vtkTestErrorObserver.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: TestErrorObserver.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #ifndef vtkTestErrorObserver_h
16 #define vtkTestErrorObserver_h
17 
18 #include <vtkCommand.h>
19 #include <string> // Needed for std::string
20 
21 namespace vtkTest
22 {
24 {
25 public:
26  vtkTypeMacro(ErrorObserver, vtkCommand);
27 
29  Error(false),
30  Warning(false),
31  ErrorMessage(""),
32  WarningMessage("") {}
33  static ErrorObserver *New()
34  {
35  return new ErrorObserver;
36  }
37  bool GetError() const
38  {
39  return this->Error;
40  }
41  bool GetWarning() const
42  {
43  return this->Warning;
44  }
45  void Clear()
46  {
47  this->Error = false;
48  this->Warning = false;
49  this->ErrorMessage = "";
50  this->WarningMessage = "";
51  }
52  virtual void Execute(vtkObject *vtkNotUsed(caller),
53  unsigned long event,
54  void *calldata)
55  {
56  switch(event)
57  {
58  case vtkCommand::ErrorEvent:
59  ErrorMessage += static_cast<char *>(calldata);
60  this->Error = true;
61  break;
62  case vtkCommand::WarningEvent:
63  WarningMessage += static_cast<char *>(calldata);
64  this->Warning = true;
65  break;
66  }
67  }
69  {
70  return ErrorMessage;
71  }
73  {
74  return WarningMessage;
75  }
76 private:
77  bool Error;
78  bool Warning;
79  std::string ErrorMessage;
80  std::string WarningMessage;
81 };
82 }
83 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Execute(vtkObject *vtkNotUsed(caller), unsigned long event, void *calldata)
superclass for callback/observer methods
Definition: vtkCommand.h:328
static ErrorObserver * New()