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>
20 
21 namespace vtkTest
22 {
24 {
25 public:
27  Error(false),
28  Warning(false),
29  ErrorMessage(""),
30  WarningMessage("") {}
31  static ErrorObserver *New()
32  {
33  return new ErrorObserver;
34  }
35  bool GetError() const
36  {
37  return this->Error;
38  }
39  bool GetWarning() const
40  {
41  return this->Warning;
42  }
43  void Clear()
44  {
45  this->Error = false;
46  this->Warning = false;
47  this->ErrorMessage = "";
48  this->WarningMessage = "";
49  }
50  virtual void Execute(vtkObject *vtkNotUsed(caller),
51  unsigned long event,
52  void *calldata)
53  {
54  switch(event)
55  {
56  case vtkCommand::ErrorEvent:
57  ErrorMessage += static_cast<char *>(calldata);
58  this->Error = true;
59  break;
60  case vtkCommand::WarningEvent:
61  WarningMessage += static_cast<char *>(calldata);
62  this->Warning = true;
63  break;
64  }
65  }
67  {
68  return ErrorMessage;
69  }
71  {
72  return WarningMessage;
73  }
74 private:
75  bool Error;
76  bool Warning;
77  std::string ErrorMessage;
78  std::string WarningMessage;
79 };
80 }
81 #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:325
static ErrorObserver * New()