Main Page   Class Hierarchy   File List  

BufferedFile.h

00001 #include <unistd.h>
00002 #include <vector>
00003 #include <list>
00004 #ifndef BUFFEREDFILE_H
00005 #define BUFFEREDFILE_H
00006 #define BUFFER_READ 0
00007 #define BUFFER_WRITE 1
00008 
00009 struct CharAndSize {
00010         char * data;
00011         int size;
00012         int alreadyRead;
00013 } typedef CharAndSize;
00014 
00015 //Acts like a stack
00016 
00017 class BufferedFile {
00018         public:
00019         BufferedFile(int fdesc);
00020         BufferedFile();
00021         ~BufferedFile();
00022         int Read(char * data, int size);
00023         int Write(const char * data, int size);
00024         int getFileHandle();
00025         void Close();
00026         void pushBack(char * data, int size);
00027         bool readReady();
00028         bool writeReady();
00029         void setWait(int w);
00030         int getWait();
00031         bool ready(int rw);
00032         
00033         void setWriteReady(bool b);
00034         void setReadReady(bool b);
00035         void setBufferedFileFactory(void * parent);
00036         void setWriteOnly();
00037         void setReadOnly();
00038         void setReadWrite();
00039         bool hasBeenWritten();
00040         bool hasBeenRead();
00041         bool doesWrite();
00042         bool doesRead();
00043         private:
00044         void setParentRW();
00045         bool reading;
00046         bool writing;
00047         int timeToWait; //This is in microseconds
00048         int fd;
00049         list<CharAndSize *> pushBackBlocks;
00050         //Don't destroy tell parent to remove
00051         void * parent;
00052         bool preadReady;
00053         bool pwriteReady;
00054         bool hasWritten;
00055         bool hasRead;
00056 };
00057 #endif

Generated on Sat Dec 7 21:28:09 2002 by doxygen1.2.18