Blame view

src/Common/DataExchangePipe.h 1.29 KB
e30d6793   Zou XiKun   v0.0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  #if !defined(AFX_DATAEXCHANGEPIPE_H__FAA2F47E_5211_449D_A351_7E40AABB57D7__INCLUDED_)
  #define AFX_DATAEXCHANGEPIPE_H__FAA2F47E_5211_449D_A351_7E40AABB57D7__INCLUDED_
  
  #include "BaseDataTypeDef.h"
  #include "BaseEvent.h"
  #include "BaseObject.h"
  
  #define DATA_EXCHANGE_BLOCK_SIZE					8192*1024
  
  typedef struct structDataExchangeBlock
  {
  	INT32 wDataLen;
  	BYTE lpData[DATA_EXCHANGE_BLOCK_SIZE];
  }DataExchangeBlock;
  
  class CDataExchangePipe : public CBaseObject
  {
  public:
  	CDataExchangePipe(long lDataBufferCount = 100);
  	virtual ~CDataExchangePipe();
  
  public:
  	BOOL MultiPut(void* pData, INT32 wDataLen, DWORD nTimeOut = 10, BOOL bNotifyImmediate = TRUE);
  	BOOL PutDataEx(void* pData, INT32 wDataLen, DWORD nTimeOut = 10, BOOL bNotifyImmediate = TRUE);
  	void ClearData();
  	DataExchangeBlock* GetDataExchangeBlock(DWORD nTimeOut = 10);
  
  protected:
  	void UnlockPut();
  	void LockPut();
  	BOOL PutData(void* pData, INT32 wDataLen, DWORD nTimeOut = 0, BOOL bNotifyImmediate = TRUE);
  
  public:
  	DataExchangeBlock** m_ppDataBuffers;
  	void* m_pBuffer;
  
  protected:
  	CBaseEvent m_DataArriveEvent;
  	CBaseEvent m_DataBufferAvailableEvent;
  	CBaseObject m_MultiPutObject;
  	long m_lDataBufferCount;
  	long m_lFirstIndex;
  	long m_lCurrentIndex;
  };
  
  #endif // !defined(AFX_DATAEXCHANGEPIPE_H__FAA2F47E_5211_449D_A351_7E40AABB57D7__INCLUDED_)