XCube Stream Reader SDK
x3c/include/libIndexer/CIndexWriter.h
00001 
00008 #ifndef __CINDEXWRITER_H__
00009 #define __CINDEXWRITER_H__
00010 
00011 #include <vector>
00012 #include <cassert>
00013 #include "IdxFileFormat.h"
00014 #include "CIndexer.h"
00015 
00016 namespace x3c {
00017     namespace indexer {
00018 
00019         class CIndexWriter
00020         {
00021         public:
00022 
00026             ~CIndexWriter();
00027 
00031             void close();
00032 
00041             void  addIndexRecord(UINT64 timestamp, UINT64 offset);
00042 
00048             void  addIndexRecord(IndexRecord const& record);
00049 
00053             UINT32 numRecords() const;
00054 
00060             bool  flushToDisk();
00061 
00065             std::string const& filename() const;
00066 
00067        private:
00068 
00072             CIndexWriter& operator=(CIndexWriter const&);
00073 
00077             CIndexWriter(CIndexWriter const&);
00078 
00084             CIndexWriter(CIndexer<CIndexWriter> const& parent,
00085                                  UINT32 reservedMem);
00086 
00090             bool create(std::string const& filename);
00091 
00095             bool writeHeader();
00096 
00100             bool writeIndexRecords();
00101 
00105             bool writeTrailer();
00106 
00108             std::string         mFilename;
00109 
00111             IndexHeader         mHeader;
00112 
00114             std::vector<IndexRecord>  mIndexRecords;
00115             
00117             IndexTrailer        mTrailer;
00118 
00120             CIndexer<CIndexWriter> const& mParent;
00121 
00123             mutable INT32       mFd;
00124 
00126             unsigned long long  mNumIndexRecords;
00127 
00129             UINT64 mFirstTimestamp;
00130 
00132             UINT64 mLastTimestamp;
00133 
00136             friend class CIndexer<CIndexWriter>;
00137 
00140             static const unsigned int DefaultFlushCount = 100; 
00141         };
00142 
00143         //======================================================================
00144         // Inline members
00145         //
00146 
00147         inline std::string const& CIndexWriter::filename() const
00148         {
00149             return mFilename;
00150         }
00151 
00152         inline UINT32 CIndexWriter::numRecords() const
00153         {
00154             return mNumIndexRecords;
00155         }
00156 
00157     }   /* namespace indexer */
00158 }  /* namespace x3c */
00159 
00160 #endif /*  __CINDEXWRITER_H__ */
 All Classes Files Functions Variables Typedefs Friends Defines