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

CacheIndex.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 // Created on Fri Nov  7 09:54:23 PST 1997 by heydon
00020 // Last modified on Wed Aug  4 17:38:36 EDT 2004 by ken@xorian.net
00021 //      modified on Mon Nov 10 12:41:29 PST 1997 by heydon
00022 
00023 /* Defines the types "CacheEntry::Index", "CacheEntry::Indices",
00024    and "CacheEntry::IndicesApp".
00025 
00026    IMPORTANT: Use of this interface assumes you are linking your
00027    application program with a garbage collector! Also, none of these
00028    classes defines an assignment operator, so objects are copied
00029    field-wise by default. This means that use of the assignment
00030    operator will produce aliases for those fields that are pointer
00031    types. */
00032 
00033 #ifndef _CACHE_INDEX_H
00034 #define _CACHE_INDEX_H
00035 
00036 #include <Basics.H>
00037 #include <FS.H>
00038 #include <SRPC.H>
00039 #include <VestaLog.H>
00040 #include <Recovery.H>
00041 #include "ImmutableVal.H"
00042 
00043 namespace CacheEntry
00044 {
00045   typedef Basics::int32 Index;
00046   class Indices;
00047 }
00048 
00049 std::ostream& operator << (std::ostream &os, const CacheEntry::Indices &cis) throw ();
00050 
00051 namespace CacheEntry
00052 {
00053   // A list of indices
00054   class Indices {
00055   public:
00056     // data fields
00057     CacheEntry::Index *index;      // array of indices
00058     Basics::int32 len;             // size of "index" array
00059 
00060     // constructor/destructor
00061     Indices() throw ()
00062       : len(0), index(NULL) { /*SKIP*/ }
00063     Indices(RecoveryReader &rd) throw (VestaLog::Error, VestaLog::Eof)
00064     { Recover(rd); }
00065     Indices(std::istream &ifs) throw (FS::EndOfFile, FS::Failure)
00066     { Read(ifs); }
00067     Indices(SRPC &srpc) throw (SRPC::failure)
00068     { Recv(srpc); }
00069 
00070     // size
00071     int Size() const throw ()
00072     { return sizeof(this->len) +
00073         (this->len * sizeof(*(this->index))); }
00074 
00075     // log/recover
00076     void Log(VestaLog &log) const throw (VestaLog::Error);
00077     void Recover(RecoveryReader &rd)
00078       throw (VestaLog::Error, VestaLog::Eof);
00079 
00080     // write/read
00081     void Write(std::ostream &ofs) const throw (FS::Failure);
00082     void Read(std::istream &ifs) throw (FS::EndOfFile, FS::Failure);
00083 
00084     // read as an immutable value
00085     static ImmutableVal* ReadImmutable(std::istream &ifs)
00086       throw (FS::EndOfFile, FS::Failure);
00087 
00088     // send/receive
00089     void Send(SRPC &srpc) const throw (SRPC::failure);
00090     void Recv(SRPC &srpc) throw (SRPC::failure);
00091 
00092     // print
00093     void Print(std::ostream &os, int indent) const throw ();
00094 
00095   private:
00096     // hide the copy constructor from clients
00097     Indices(const Indices&);
00098   };
00099 
00100   // an appendable list of cache indices
00101   class IndicesApp: public Indices {
00102   public:
00103     // constructor
00104     IndicesApp() throw ()
00105       : Indices(), maxLen(0) { /* SKIP */ }
00106 
00107     // size
00108     int Size() const throw ()
00109     { return sizeof(this->len) + sizeof(this->maxLen) +
00110         (this->len * sizeof(*(this->index))); }
00111 
00112     void Append(Index ci) throw ();
00113     /* Append the index "ci" to this list. */
00114 
00115   private:
00116     int maxLen;
00117 
00118     // hide the copy constructor from clients
00119     IndicesApp(const IndicesApp&);
00120   };
00121 }
00122 
00123 #endif // _CACHE_INDEX_H

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