1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkCommunicator.h,v $
6 Date: $Date: 2002/05/17 01:50:34 $
7 Version: $Revision: 1.16 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkCommunicator - Used to send/receive messages in a multiprocess/thread environment.
19 // .SECTION Description
20 // This is an abstact class which contains functionality for sending
21 // and receiving inter-process messages. It contains methods for marshaling
22 // an object into a string (currently used by the MPI communicator but
23 // not the shared memory communicator).
26 // Communication between systems with different vtkIdTypes is not
27 // supported. All machines have to have the same vtkIdType.
30 // vtkSharedMemoryCommunicator vtkMPICommunicator
32 #ifndef __vtkCommunicator_h
33 #define __vtkCommunicator_h
35 #include "vtkObject.h"
42 class VTK_PARALLEL_EXPORT vtkCommunicator : public vtkObject
47 vtkTypeRevisionMacro(vtkCommunicator, vtkObject);
48 void PrintSelf(ostream& os, vtkIndent indent);
51 // This method sends a data object to a destination.
52 // Tag eliminates ambiguity
53 // and is used to match sends to receives.
54 virtual int Send(vtkDataObject* data, int remoteHandle, int tag);
57 // This method sends a data array to a destination.
58 // Tag eliminates ambiguity
59 // and is used to match sends to receives.
60 virtual int Send(vtkDataArray* data, int remoteHandle, int tag);
63 // Subclass have to supply these methods to send various arrays of data.
64 virtual int Send(int* data, int length, int remoteHandle, int tag) = 0;
65 virtual int Send(unsigned long* data, int length, int remoteHandle,
67 virtual int Send(unsigned char* data, int length, int remoteHandle,
69 virtual int Send(char* data, int length, int remoteHandle,
71 virtual int Send(float* data, int length, int remoteHandle,
73 virtual int Send(double* data, int length, int remoteHandle,
75 #ifdef VTK_USE_64BIT_IDS
76 virtual int Send(vtkIdType* data, int length, int remoteHandle,
82 // This method receives a data object from a corresponding send. It blocks
83 // until the receive is finished.
84 virtual int Receive(vtkDataObject* data, int remoteHandle, int tag);
87 // This method receives a data array from a corresponding send. It blocks
88 // until the receive is finished.
89 virtual int Receive(vtkDataArray* data, int remoteHandle, int tag);
92 // Subclass have to supply these methods to receive various arrays of data.
93 virtual int Receive(int* data, int length, int remoteHandle,
95 virtual int Receive(unsigned long* data, int length, int remoteHandle,
97 virtual int Receive(unsigned char* data, int length, int remoteHandle,
99 virtual int Receive(char* data, int length, int remoteHandle,
101 virtual int Receive(float* data, int length, int remoteHandle,
103 virtual int Receive(double* data, int length, int remoteHandle,
105 #ifdef VTK_USE_64BIT_IDS
106 virtual int Receive(vtkIdType* data, int length, int remoteHandle,
110 static void SetUseCopy(int useCopy);
114 void DeleteAndSetMarshalString(char *str, int strLength);
116 // Write and read from marshal string
117 // return 1 success, 0 fail
118 int WriteObject(vtkDataObject *object);
119 int ReadObject(vtkDataObject *object);
121 int WriteDataSet(vtkDataSet *object);
122 int ReadDataSet(vtkDataSet *object);
124 int WriteImageData(vtkImageData *object);
125 int ReadImageData(vtkImageData *object);
127 int WriteDataArray(vtkDataArray *object);
128 int ReadDataArray(vtkDataArray *object);
134 int MarshalStringLength;
135 // The data may not take up all of the string.
136 int MarshalDataLength;
141 vtkCommunicator(const vtkCommunicator&); // Not implemented.
142 void operator=(const vtkCommunicator&); // Not implemented.
145 #endif // __vtkCommunicator_h