13#include "wvstreamclone.h"
17#pragma warning(disable : 4073)
45 my_type(
"WvStreamClone:(none)")
77 if (cloned && !outbuf.used())
87 cloned->setclosecallback(0);
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);
154 return cloned->geterr();
159WvString WvStreamClone::errstr()
const
162 return WvStream::errstr();
164 return cloned->errstr();
165 return "No child stream!";
169void WvStreamClone::close_callback()
184 cloned->setclosecallback(0);
189 cloned->setclosecallback(wv::bind(&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;
230 if (cloned && cloned->should_flush())
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();
278WvString WvStreamClone::getattr(WvStringParm name)
const
280 WvString ret = WvStream::getattr(name);
281 if (ret.
isnull() && cloned)
282 return cloned->getattr(name);
The basic interface which is included by all other XPLC interfaces and objects.
Base class for different address types, each of which will have the ability to convert itself to/from...
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
bool isnull() const
returns true if this string is null
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
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 ~WvStreamClone()
The WvStreamClone destructor.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
virtual void close()
Close this stream.
WvStreamClone(IWvStream *_cloned=NULL)
Constructs the stream, then calls setclone(_cloned).
virtual const WvAddr * src() const
get the remote address from which the last data block was received.
virtual bool isok() const
return true if the stream is actually usable right now
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual void noread()
Shuts down the reading side of the stream.
virtual void nowrite()
Shuts down the writing side of the stream.
virtual size_t uread(void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by read().
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
virtual bool flush_internal(time_t msec_timeout)
WvStream overrides.
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 execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
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 bool isok() const
return true if the stream is actually usable right now
virtual void nowrite()
Shuts down the writing side of the stream.
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...
bool stop_read
True if noread()/nowrite()/close() have been called, respectively.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
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 void close()
Close the stream if it is open; isok() becomes false from now on.
WvStream * write_requires_readable
If this is set, select() doesn't return true for write unless the given stream also returns true for ...
virtual void noread()
Shuts down the reading side of the stream.
WvString is an implementation of a simple and efficient printable-string class.
Interface * mutate(IObject *aObj)
A version of get() that releases its parameter.
the data structure used by pre_select()/post_select() and internally by select().
A SelectRequest is a convenient way to remember what we want to do to a particular stream: read from ...