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 Fri Apr 29 00:25:06 EDT 2005 by ken@xorian.net 00020 // modified on Fri Aug 8 19:53:51 PDT 1997 by heydon 00021 00022 /* StatMPKFile.H 00023 00024 Defines objects and iterators at level 3 of the stable cache hierarchy, 00025 namely, at the level of sets of cache entries with the same primary key 00026 prefix (PKPrefix). Abstractly, a "MPKFileObj" is a collection of PKFiles. 00027 */ 00028 00029 #ifndef _STAT_MPKFILE_H 00030 #define _STAT_MPKFILE_H 00031 00032 #include <Basics.H> 00033 #include <FS.H> 00034 #include "SMultiPKFileRep.H" 00035 #include "StatError.H" 00036 #include "StatCount.H" 00037 #include "StatDirEntry.H" 00038 #include "StatPKFile.H" 00039 #include "StatCollection.H" 00040 00041 class MPKFileIter; // defined below 00042 00043 class MPKFileObj : public DirEntry { 00044 public: 00045 MPKFileObj(const Text& fname) throw () 00046 : DirEntry(DirEntry::File), fname(fname) 00047 { 00048 loc = NEW_CONSTR(Stat::Location, (fname)); 00049 } 00050 /* Create a new MPKFileObj for the MultiPKFile named "fname". */ 00051 00052 int Search(int verbose, /*INOUT*/ Stat::Collection &stats) 00053 throw (StatError::BadMPKFile, 00054 StatError::EndOfFile, FS::Failure, FS::DoesNotExist); 00055 /* Search this MPKFileObj, returning the height of the MPKFileObj 00056 in the search tree (i.e., 3). Update "entryStats" with statistical 00057 values at the leaves of the subtree rooted at this MPKFileObj; 00058 update "fanout" at all levels at and below this MPKFileObj with 00059 the fanout of each object in the subtree. */ 00060 00061 private: 00062 Text fname; // name of the MultiPKFile 00063 Stat::Location *loc; 00064 SMultiPKFileRep::Header *hdr; // contents of this MultiPKFile 00065 friend class MPKFileIter; 00066 }; 00067 00068 class MPKFileIter { 00069 public: 00070 MPKFileIter(const MPKFileObj *mpkf) throw () 00071 : mpkf(mpkf), pkIndex(0) { /*SKIP*/ } 00072 /* Initialize this iterator on the MPKFileObj "mpkf". */ 00073 00074 bool Next(/*OUT*/ PKFileObj* &pkf) throw (); 00075 /* If the iterator is not finished, set "pkf" to point to the next 00076 "PKFileObj" in it and return true. Otherwise, return false. */ 00077 00078 private: 00079 const MPKFileObj *mpkf; // object to iterate over 00080 int pkIndex; // index into "this->mpkf->hdr->pkSeq" 00081 }; 00082 00083 #endif // _STAT_MPKFILE_H