#include <BufferedFile.h>
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 |
|
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. |
|
Default constructor.
Definition at line 22 of file BufferedFile.C. References parent, preadReady, pushBackBlocks, pwriteReady, reading, TIMETOWAIT, timeToWait, and writing. |
|
Destructor, closes the file if nessecary.
Definition at line 40 of file BufferedFile.C. References fd, and pushBackBlocks. |
|
close the file descriptor.
Definition at line 117 of file BufferedFile.C. Referenced by Connection< char >::disconnect(), and ConnectionFactory::~ConnectionFactory(). |
|
Can this file read? (notnessecarily now).
Definition at line 184 of file BufferedFile.C. References reading. Referenced by BufferedFileFactory::process(). |
|
Can this file write? (notnessecarily now).
Definition at line 187 of file BufferedFile.C. References writing. Referenced by BufferedFileFactory::process(). |
|
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(). |
|
gets the current wait value
Definition at line 149 of file BufferedFile.C. References timeToWait. Referenced by attemptHeader(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
sets the BufferedFileFactory parent that will be called on destruction
Definition at line 30 of file BufferedFile.C. References parent. Referenced by BufferedFileFactory::getNewBufferedFile(). |
|
Definition at line 168 of file BufferedFile.C. References parent, reading, and writing. Referenced by setReadOnly(), setReadWrite(), and setWriteOnly(). |
|
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(). |
|
sets the files status for nonblocking reads.
Definition at line 159 of file BufferedFile.C. References hasRead, and preadReady. Referenced by BufferedFileFactory::process(). |
|
sets the file to read and write, informs parent factory.
Definition at line 179 of file BufferedFile.C. References reading, setParentRW(), and writing. |
|
sets the current wait for the ready call
Definition at line 146 of file BufferedFile.C. References timeToWait. Referenced by attemptHeader(). |
|
sets the file to writeonly, informs parent factory.
Definition at line 163 of file BufferedFile.C. References reading, setParentRW(), and writing. Referenced by main(). |
|
sets the files status for nonblocking writes
Definition at line 155 of file BufferedFile.C. References hasWritten, and pwriteReady. Referenced by BufferedFileFactory::process(). |
|
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(). |
|
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(). |
|
Definition at line 133 of file BufferedFile.h. Referenced by BufferedFile(), Close(), getFileHandle(), Read(), ready(), Write(), and ~BufferedFile(). |
|
Definition at line 140 of file BufferedFile.h. Referenced by BufferedFile(), hasBeenRead(), Read(), and setReadReady(). |
|
Definition at line 139 of file BufferedFile.h. Referenced by BufferedFile(), hasBeenWritten(), setWriteReady(), and Write(). |
|
Definition at line 136 of file BufferedFile.h. Referenced by BufferedFile(), Close(), setBufferedFileFactory(), and setParentRW(). |
|
Definition at line 137 of file BufferedFile.h. Referenced by BufferedFile(), readReady(), and setReadReady(). |
|
Definition at line 134 of file BufferedFile.h. Referenced by BufferedFile(), pushBack(), Read(), ready(), and ~BufferedFile(). |
|
Definition at line 138 of file BufferedFile.h. Referenced by BufferedFile(), setWriteReady(), and writeReady(). |
|
Definition at line 130 of file BufferedFile.h. Referenced by BufferedFile(), doesRead(), setParentRW(), setReadOnly(), setReadWrite(), and setWriteOnly(). |
|
Definition at line 132 of file BufferedFile.h. Referenced by BufferedFile(), getWait(), ready(), and setWait(). |
|
Definition at line 131 of file BufferedFile.h. Referenced by BufferedFile(), doesWrite(), setParentRW(), setReadOnly(), setReadWrite(), and setWriteOnly(). |