2001-10-06 14:13:28 +00:00
|
|
|
#ifndef CSOCKETINPUTSTREAM_H
|
|
|
|
#define CSOCKETINPUTSTREAM_H
|
|
|
|
|
|
|
|
#include "CSocketStreamBuffer.h"
|
|
|
|
#include "CCondVar.h"
|
|
|
|
#include "IInputStream.h"
|
|
|
|
|
|
|
|
class CMutex;
|
|
|
|
class IJob;
|
|
|
|
|
|
|
|
class CSocketInputStream : public IInputStream {
|
|
|
|
public:
|
|
|
|
CSocketInputStream(CMutex*, IJob* adoptedCloseCB);
|
|
|
|
~CSocketInputStream();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
// write() appends n bytes to the buffer
|
2001-10-14 16:58:01 +00:00
|
|
|
void write(const void*, UInt32 n);
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
// causes read() to always return immediately. if there is no
|
|
|
|
// more data then it returns 0. further writes are discarded.
|
2001-10-14 16:58:01 +00:00
|
|
|
void hangup();
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
|
|
|
// IInputStream overrides
|
|
|
|
// these all lock the mutex for their duration
|
2001-10-14 16:58:01 +00:00
|
|
|
virtual void close();
|
|
|
|
virtual UInt32 read(void*, UInt32 count);
|
|
|
|
virtual UInt32 getSize() const;
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CMutex* m_mutex;
|
|
|
|
CCondVar<bool> m_empty;
|
|
|
|
IJob* m_closeCB;
|
|
|
|
CSocketStreamBuffer m_buffer;
|
|
|
|
bool m_closed;
|
|
|
|
bool m_hungup;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|