Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Parallel/vtkSocketCommunicator.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkSocketCommunicator.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00040 #ifndef __vtkSocketCommunicator_h 00041 #define __vtkSocketCommunicator_h 00042 00043 #include "vtkCommunicator.h" 00044 00045 #include "vtkByteSwap.h" // Needed for vtkSwap macros 00046 00047 #ifdef VTK_WORDS_BIGENDIAN 00048 # define vtkSwap4 vtkByteSwap::Swap4LE 00049 # define vtkSwap4Range vtkByteSwap::Swap4LERange 00050 # define vtkSwap8 vtkByteSwap::Swap8LE 00051 # define vtkSwap8Range vtkByteSwap::Swap8LERange 00052 #else 00053 # define vtkSwap4 vtkByteSwap::Swap4BE 00054 # define vtkSwap4Range vtkByteSwap::Swap4BERange 00055 # define vtkSwap8 vtkByteSwap::Swap8BE 00056 # define vtkSwap8Range vtkByteSwap::Swap8BERange 00057 #endif 00058 00059 class VTK_PARALLEL_EXPORT vtkSocketCommunicator : public vtkCommunicator 00060 { 00061 public: 00062 static vtkSocketCommunicator *New(); 00063 vtkTypeRevisionMacro(vtkSocketCommunicator,vtkCommunicator); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00067 virtual int WaitForConnection(int port); 00068 00070 virtual void CloseConnection(); 00071 00073 virtual int ConnectTo( char* hostName, int port); 00074 00076 00077 vtkGetMacro(SwapBytesInReceivedData, int); 00079 00081 00082 vtkGetMacro(IsConnected, int); 00084 00085 //------------------ Communication -------------------- 00086 00088 00090 int Send(int *data, int length, int remoteProcessId, int tag); 00091 int Send(unsigned long *data, int length, int remoteProcessId, int tag); 00092 int Send(char *data, int length, int remoteProcessId, int tag); 00093 int Send(unsigned char *data, int length, int remoteProcessId, int tag); 00094 int Send(float *data, int length, int remoteProcessId, int tag); 00095 int Send(double *data, int length, int remoteProcessId, int tag); 00096 #ifdef VTK_USE_64BIT_IDS 00097 int Send(vtkIdType *data, int length, int remoteProcessId, int tag); 00099 #endif 00100 int Send(vtkDataObject *data, int remoteId, int tag) 00101 {return this->vtkCommunicator::Send(data,remoteId,tag);} 00102 int Send(vtkDataArray *data, int remoteId, int tag) 00103 {return this->vtkCommunicator::Send(data,remoteId,tag);} 00104 00106 00109 int Receive(int *data, int length, int remoteProcessId, int tag); 00110 int Receive(unsigned long *data, int length, int remoteProcessId, int tag); 00111 int Receive(char *data, int length, int remoteProcessId, int tag); 00112 int Receive(unsigned char *data, int length, int remoteProcessId, int tag); 00113 int Receive(float *data, int length, int remoteProcessId, int tag); 00114 int Receive(double *data, int length, int remoteProcessId, int tag); 00115 #ifdef VTK_USE_64BIT_IDS 00116 int Receive(vtkIdType *data, int length, int remoteProcessId, int tag); 00118 #endif 00119 int Receive(vtkDataObject *data, int remoteId, int tag) 00120 {return this->vtkCommunicator::Receive(data, remoteId, tag);} 00121 int Receive(vtkDataArray *data, int remoteId, int tag) 00122 {return this->vtkCommunicator::Receive(data, remoteId, tag);} 00123 00125 00127 vtkSetClampMacro(PerformHandshake, int, 0, 1); 00128 vtkBooleanMacro(PerformHandshake, int); 00129 vtkGetMacro(PerformHandshake, int); 00131 00134 int ReceiveMessage(char *data, int *length, int maxlength); 00135 00137 int SendMessage(const char *data, int length); 00138 00139 protected: 00140 00141 int Socket; 00142 int IsConnected; 00143 int NumberOfProcesses; 00144 int SwapBytesInReceivedData; 00145 int PerformHandshake; 00146 00147 vtkSocketCommunicator(); 00148 ~vtkSocketCommunicator(); 00149 00150 int ReceiveMessage(char *data, int size, int length, int tag ); 00151 00152 ofstream *TraceFile; 00153 00154 private: 00155 vtkSocketCommunicator(const vtkSocketCommunicator&); // Not implemented. 00156 void operator=(const vtkSocketCommunicator&); // Not implemented. 00157 }; 00158 00159 #endif