VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: TestErrorObserver.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 #ifndef __vtkTestErrorObserver_h 00016 #define __vtkTestErrorObserver_h 00017 00018 #include <vtkCommand.h> 00019 #include <string> 00020 00021 namespace vtkTest 00022 { 00023 class ErrorObserver : public ::vtkCommand 00024 { 00025 public: 00026 ErrorObserver(): 00027 Error(false), 00028 Warning(false), 00029 ErrorMessage(""), 00030 WarningMessage("") {} 00031 static ErrorObserver *New() 00032 { 00033 return new ErrorObserver; 00034 } 00035 bool GetError() const 00036 { 00037 return this->Error; 00038 } 00039 bool GetWarning() const 00040 { 00041 return this->Warning; 00042 } 00043 void Clear() 00044 { 00045 this->Error = false; 00046 this->Warning = false; 00047 this->ErrorMessage = ""; 00048 this->WarningMessage = ""; 00049 } 00050 virtual void Execute(vtkObject *vtkNotUsed(caller), 00051 unsigned long event, 00052 void *calldata) 00053 { 00054 switch(event) 00055 { 00056 case vtkCommand::ErrorEvent: 00057 ErrorMessage = static_cast<char *>(calldata); 00058 this->Error = true; 00059 break; 00060 case vtkCommand::WarningEvent: 00061 WarningMessage = static_cast<char *>(calldata); 00062 this->Warning = true; 00063 break; 00064 } 00065 } 00066 std::string GetErrorMessage() 00067 { 00068 return ErrorMessage; 00069 } 00070 std::string GetWarningMessage() 00071 { 00072 return WarningMessage; 00073 } 00074 private: 00075 bool Error; 00076 bool Warning; 00077 std::string ErrorMessage; 00078 std::string WarningMessage; 00079 }; 00080 } 00081 #endif