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-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00008 All rights reserved.
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013  * Redistributions of source code must retain the above copyright notice,
00014    this list of conditions and the following disclaimer.
00015 
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019 
00020  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00021    of any contributors may be used to endorse or promote products derived
00022    from this software without specific prior written permission.
00023 
00024  * Modified source versions must be plainly marked as such, and must not be
00025    misrepresented as being the original software.
00026 
00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00028 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00033 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00034 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00035 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 
00038 =========================================================================*/
00063 #ifndef __vtkSocketCommunicator_h
00064 #define __vtkSocketCommunicator_h
00065 
00066 #if defined(_WIN32) && !defined(__CYGWIN__)
00067 #include <winsock2.h>
00068 #else
00069 #include <sys/types.h>
00070 #include <sys/socket.h>
00071 #include <netinet/in.h>
00072 #include <arpa/inet.h>
00073 #include <netdb.h>
00074 #include <unistd.h>
00075 #endif
00076 
00077 #include "vtkObject.h"
00078 #include "vtkByteSwap.h"
00079 #include "vtkCommunicator.h"
00080 
00081 #ifdef VTK_WORDS_BIGENDIAN
00082 # define vtkSwap4 vtkByteSwap::Swap4LE
00083 # define vtkSwap4Range vtkByteSwap::Swap4LERange
00084 # define vtkSwap8 vtkByteSwap::Swap8LE
00085 # define vtkSwap8Range vtkByteSwap::Swap8LERange
00086 #else
00087 # define vtkSwap4 vtkByteSwap::Swap4BE
00088 # define vtkSwap4Range vtkByteSwap::Swap4BERange
00089 # define vtkSwap8 vtkByteSwap::Swap8BE
00090 # define vtkSwap8Range vtkByteSwap::Swap8BERange
00091 #endif
00092 
00093 class VTK_PARALLEL_EXPORT vtkSocketCommunicator : public vtkCommunicator
00094 {
00095 public:
00096   static vtkSocketCommunicator *New();
00097   vtkTypeMacro(vtkSocketCommunicator,vtkCommunicator);
00098   void PrintSelf(ostream& os, vtkIndent indent);
00099 
00101   virtual int WaitForConnection(int port);
00102 
00104   virtual void CloseConnection();
00105 
00107   virtual int ConnectTo( char* hostName, int port);
00108 
00110 
00111   vtkGetMacro(SwapBytesInReceivedData, int);
00113 
00115 
00116   vtkGetMacro(IsConnected, int);
00118 
00119   //------------------ Communication --------------------
00120   
00122 
00124   int Send(int *data, int length, int remoteProcessId, int tag);
00125   int Send(unsigned long *data, int length, int remoteProcessId, int tag);
00126   int Send(char *data, int length, int remoteProcessId, int tag);
00127   int Send(unsigned char *data, int length, int remoteProcessId, int tag);
00128   int Send(float *data, int length, int remoteProcessId, int tag);
00129   int Send(double *data, int length, int remoteProcessId, int tag);
00130 #ifdef VTK_USE_64BIT_IDS
00131   int Send(vtkIdType *data, int length, int remoteProcessId, int tag);
00133 #endif
00134   int Send(vtkDataObject *data, int remoteId, int tag)
00135     {return this->vtkCommunicator::Send(data,remoteId,tag);}
00136   int Send(vtkDataArray *data, int remoteId, int tag)
00137     {return this->vtkCommunicator::Send(data,remoteId,tag);}
00138 
00140 
00143   int Receive(int *data, int length, int remoteProcessId, int tag);
00144   int Receive(unsigned long *data, int length, int remoteProcessId, int tag);
00145   int Receive(char *data, int length, int remoteProcessId, int tag);
00146   int Receive(unsigned char *data, int length, int remoteProcessId, int tag);
00147   int Receive(float *data, int length, int remoteProcessId, int tag);
00148   int Receive(double *data, int length, int remoteProcessId, int tag);
00149 #ifdef VTK_USE_64BIT_IDS
00150   int Receive(vtkIdType *data, int length, int remoteProcessId, int tag);
00152 #endif
00153   int Receive(vtkDataObject *data, int remoteId, int tag)
00154     {return this->vtkCommunicator::Receive(data, remoteId, tag);}
00155   int Receive(vtkDataArray *data, int remoteId, int tag)
00156     {return this->vtkCommunicator::Receive(data, remoteId, tag);}
00157 
00158 protected:
00159 
00160   int Socket;
00161   int IsConnected;
00162   int NumberOfProcesses;
00163   int SwapBytesInReceivedData;
00164 
00165   vtkSocketCommunicator();
00166   ~vtkSocketCommunicator();
00167 
00168   int ReceiveMessage(char *data, int size, int length, int tag );
00169 private:
00170   vtkSocketCommunicator(const vtkSocketCommunicator&);  // Not implemented.
00171   void operator=(const vtkSocketCommunicator&);  // Not implemented.
00172 };
00173 
00174 #endif

Generated on Thu Mar 28 14:19:30 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001