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

BufferedFile Class Reference

#include <BufferedFile.h>

List of all members.


Detailed Description

The BufferedFile class acts like a stack buffered file.

You can push data back onto the stack and consecutive reads will read it. BufferedFiles are created from BufferedFileFactories so that the factory can detect if the file descriptor can read or written to.

Definition at line 34 of file BufferedFile.h.

Public Methods

 BufferedFile (int fdesc)
 Make a new BufferedFile using fdesc as the file descriptor.

 BufferedFile ()
 Default constructor.

 ~BufferedFile ()
 Destructor, closes the file if nessecary.

int Read (char *data, int size)
 Reads size bytes into data from the file.

int Write (const char *data, int size)
 Writes size bytes from data to the file.

int getFileHandle ()
 returns the file handle of the BufferedFile

void Close ()
 close the file descriptor.

void pushBack (char *data, int size)
 Push size bytes of data back onto the BufferedFile stack.

bool readReady ()
 Can we read without blocking?

bool writeReady ()
 Can we write without blocking?

void setWait (int w)
 sets the current wait for the ready call

int getWait ()
 gets the current wait value

bool ready (int rw)
 Blocks for wait time checking if the file is readable or writable.

void setWriteReady (bool b)
 sets the files status for nonblocking writes

void setReadReady (bool b)
 sets the files status for nonblocking reads.

void setBufferedFileFactory (void *parent)
 sets the BufferedFileFactory parent that will be called on destruction

void setWriteOnly ()
 sets the file to writeonly, informs parent factory.

void setReadOnly ()
 sets the file to readonly, informs parent factory.

void setReadWrite ()
 sets the file to read and write, informs parent factory.

bool hasBeenWritten ()
 Has the file been written to since the last the last setWriteReady.

bool hasBeenRead ()
 Has the file been read to since the last the last setReadReady.

bool doesWrite ()
 Can this file write? (notnessecarily now).

bool doesRead ()
 Can this file read? (notnessecarily now).


Private Methods

void setParentRW ()

Private Attributes

bool reading
bool writing
int timeToWait
int fd
list< CharAndSize * > pushBackBlocks
void * parent
bool preadReady
bool pwriteReady
bool hasWritten
bool hasRead


Constructor & Destructor Documentation

BufferedFile::BufferedFile int    fdesc
 

Make a new BufferedFile using fdesc as the file descriptor.

Definition at line 11 of file BufferedFile.C.

References fd, hasRead, hasWritten, parent, preadReady, pushBackBlocks, pwriteReady, reading, TIMETOWAIT, timeToWait, and writing.

BufferedFile::BufferedFile  
 

Default constructor.

Definition at line 22 of file BufferedFile.C.

References parent, preadReady, pushBackBlocks, pwriteReady, reading, TIMETOWAIT, timeToWait, and writing.

BufferedFile::~BufferedFile  
 

Destructor, closes the file if nessecary.

Definition at line 40 of file BufferedFile.C.

References fd, and pushBackBlocks.


Member Function Documentation

void BufferedFile::Close  
 

close the file descriptor.

Definition at line 117 of file BufferedFile.C.

References fd, and parent.

Referenced by Connection< char >::disconnect(), and ConnectionFactory::~ConnectionFactory().

bool BufferedFile::doesRead  
 

Can this file read? (notnessecarily now).

Definition at line 184 of file BufferedFile.C.

References reading.

Referenced by BufferedFileFactory::process().

bool BufferedFile::doesWrite  
 

Can this file write? (notnessecarily now).

Definition at line 187 of file BufferedFile.C.

References writing.

Referenced by BufferedFileFactory::process().

int BufferedFile::getFileHandle  
 

returns the file handle of the BufferedFile

Definition at line 152 of file BufferedFile.C.

References fd.

Referenced by BufferedFileFactory::closeFile(), Connection< char >::getFileHandle(), ConfigConnection::getFileHandle(), BufferedFileFactory::process(), BufferedFileFactory::setBufferedFileRead(), and BufferedFileFactory::setBufferedFileWrite().

int BufferedFile::getWait  
 

gets the current wait value

Definition at line 149 of file BufferedFile.C.

References timeToWait.

Referenced by attemptHeader().

bool BufferedFile::hasBeenRead  
 

Has the file been read to since the last the last setReadReady.

Definition at line 193 of file BufferedFile.C.

References hasRead.

Referenced by BufferedFileFactory::process().

bool BufferedFile::hasBeenWritten  
 

Has the file been written to since the last the last setWriteReady.

Definition at line 190 of file BufferedFile.C.

References hasWritten.

Referenced by BufferedFileFactory::process().

void BufferedFile::pushBack char *    data,
int    size
 

Push size bytes of data back onto the BufferedFile stack.

Definition at line 53 of file BufferedFile.C.

References CharAndSize::alreadyRead, CharAndSize::data, pushBackBlocks, and CharAndSize::size.

Referenced by attemptHeader().

int BufferedFile::Read char *    data,
int    size
 

Reads size bytes into data from the file.

