17 #include "vtkCommand.h"
18 #include "vtkCommunicator.h"
19 #include "vtkMultiProcessController.h"
20 #include "vtkObjectFactory.h"
25 this->Controller = controller;
28 this->Communicator = controller->GetCommunicator();
36 this->Communicator = communicator;
43 if (this->Communicator && this->CommunicatorObserverId)
45 this->Communicator->RemoveObserver(this->CommunicatorObserverId);
47 if (this->Controller && this->ControllerObserverId)
49 this->Controller->RemoveObserver(this->ControllerObserverId);
54 void vtkCommunicationErrorCatcher::Initialize()
56 this->ErrorsRaised =
false;
57 this->ControllerObserverId = 0;
58 this->CommunicatorObserverId = 0;
62 this->ControllerObserverId = this->Controller->AddObserver(
63 vtkCommand::ErrorEvent,
this, &vtkCommunicationErrorCatcher::OnErrorEvent);
65 if (this->Communicator)
67 this->CommunicatorObserverId = this->Communicator->AddObserver(
68 vtkCommand::ErrorEvent,
this, &vtkCommunicationErrorCatcher::OnErrorEvent);
73 void vtkCommunicationErrorCatcher::OnErrorEvent(
74 vtkObject* caller,
unsigned long eventid,
void* calldata)
76 if (caller && calldata && eventid == vtkCommand::ErrorEvent)
78 const char* error_message =
reinterpret_cast<const char*
>(calldata);
79 if (error_message && error_message[0])
81 this->ErrorMessages += error_message;
83 this->ErrorsRaised =
true;
virtual ~vtkCommunicationErrorCatcher()
vtkCommunicationErrorCatcher(vtkMultiProcessController *)