1 // StreamBinder.h 2 3 #ifndef __STREAMBINDER_H 4 #define __STREAMBINDER_H 5 6 #include "../IStream.h" 7 #include "../../Windows/Synchronization.h" 8 9 class CStreamBinder 10 { 11 NWindows::NSynchronization::CManualResetEventWFMO _allBytesAreWritenEvent; 12 NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent; 13 NWindows::NSynchronization::CManualResetEventWFMO _readStreamIsClosedEvent; 14 NWindows::NSynchronization::CSynchro * _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent; 15 UInt32 _bufferSize; 16 const void *_buffer; 17 public: 18 // bool ReadingWasClosed; 19 UInt64 ProcessedSize; CStreamBinder()20 CStreamBinder() { _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent = 0; } ~CStreamBinder()21 ~CStreamBinder() { 22 if (_synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent) 23 delete _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent; 24 _synchroFor_allBytesAreWritenEvent_and_readStreamIsClosedEvent = 0; 25 } 26 HRes CreateEvents(); 27 28 void CreateStreams(ISequentialInStream **inStream, 29 ISequentialOutStream **outStream); 30 HRESULT Read(void *data, UInt32 size, UInt32 *processedSize); 31 void CloseRead(); 32 33 HRESULT Write(const void *data, UInt32 size, UInt32 *processedSize); 34 void CloseWrite(); 35 void ReInit(); 36 }; 37 38 #endif 39