Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

WvFileWatcher Class Reference

#include <wvwatcher.h>

Inheritance diagram for WvFileWatcher:

WvFile WvFile WvStream WvStream WvStream WvStream List of all members.

Public Methods

 WvFileWatcher (const char *_filename, int _mode)
virtual bool isok () const
virtual size_t uread (void *buf, size_t size)
virtual size_t uwrite (const void *buf, size_t size)
virtual bool pre_select (SelectInfo &si)
 WvFileWatcher (const char *_filename, int _mode)
virtual bool isok () const
virtual size_t uread (void *buf, size_t size)
virtual size_t uwrite (const void *buf, size_t size)
virtual bool pre_select (SelectInfo &si)

Protected Methods

bool make_ok (bool retry)
bool make_ok (bool retry)

Private Attributes

WvString filename
int openmode
bool once_ok
stat last_st
off_t fpos
stat last_st

Detailed Description

The WvFileWatcher class provides support for files which sometimes have data appended at the end. It only polls as often as your select() delay, so be careful!

The file is rewound and reopened if its inode changes or its length gets shorter, under the assumption that we will want to see the entire contents of the new file.

Definition at line 22 of file include/wvwatcher.h.


Constructor & Destructor Documentation

WvFileWatcher::WvFileWatcher const char *    _filename,
int    _mode
 

Definition at line 19 of file wvwatcher.cc.

References WvStream::close(), WvStream::errnum, filename, fpos, WvStream::isok(), last_st, once_ok, and openmode.

WvFileWatcher::WvFileWatcher const char *    _filename,
int    _mode
 


Member Function Documentation

virtual bool WvFileWatcher::isok   const [virtual]
 

return true if the stream is actually usable right now

Reimplemented from WvStream.

bool WvFileWatcher::isok   const [virtual]
 

return true if the stream is actually usable right now

Reimplemented from WvStream.

Definition at line 34 of file wvwatcher.cc.

References once_ok.

bool WvFileWatcher::make_ok bool    retry [protected]
 

bool WvFileWatcher::make_ok bool    retry [protected]
 

Definition at line 40 of file wvwatcher.cc.

References WvStream::close(), filename, fpos, WvStream::getrfd(), WvStream::isok(), last_st, WvFile::open(), and openmode.

Referenced by pre_select(), and uwrite().

virtual bool WvFileWatcher::pre_select SelectInfo &    si [virtual]
 

pre_select() sets up for eventually calling select(). It adds the right fds to the read, write, and except lists in the SelectInfo struct.

Returns true if we already know this stream is ready, and there's no need to actually do a real select(). Some streams, such as timers, can be implemented by _only_ either returning true or false here after doing a calculation, and never actually adding anything to the SelectInfo.

You can add your stream to any of the lists even if readable, writable, or isexception isn't set. This is what force_select() does. You can also choose not to add yourself to the list if you know it would be useless right now.

pre_select() is only called if isok() is true.

pre_select() is allowed to reduce msec_timeout (or change it if it's -1). However, it's not allowed to _increase_ msec_timeout.

Reimplemented from WvStream.

bool WvFileWatcher::pre_select SelectInfo &    si [virtual]
 

pre_select() sets up for eventually calling select(). It adds the right fds to the read, write, and except lists in the SelectInfo struct.

Returns true if we already know this stream is ready, and there's no need to actually do a real select(). Some streams, such as timers, can be implemented by _only_ either returning true or false here after doing a calculation, and never actually adding anything to the SelectInfo.

You can add your stream to any of the lists even if readable, writable, or isexception isn't set. This is what force_select() does. You can also choose not to add yourself to the list if you know it would be useless right now.

pre_select() is only called if isok() is true.

pre_select() is allowed to reduce msec_timeout (or change it if it's -1). However, it's not allowed to _increase_ msec_timeout.

Reimplemented from WvStream.

Definition at line 99 of file wvwatcher.cc.

References fpos, WvStream::getrfd(), last_st, make_ok(), and once_ok.

virtual size_t WvFileWatcher::uread void *    buf,
size_t    size
[virtual]
 

unbuffered I/O functions; these ignore the buffer, which is handled by read(). Don't call these functions unless you have a _really_ good reason.

Reimplemented from WvStream.

size_t WvFileWatcher::uread void *    buf,
size_t    size
[virtual]
 

unbuffered I/O functions; these ignore the buffer, which is handled by read(). Don't call these functions unless you have a _really_ good reason.

Reimplemented from WvStream.

Definition at line 67 of file wvwatcher.cc.

References fpos, once_ok, WvStream::select(), size, and WvStream::uread().

virtual size_t WvFileWatcher::uwrite const void *    buf,
size_t    size
[virtual]
 

unbuffered I/O functions; these ignore the buffer, which is handled by write(). Don't call these functions unless you have a _really_ good reason.

Reimplemented from WvStream.

size_t WvFileWatcher::uwrite const void *    buf,
size_t    size
[virtual]
 

unbuffered I/O functions; these ignore the buffer, which is handled by write(). Don't call these functions unless you have a _really_ good reason.

Reimplemented from WvStream.

Definition at line 83 of file wvwatcher.cc.

References fpos, make_ok(), once_ok, size, and WvStream::uwrite().


Member Data Documentation

WvString WvFileWatcher::filename [private]
 

Definition at line 24 of file streams/wvwatcher.h.

Referenced by make_ok(), and WvFileWatcher().

off_t WvFileWatcher::fpos [private]
 

Definition at line 28 of file streams/wvwatcher.h.

Referenced by make_ok(), pre_select(), uread(), uwrite(), and WvFileWatcher().

struct stat WvFileWatcher::last_st [private]
 

Definition at line 27 of file streams/wvwatcher.h.

struct stat WvFileWatcher::last_st [private]
 

Definition at line 27 of file include/wvwatcher.h.

Referenced by make_ok(), pre_select(), and WvFileWatcher().

bool WvFileWatcher::once_ok [private]
 

Definition at line 26 of file streams/wvwatcher.h.

Referenced by isok(), pre_select(), uread(), uwrite(), and WvFileWatcher().

int WvFileWatcher::openmode [private]
 

Definition at line 25 of file streams/wvwatcher.h.

Referenced by make_ok(), and WvFileWatcher().


The documentation for this class was generated from the following files:
Generated on Sat Aug 24 21:09:40 2002 for WvStreams by doxygen1.2.15