wvbufstream.cc

00001 /*
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  * 
00005  * WvBufStream stores data written by write(), and returns it in read().
00006  * 
00007  * See wvbufstream.h.
00008  */ 
00009 #include "wvbufstream.h"
00010 
00011 
00012 WvBufStream::WvBufStream()
00013 {
00014     dead = eof = false; 
00015     death_notify = NULL;
00016 }
00017 
00018 
00019 WvBufStream::~WvBufStream()
00020 {
00021     close();
00022 }
00023 
00024 
00025 void WvBufStream::close()
00026 {
00027     dead = true; 
00028     if (death_notify)
00029         *death_notify = NULL;
00030     death_notify = NULL;
00031     WvStream::close();
00032 }
00033 
00034 
00035 // if uread() is called, someone has already exhausted inbuf... so now it's
00036 // time to close our stream so they know they're at EOF.
00037 size_t WvBufStream::uread(void *buf, size_t size)
00038 {
00039     if (eof)
00040         close();
00041     return 0; 
00042 }
00043 
00044 
00045 size_t WvBufStream::uwrite(const void *buf, size_t size)
00046 {
00047     inbuf.put(buf, size);
00048     return size;
00049 }
00050 
00051 
00052 bool WvBufStream::isok() const
00053 {
00054     return !dead;
00055 }
00056 
00057 
00058 void WvBufStream::pre_select(SelectInfo &si)
00059 {
00060     WvStream::pre_select(si);
00061 
00062     if (si.wants.writable || eof)
00063         si.msec_timeout = 0;
00064 }
00065 
00066 
00067 bool WvBufStream::post_select(SelectInfo &si)
00068 {
00069     return WvStream::post_select(si) || si.wants.writable || eof;
00070 }

Generated on Thu Jan 24 16:50:55 2008 for WvStreams by  doxygen 1.5.4