2001-10-06 18:13:28 +04:00
|
|
|
#ifndef CSOCKETOUTPUTSTREAM_H
|
|
|
|
#define CSOCKETOUTPUTSTREAM_H
|
|
|
|
|
|
|
|
#include "CSocketStreamBuffer.h"
|
|
|
|
#include "IOutputStream.h"
|
|
|
|
|
|
|
|
class CMutex;
|
|
|
|
class IJob;
|
|
|
|
|
|
|
|
class CSocketOutputStream : public IOutputStream {
|
|
|
|
public:
|
|
|
|
CSocketOutputStream(CMutex*, IJob* adoptedCloseCB);
|
|
|
|
~CSocketOutputStream();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
|
|
|
// pop() discards the next n bytes.
|
2001-10-14 20:58:01 +04:00
|
|
|
const void* peek(UInt32 n);
|
|
|
|
void pop(UInt32 n);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
|
|
|
// return the number of bytes in the buffer
|
2001-10-14 20:58:01 +04:00
|
|
|
UInt32 getSize() const;
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// IOutputStream overrides
|
|
|
|
// these all lock the mutex for their duration
|
2001-10-14 20:58:01 +04:00
|
|
|
virtual void close();
|
|
|
|
virtual UInt32 write(const void*, UInt32 count);
|
|
|
|
virtual void flush();
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
private:
|
2001-10-14 20:58:01 +04:00
|
|
|
UInt32 getSizeWithLock() const;
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
CMutex* m_mutex;
|
|
|
|
IJob* m_closeCB;
|
|
|
|
CSocketStreamBuffer m_buffer;
|
|
|
|
bool m_closed;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|