00001 // Copyright (C) 2001, Compaq Computer Corporation 00002 // 00003 // This file is part of Vesta. 00004 // 00005 // Vesta is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // Vesta is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with Vesta; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 // Last modified on Thu Nov 8 12:48:54 EST 2001 by ken@xorian.net 00020 // modified on Wed Feb 23 12:24:17 PST 2000 by mann 00021 // modified on Fri Sep 18 16:26:43 PDT 1998 by heydon 00022 00023 // VPKFileChkPt.H -- records certain aspects of the state of a VPKFile 00024 00025 #ifndef _VPK_FILE_CHK_PT 00026 #define _VPK_FILE_CHK_PT 00027 00028 #include <Basics.H> 00029 #include <FP.H> 00030 #include <Table.H> 00031 #include <PKEpoch.H> 00032 #include <FV.H> 00033 00034 #include "CacheEntry.H" 00035 00036 /* A "VPKFileChkPt" object is used by "SMultiPKFile::Rewrite" to checkpoint 00037 the state of a VPKFile. Then, while the SPKFile is being rewritten, new 00038 entries may be added to the VPKFile. After the SPKFile has been written, 00039 but before it has been committed on disk, each relevant VPKFile is updated 00040 from its checkpoint by removing the entries in the checkpoint. See the 00041 "VToSCache" procedure and the "NewVF" function in "SVCache.spec". 00042 00043 New "VPKFileChkPt" objects are created by the "VPKFile::CheckPoint" method. 00044 00045 To checkpoint a VPKFile without having to make a complete copy of it, we 00046 rely on certain properties of how VPKFile's are augmented: 00047 00048 To checkpoint the scalar "pkEpoch" and "namesEpoch" values, we simply copy 00049 their values. 00050 00051 Since the "allNames" list is only appended to when new entries are added to 00052 the VPKFile, we checkpoint it by recording its current length and a pointer 00053 to the current "allNames" value. 00054 00055 Since the "newUncommon" list of cache entries is only prepended to, we 00056 checkpoint it by making copies of its cache entries in "newUncommon" and 00057 recording its current value in "newUncommonHead". Copying the cache entries 00058 is necessary because the "SMultiPKFile::Rewrite" method can change the 00059 contents of the entries. Similarly, we checkpoint the "newCommon" table by 00060 making copies of its entries in "newCommon" and saving copies of the heads 00061 of each list in the "newCommonHeads" table as well. */ 00062 00063 class VPKFileChkPt { 00064 public: 00065 // constructor 00066 VPKFileChkPt() 00067 : pkEpoch(0), namesEpoch(0), allNamesLen(0), allNames(NULL), 00068 newUncommon(NULL), newUncommonHead(NULL), hasNewEntries(false) 00069 { /*SKIP*/ } 00070 00071 // dictionary type 00072 typedef Table<FP::Tag,CE::List*>::Default CFPEntryMap; 00073 typedef Table<FP::Tag,CE::List*>::Iterator CFPEntryIter; 00074 00075 // data fields 00076 const Text *sourceFunc; // copy of "sourceFunc" 00077 PKFile::Epoch pkEpoch; // copy of "pkEpoch" 00078 FV::Epoch namesEpoch; // copy of "namesEpoch" 00079 int allNamesLen; // copy of "allNames.len" 00080 const FV::ListApp *allNames; // ptr to "allNames" 00081 const CE::List *newUncommon; // checkpoint of "newUncommon" 00082 CFPEntryMap newCommon; // table of checkpoints of "newCommon" 00083 const CE::List *newUncommonHead; // ptr to original "newUncommon" list 00084 CFPEntryMap newCommonHeads; // table of pointers to original lists 00085 bool hasNewEntries; 00086 00087 /* "hasNewEntries" is true iff "newUncommonHead != NULL" or if 00088 "newCommonHeads.Size() > 0". That is, it represents if there 00089 are any new cache entries in the checkpoint. */ 00090 }; 00091 00092 #endif // _VPK_FILE_CHK_PT