13 #include "wvstreamclone.h"
14 #include "wvmoniker.h"
17 #pragma warning(disable : 4073)
29 #if MUTATE_ISNT_BROKEN
30 return mutate<IWvStream>(_obj);
45 my_type(
"WvStreamClone:(none)")
77 if (cloned && !outbuf.
used())
98 if (stop_write && !outbuf.
used())
100 return cloned->
flush(msec_timeout);
115 len = cloned->read(buf, size);
116 if (len == 0 && !cloned->
isok())
130 return cloned->write(buf, size);
159 WvString WvStreamClone::errstr()
const
162 return WvStream::errstr();
164 return cloned->errstr();
165 return "No child stream!";
169 void WvStreamClone::close_callback()
192 if (newclone != NULL)
193 my_type =
WvString(
"WvStreamClone:%s", newclone->wstype());
195 my_type =
"WvStreamClone:(none)";
204 if (cloned && cloned->
isok())
206 if (!si.inherit_request)
208 si.wants.readable |=
static_cast<bool>(readcb);
209 si.wants.writable |=
static_cast<bool>(writecb);
210 si.wants.isexception |=
static_cast<bool>(exceptcb);
213 if (outbuf.
used() || autoclose_time)
214 si.wants.writable =
true;
216 cloned->pre_select(si);
228 bool val, want_write;
233 if (cloned && cloned->
isok())
235 if (!si.inherit_request)
237 si.wants.readable |=
static_cast<bool>(readcb);
238 si.wants.writable |=
static_cast<bool>(writecb);
239 si.wants.isexception |=
static_cast<bool>(exceptcb);
242 val = cloned->post_select(si);
243 want_write = si.wants.writable;
248 if (want_write && outbuf.
used())
257 return val || result;
267 return cloned->src();
275 if (cloned) cloned->callback();
278 WvString WvStreamClone::getattr(WvStringParm name)
const
280 WvString ret = WvStream::getattr(name);
281 if (ret.
isnull() && cloned)
282 return cloned->getattr(name);
WvStream * write_requires_readable
If this is set, select() doesn't return true for write unless the given stream also returns true for ...
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
virtual ~WvStreamClone()
The WvStreamClone destructor.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
WvStream * read_requires_writable
If this is set, select() doesn't return true for read unless the given stream also returns true for w...
virtual size_t uread(void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by read().
virtual void nowrite()=0
Shuts down the writing side of the stream.
virtual bool flush(time_t msec_timeout)
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
virtual void close()
Close this stream.
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
virtual size_t uwrite(const void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
virtual void close()
Close the stream if it is open; isok() becomes false from now on.
virtual void noread()
Shuts down the reading side of the stream.
WvString is an implementation of a simple and efficient printable-string class.
bool isnull() const
returns true if this string is null
void force_select(bool readable, bool writable, bool isexception=false)
Use force_select() to force one or more particular modes (readable, writable, or isexception) to true...
the data structure used by pre_select()/post_select() and internally by select().
virtual void nowrite()
Shuts down the writing side of the stream.
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
Base class for different address types, each of which will have the ability to convert itself to/from...
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
WvStreamClone simply forwards all requests to the "cloned" stream.
virtual void setclone(IWvStream *clone)
WvStreamClone takes ownership of the given stream; it will WVRELEASE() the stream when you setclone()...
virtual bool isok() const =0
By default, returns true if geterr() == 0.
virtual bool isok() const
return true if the stream is actually usable right now
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual const WvAddr * src() const
get the remote address from which the last data block was received.
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
A SelectRequest is a convenient way to remember what we want to do to a particular stream: read from ...
virtual bool isok() const
return true if the stream is actually usable right now
virtual bool should_flush()=0
Returns true if we want to flush the output buffer right now.
virtual IWvStreamCallback setclosecallback(IWvStreamCallback _callfunc)=0
Sets a callback to be invoked on close().
virtual void nowrite()
Shuts down the writing side of the stream.
size_t used() const
Returns the number of elements in the buffer currently available for reading.
virtual bool flush(time_t msec_timeout)=0
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
WvStreamClone(IWvStream *_cloned=NULL)
Constructs the stream, then calls setclone(_cloned).
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
virtual void noread()=0
Shuts down the reading side of the stream.
virtual void noread()
Shuts down the reading side of the stream.
bool stop_read
True if noread()/nowrite()/close() have been called, respectively.
virtual bool flush_internal(time_t msec_timeout)
WvStream overrides.