Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

persist.h

Go to the documentation of this file.
00001 // persist.h --
00002 // $Id: persist.h,v 1.14 2004/01/28 21:33:40 jcw Exp $
00003 // This is part of Metakit, see https://www.equi4.com/metakit/
00004 
00009 #ifndef __PERSIST_H__
00010 #define __PERSIST_H__
00011 
00013 // Declarations in this file
00014 
00015   class c4_SaveContext;       // wraps file commits
00016   class c4_Persist;         // persistent table storage
00017 
00018   class c4_Allocator;         // not defined here
00019   class c4_Column;          // not defined here
00020   class c4_Differ;          // not defined here
00021   class c4_FileMark;          // not defined here
00022   class c4_Strategy;          // not defined here
00023   class c4_HandlerSeq;        // not defined here
00024 
00026 
00027 class c4_SaveContext
00028 { 
00029   c4_Strategy& _strategy;
00030   c4_Column* _walk;
00031   c4_Differ* _differ;
00032 
00033   c4_Allocator* _space;
00034   c4_Allocator* _cleanup;
00035   c4_Allocator* _nextSpace;
00036 
00037   bool _preflight;
00038   bool _fullScan;
00039   int _mode;
00040   
00041   c4_DWordArray _newPositions;
00042   int _nextPosIndex;
00043 
00044   t4_byte* _bufPtr;
00045   t4_byte* _curr;
00046   t4_byte* _limit;
00047   t4_byte _buffer [512];
00048 
00049 public:           
00050   c4_SaveContext (c4_Strategy& strategy_, bool fullScan_, int mode_,
00051             c4_Differ* differ_, c4_Allocator* space_);
00052   ~c4_SaveContext ();
00053   
00054   void SaveIt(c4_HandlerSeq& root_, c4_Allocator** spacePtr_,
00055             c4_Bytes& rootWalk_);
00056 
00057   void StoreValue(t4_i32 v_);
00058   bool CommitColumn(c4_Column& col_);
00059   void CommitSequence(c4_HandlerSeq& seq_, bool selfDesc_);
00060 
00061   c4_Column* SetWalkBuffer(c4_Column* walk_);
00062   bool IsFlipped() const;
00063 
00064   bool Serializing() const;
00065   void AllocDump(const char*, bool =false);
00066   
00067 private:
00068   void FlushBuffer();
00069   void Write(const void* buf_, int len_);
00070 };
00071 
00073 
00074 class c4_Persist
00075 {
00076   c4_Allocator* _space;
00077   c4_Strategy& _strategy;
00078   c4_HandlerSeq* _root;
00079   c4_Differ* _differ;
00080   c4_Bytes _rootWalk;
00081   bool (c4_Persist::*_fCommit) (bool);
00082   int _mode;
00083   bool _owned;
00084 
00085   // used for on-the-fly conversion of old-format datafiles
00086   t4_byte* _oldBuf;
00087   const t4_byte* _oldCurr;
00088   const t4_byte* _oldLimit;
00089   t4_i32 _oldSeek;
00090 
00091   int OldRead(t4_byte* buf_, int len_);
00092 
00093 public:
00094   c4_Persist (c4_Strategy&, bool owned_, int mode_);
00095   ~c4_Persist ();
00096   
00097   c4_HandlerSeq& Root() const;
00098   void SetRoot(c4_HandlerSeq* root_);
00099   c4_Strategy& Strategy() const;
00100 
00101   bool AutoCommit(bool =true);
00102   void DoAutoCommit();
00103 
00104   bool SetAside(c4_Storage& aside_);
00105   c4_Storage* GetAside() const;
00106 
00107   bool Commit(bool full_);
00108   bool Rollback(bool full_);
00109 
00110   bool LoadIt(c4_Column& walk_);
00111   void LoadAll();
00112 
00113   t4_i32 LookupAside(int id_);
00114   void ApplyAside(int id_, c4_Column& col_);
00115 
00116   void OccupySpace(t4_i32 pos_, t4_i32 len_);
00117 
00118   t4_i32 FetchOldValue();
00119   void FetchOldLocation(c4_Column& col_);
00120   
00121   t4_i32 FreeBytes(t4_i32* bytes_ =0);
00122 
00123   static c4_HandlerSeq* Load(c4_Stream*);
00124   static void Save(c4_Stream*, c4_HandlerSeq& root_);
00125 };
00126 
00128 
00129 #endif


Metakit C++ API Reference - https://www.equi4.com/metakit.html - extracted with Doxygen