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

# 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 =========================================================================*/
    00053 #ifndef __vtkSocketCommunicator_h
    00054 #define __vtkSocketCommunicator_h
    00055
    00056 #include "vtkCommunicator.h"
    00057
    00058 #include "vtkByteSwap.h" // Needed for vtkSwap macros
    00059
    00060 #ifdef VTK_WORDS_BIGENDIAN
    00061 # define vtkSwap4 vtkByteSwap::Swap4LE
    00062 # define vtkSwap4Range vtkByteSwap::Swap4LERange
    00063 # define vtkSwap8 vtkByteSwap::Swap8LE
    00064 # define vtkSwap8Range vtkByteSwap::Swap8LERange
    00065 #else
    00066 # define vtkSwap4 vtkByteSwap::Swap4BE
    00067 # define vtkSwap4Range vtkByteSwap::Swap4BERange
    00068 # define vtkSwap8 vtkByteSwap::Swap8BE
    00069 # define vtkSwap8Range vtkByteSwap::Swap8BERange
    00070 #endif
    00071
    00072 class VTK_PARALLEL_EXPORT vtkSocketCommunicator : public vtkCommunicator
    00073 {
    00074 public:
    00075   static vtkSocketCommunicator *New();
    00076   vtkTypeRevisionMacro(vtkSocketCommunicator,vtkCommunicator);
    00077   void PrintSelf(ostream& os, vtkIndent indent);
    00078
    00080   virtual int WaitForConnection(int port);
    00081
    00083   virtual void CloseConnection();
    00084
    00086   virtual int ConnectTo( char* hostName, int port);
    00087
    00089
    00090   vtkGetMacro(SwapBytesInReceivedData, int);
    00092
    00094
    00095   vtkGetMacro(IsConnected, int);
    00097
    00098   //------------------ Communication --------------------
    00099
    00101
    00103   int Send(int *data, int length, int remoteProcessId, int tag);
    00104   int Send(unsigned long *data, int length, int remoteProcessId, int tag);
    00105   int Send(char *data, int length, int remoteProcessId, int tag);
    00106   int Send(unsigned char *data, int length, int remoteProcessId, int tag);
    00107   int Send(float *data, int length, int remoteProcessId, int tag);
    00108   int Send(double *data, int length, int remoteProcessId, int tag);
    00109 #ifdef VTK_USE_64BIT_IDS
    00110   int Send(vtkIdType *data, int length, int remoteProcessId, int tag);
    00112 #endif
    00113   int Send(vtkDataObject *data, int remoteId, int tag)
    00114     {return this->vtkCommunicator::Send(data,remoteId,tag);}
    00115   int Send(vtkDataArray *data, int remoteId, int tag)
    00116     {return this->vtkCommunicator::Send(data,remoteId,tag);}
    00117
    00119
    00122   int Receive(int *data, int length, int remoteProcessId, int tag);
    00123   int Receive(unsigned long *data, int length, int remoteProcessId, int tag);
    00124   int Receive(char *data, int length, int remoteProcessId, int tag);
    00125   int Receive(unsigned char *data, int length, int remoteProcessId, int tag);
    00126   int Receive(float *data, int length, int remoteProcessId, int tag);
    00127   int Receive(double *data, int length, int remoteProcessId, int tag);
    00128 #ifdef VTK_USE_64BIT_IDS
    00129   int Receive(vtkIdType *data, int length, int remoteProcessId, int tag);
    00131 #endif
    00132   int Receive(vtkDataObject *data, int remoteId, int tag)
    00133     {return this->vtkCommunicator::Receive(data, remoteId, tag);}
    00134   int Receive(vtkDataArray *data, int remoteId, int tag)
    00135     {return this->vtkCommunicator::Receive(data, remoteId, tag);}
    00136
    00138
    00140   vtkSetClampMacro(PerformHandshake, int, 0, 1);
    00141   vtkBooleanMacro(PerformHandshake, int);
    00142   vtkGetMacro(PerformHandshake, int);
    00144
    00147   int ReceiveMessage(char *data, int *length, int maxlength);
    00148
    00150   int SendMessage(const char *data, int length);
    00151
    00152 protected:
    00153
    00154   int Socket;
    00155   int IsConnected;
    00156   int NumberOfProcesses;
    00157   int SwapBytesInReceivedData;
    00158   int PerformHandshake;
    00159
    00160   vtkSocketCommunicator();
    00161   ~vtkSocketCommunicator();
    00162
    00163   int ReceiveMessage(char *data, int size, int length, int tag );
    00164
    00165   ofstream *TraceFile;
    00166
    00167 private:
    00168   vtkSocketCommunicator(const vtkSocketCommunicator&);  // Not implemented.
    00169   void operator=(const vtkSocketCommunicator&);  // Not implemented.
    00170 };
    00171
    00172 #endif