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

FPShortId.H

Go to the documentation of this file.
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 Wed Dec  8 01:33:30 EST 2004 by ken@xorian.net
00020 
00021 #ifndef _FPSHORTID_H
00022 #define _FPSHORTID_H
00023 
00024 #include "Basics.H"
00025 #include "FP.H"
00026 #include "ShortIdBlock.H"
00027 
00028 //
00029 // The methods are unmonitored
00030 //
00031 class FPShortIdTable {
00032   public:
00033     typedef FP::Tag (*GetFP)(Bit8* ptr);
00034     typedef ShortId (*GetSid)(Bit8* ptr);
00035 
00036     FPShortIdTable(GetFP getfp, GetSid getsid,
00037                    Bit32 sizeHint = 0, double resizeF = 2.0,
00038                    double resizeT = 0.7);
00039     ~FPShortIdTable();
00040     ShortId Get(const FP::Tag& fptag);
00041     bool Set(Bit8 *ptr, bool resize = true);
00042     bool Resize(Bit32 size);
00043     Bit32 Size();
00044     Bit32 Entries();
00045     void Clear();  // empty the table but do not resize
00046 
00047   private:
00048     Bit32 numEntries;      // current number of entries in table
00049     Bit32 tableSize;
00050     double resizeTrigger;
00051     double resizeFactor;
00052     
00053     Bit32 *table;   
00054     GetFP getfp;
00055     GetSid getsid;
00056 };
00057 
00058 // These procedures are used to create two instances of the above
00059 // object and manipulate them.  They are monitored by a private mutex.
00060 // Better coding style might put this layer in a separate .H file.
00061 //
00062 
00063 // Initialization.  Call once from RepositoryMain.
00064 void InitFPShortId();
00065 
00066 // Clear both tables; used in preparation for rebuilding them after a
00067 // checkpoint or source weed.
00068 void DeleteAllFPShortId();
00069 
00070 // Enter a file fingerprint in the table, starting with a pointer to
00071 // the file's directory entry.  The pointer is retained, which is OK
00072 // for entries in immutable or appendable directories. Entries in
00073 // immutable directories are safe because they do not change.  Entries
00074 // in appendable directories are safe because they can change only by
00075 // having their entry type set to "deleted" or "outdated", in which
00076 // case we ignore them on lookup.
00077 void SetFPFileShortId(Bit8 *entry);
00078 
00079 // Enter a directory fingerprint in the table, starting with a
00080 // pointer to the representation.  This pointer is retained, which is
00081 // OK because only an immutable directory can be passed in.
00082 void SetFPDirShortId(Bit8 *rep);
00083 
00084 // Get either a file or directory.  The fptag is looked up in both
00085 // tables.  This is a bit inefficient, and could be avoided since the
00086 // ultimate caller knows (in today's applications, at least) whether
00087 // it is expecting a file or a directory.  However, for historical
00088 // reasons the existing VestaSource interface doesn't supply this
00089 // information, and it's a bit of a pain to change it and the client.
00090 ShortId GetFPShortId(const FP::Tag &fptag);
00091 
00092 #endif //_FPSHORTID_H

Generated on Mon May 8 00:48:44 2006 for Vesta by  doxygen 1.4.2