OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / include / vtk / vtkCommunicator.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkCommunicator.h,v $
5   Language:  C++
6   Date:      $Date: 2002/05/17 01:50:34 $
7   Version:   $Revision: 1.16 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
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).
24
25 // .SECTION Caveats
26 // Communication between systems with different vtkIdTypes is not
27 // supported. All machines have to have the same vtkIdType.
28
29 // .SECTION see also
30 // vtkSharedMemoryCommunicator vtkMPICommunicator
31
32 #ifndef __vtkCommunicator_h
33 #define __vtkCommunicator_h
34
35 #include "vtkObject.h"
36
37 class vtkDataSet;
38 class vtkImageData;
39 class vtkDataObject;
40 class vtkDataArray;
41
42 class VTK_PARALLEL_EXPORT vtkCommunicator : public vtkObject
43 {
44
45 public:
46
47   vtkTypeRevisionMacro(vtkCommunicator, vtkObject);
48   void PrintSelf(ostream& os, vtkIndent indent);
49
50   // Description:
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);
55
56   // Description:
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);
61   
62   // Description:
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, 
66                    int tag) = 0;
67   virtual int Send(unsigned char* data, int length, int remoteHandle, 
68                    int tag) = 0;
69   virtual int Send(char* data, int length, int remoteHandle, 
70                    int tag) = 0;
71   virtual int Send(float* data, int length, int remoteHandle, 
72                    int tag) = 0;
73   virtual int Send(double* data, int length, int remoteHandle, 
74                    int tag) = 0;
75 #ifdef VTK_USE_64BIT_IDS
76   virtual int Send(vtkIdType* data, int length, int remoteHandle, 
77                    int tag) = 0;
78 #endif
79
80
81   // Description:
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);
85
86   // Description:
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);
90
91   // Description:
92   // Subclass have to supply these methods to receive various arrays of data.
93   virtual int Receive(int* data, int length, int remoteHandle, 
94                       int tag) = 0;
95   virtual int Receive(unsigned long* data, int length, int remoteHandle,
96                       int tag) = 0;
97   virtual int Receive(unsigned char* data, int length, int remoteHandle, 
98                       int tag) = 0;
99   virtual int Receive(char* data, int length, int remoteHandle, 
100                       int tag) = 0;
101   virtual int Receive(float* data, int length, int remoteHandle, 
102                       int tag) = 0;
103   virtual int Receive(double* data, int length, int remoteHandle, 
104                       int tag) = 0;
105 #ifdef VTK_USE_64BIT_IDS
106   virtual int Receive(vtkIdType* data, int length, int remoteHandle, 
107                       int tag) = 0;
108 #endif
109
110   static void SetUseCopy(int useCopy);
111
112 protected:
113
114   void DeleteAndSetMarshalString(char *str, int strLength);
115
116   // Write and read from marshal string
117   // return 1 success, 0 fail
118   int WriteObject(vtkDataObject *object);
119   int ReadObject(vtkDataObject *object);
120   
121   int WriteDataSet(vtkDataSet *object);
122   int ReadDataSet(vtkDataSet *object);
123
124   int WriteImageData(vtkImageData *object);
125   int ReadImageData(vtkImageData *object);
126
127   int WriteDataArray(vtkDataArray *object);
128   int ReadDataArray(vtkDataArray *object);
129
130   vtkCommunicator();
131   ~vtkCommunicator();
132
133   char *MarshalString;
134   int MarshalStringLength;
135   // The data may not take up all of the string.
136   int MarshalDataLength;
137
138   static int UseCopy;
139
140 private:
141   vtkCommunicator(const vtkCommunicator&);  // Not implemented.
142   void operator=(const vtkCommunicator&);  // Not implemented.
143 };
144
145 #endif // __vtkCommunicator_h
146
147