00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Fennel_FlatFileBuffer_Included
00025 #define Fennel_FlatFileBuffer_Included
00026
00027 #include "fennel/common/ClosableObject.h"
00028 #include "fennel/common/TraceSource.h"
00029
00030 FENNEL_BEGIN_NAMESPACE
00031
00032 class FlatFileBuffer;
00033 typedef boost::shared_ptr<FlatFileBuffer> SharedFlatFileBuffer;
00034
00073 class FENNEL_FLATFILE_EXPORT FlatFileBuffer
00074 : public ClosableObject, public TraceSource
00075 {
00076 std::string path;
00077 FILE *pFile;
00078 FileSize filePosition;
00079
00080 char *pBuffer;
00081 uint bufferSize, contentSize;
00082 char *pCurrent;
00083
00084
00085 void closeImpl();
00086
00087 public:
00093 FlatFileBuffer(const std::string &path);
00094 virtual ~FlatFileBuffer();
00095
00099 void open();
00100
00108 void setStorage(char *pBuffer, uint size);
00109
00116 uint read();
00117
00121 char *getReadPtr();
00122
00126 char *getEndPtr();
00127
00131 int getSize();
00132
00136 bool isFull();
00137
00141 bool isComplete();
00142
00151 bool isDone();
00152
00156 void setReadPtr(char *ptr);
00157 };
00158
00159 FENNEL_END_NAMESPACE
00160
00161 #endif
00162
00163