cnamedpipecomm.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __CNAMEDPIPECOMM_H__
00025 #define __CNAMEDPIPECOMM_H__
00026
00027
00028 #include <stdio.h>
00029 #include <deque>
00030 #include "simutil.h"
00031 #include "opp_string.h"
00032 #include "cparsimcomm.h"
00033 #include "platdep/platmisc.h"
00034
00035
00036 #if defined(_WIN32)
00037 #define USE_WINDOWS_PIPES
00038 #endif
00039
00040 NAMESPACE_BEGIN
00041
00042 #ifdef USE_WINDOWS_PIPES
00043 typedef HANDLE PIPE;
00044 #else
00045 typedef int PIPE;
00046 #endif
00047
00048
00056 class SIM_API cNamedPipeCommunications : public cParsimCommunications
00057 {
00058 protected:
00059 int numPartitions;
00060 int myProcId;
00061
00062
00063 opp_string prefix;
00064 PIPE *rpipes;
00065 PIPE *wpipes;
00066 int maxFdPlus1;
00067 int rrBase;
00068
00069
00070 std::deque<cCommBuffer*> storedBuffers;
00071
00072 protected:
00073
00074 bool receive(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId, bool blocking);
00075 bool doReceive(cCommBuffer *buffer, int& receivedTag, int& sourceProcId, bool blocking);
00076
00077 public:
00081 cNamedPipeCommunications();
00082
00086 virtual ~cNamedPipeCommunications();
00087
00093 virtual void init();
00094
00098 virtual void shutdown();
00099
00103 virtual int getNumPartitions() const;
00104
00108 virtual int getProcId() const;
00109
00113 virtual cCommBuffer *createCommBuffer();
00114
00118 virtual void recycleCommBuffer(cCommBuffer *buffer);
00119
00123 virtual void send(cCommBuffer *buffer, int tag, int destination);
00124
00129 virtual bool receiveBlocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId);
00130
00136 virtual bool receiveNonblocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId);
00138 };
00139
00140 NAMESPACE_END
00141
00142
00143 #endif
00144
00145