Definition at line 60 of file BufferedFile.C.

References CharAndSize::alreadyRead, CharAndSize::data, fd, hasRead, pushBackBlocks, and CharAndSize::size.

Referenced by attemptHeader(), and Connection< char >::read().

bool BufferedFile::readReady  
 

Can we read without blocking?

Definition at line 114 of file BufferedFile.C.

References preadReady.

Referenced by ConnectionFactory::isThereANewConnection(), BufferedFileFactory::process(), Connection< char >::readReady(), and ConfigConnection::readReady().

bool BufferedFile::ready int    rw
 

Blocks for wait time checking if the file is readable or writable.

Definition at line 128 of file BufferedFile.C.

References fd, pushBackBlocks, and timeToWait.

Referenced by attemptHeader().

void BufferedFile::setBufferedFileFactory void *    parent
 

sets the BufferedFileFactory parent that will be called on destruction

Definition at line 30 of file BufferedFile.C.

References parent.

Referenced by BufferedFileFactory::getNewBufferedFile().

void BufferedFile::setParentRW   [private]
 

Definition at line 168 of file BufferedFile.C.

References parent, reading, and writing.

Referenced by setReadOnly(), setReadWrite(), and setWriteOnly().

void BufferedFile::setReadOnly  
 

sets the file to readonly, informs parent factory.

Definition at line 174 of file BufferedFile.C.

References reading, setParentRW(), and writing.

Referenced by ConnectionFactory::init(), and main().

void BufferedFile::setReadReady bool    b
 

sets the files status for nonblocking reads.

Definition at line 159 of file BufferedFile.C.

References hasRead, and preadReady.

Referenced by BufferedFileFactory::process().

void BufferedFile::setReadWrite  
 

sets the file to read and write, informs parent factory.

Definition at line 179 of file BufferedFile.C.

References reading, setParentRW(), and writing.

void BufferedFile::setWait int    w
 

sets the current wait for the ready call

Definition at line 146 of file BufferedFile.C.

References timeToWait.

Referenced by attemptHeader().

void BufferedFile::setWriteOnly  
 

sets the file to writeonly, informs parent factory.

Definition at line 163 of file BufferedFile.C.

References reading, setParentRW(), and writing.

Referenced by main().

void BufferedFile::setWriteReady bool    b
 

sets the files status for nonblocking writes

Definition at line 155 of file BufferedFile.C.

References hasWritten, and pwriteReady.

Referenced by BufferedFileFactory::process().

int BufferedFile::Write const char *    data,
int    size
 

Writes size bytes from data to the file.

Definition at line 34 of file BufferedFile.C.

References fd, hasWritten, and write().

Referenced by Connection< char >::write().

bool BufferedFile::writeReady  
 

Can we write without blocking?

Definition at line 115 of file BufferedFile.C.

References pwriteReady.

Referenced by BufferedFileFactory::process(), Connection< char >::writeReady(), and ConfigConnection::writeReady().


Member Data Documentation

int BufferedFile::fd [private]
 

Definition at line 133 of file BufferedFile.h.

Referenced by BufferedFile(), Close(), getFileHandle(), Read(), ready(), Write(), and ~BufferedFile().

bool BufferedFile::hasRead [private]
 

Definition at line 140 of file BufferedFile.h.

Referenced by BufferedFile(), hasBeenRead(), Read(), and setReadReady().

bool BufferedFile::hasWritten [private]
 

Definition at line 139 of file BufferedFile.h.

Referenced by BufferedFile(), hasBeenWritten(), setWriteReady(), and Write().

void* BufferedFile::parent [private]
 

Definition at line 136 of file BufferedFile.h.

Referenced by BufferedFile(), Close(), setBufferedFileFactory(), and setParentRW().

bool BufferedFile::preadReady [private]
 

Definition at line 137 of file BufferedFile.h.

Referenced by BufferedFile(), readReady(), and setReadReady().

list<CharAndSize *> BufferedFile::pushBackBlocks [private]
 

Definition at line 134 of file BufferedFile.h.

Referenced by BufferedFile(), pushBack(), Read(), ready(), and ~BufferedFile().

bool BufferedFile::pwriteReady [private]
 

Definition at line 138 of file BufferedFile.h.

Referenced by BufferedFile(), setWriteReady(), and writeReady().

bool BufferedFile::reading [private]
 

Definition at line 130 of file BufferedFile.h.

Referenced by BufferedFile(), doesRead(), setParentRW(), setReadOnly(), setReadWrite(), and setWriteOnly().

int BufferedFile::timeToWait [private]
 

Definition at line 132 of file BufferedFile.h.

Referenced by BufferedFile(), getWait(), ready(), and setWait().

bool BufferedFile::writing [private]
 

Definition at line 131 of file BufferedFile.h.

Referenced by BufferedFile(), doesWrite(), setParentRW(), setReadOnly(), setReadWrite(), and setWriteOnly().


The documentation for this class was generated from the following files:
Generated on Tue Dec 17 21:14:36 2002 for AUSS_Connector by doxygen1.2.18