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

CacheLog.C

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 Thu Apr 28 23:57:21 EDT 2005 by ken@xorian.net
00020 //      modified on Thu Feb 10 12:15:58 PST 2000 by heydon
00021 
00022 #include <Basics.H>
00023 #include <FS.H>
00024 #include <VestaLog.H>
00025 #include <Recovery.H>
00026 #include <FP.H>
00027 #include <PKEpoch.H>
00028 #include <FV.H>
00029 #include <TextIO.H>
00030 
00031 #include "CacheEntry.H"
00032 #include "CacheLog.H"
00033 
00034 using std::ostream;
00035 using std::endl;
00036 
00037 void CacheLog::Entry::Init(const Text& sourceFunc, FP::Tag *pk,
00038                            PKFile::Epoch pkEpoch,
00039                            CacheEntry::Index ci, VestaVal::T *value,
00040                            Model::T model, CacheEntry::Indices *kids,
00041                            FV::List *names, FP::List *fps)
00042   throw ()
00043 {
00044     this->sourceFunc = sourceFunc;
00045     this->pk = pk;
00046     this->pkEpoch = pkEpoch;
00047 
00048     this->ci = ci;
00049     this->value = value;
00050     this->model = model;
00051     this->kids = kids;
00052     this->names = names;
00053     this->fps = fps;
00054     assert(names->len == fps->len);
00055 
00056     this->next = (Entry *)NULL;
00057 }
00058 
00059 void CacheLog::Entry::Log(VestaLog &log) const
00060   throw (VestaLog::Error)
00061 {
00062     TextIO::Log(log, this->sourceFunc);
00063     this->pk->Log(log);
00064     log.write((char *)(&(this->pkEpoch)), sizeof(this->pkEpoch));
00065 
00066     log.write((char *)(&(this->ci)), sizeof(this->ci));
00067     this->value->Log(log);
00068     this->kids->Log(log);
00069     Model::Log(this->model, log);
00070 
00071     this->names->Log(log);
00072     this->fps->Log(log);
00073 }
00074 
00075 void CacheLog::Entry::Recover(RecoveryReader &rd)
00076   throw (VestaLog::Error, VestaLog::Eof)
00077 {
00078     TextIO::Recover(rd, /*OUT*/ this->sourceFunc);
00079     pk = NEW_CONSTR(FP::Tag, (rd));
00080     rd.readAll((char *)(&(this->pkEpoch)), sizeof(this->pkEpoch));
00081 
00082     rd.readAll((char *)(&(this->ci)), sizeof(this->ci));
00083     this->value = NEW_CONSTR(VestaVal::T, (rd));
00084     this->kids = NEW_CONSTR(CacheEntry::Indices, (rd));
00085     Model::Recover(/*OUT*/ this->model, rd);
00086 
00087     this->names = NEW_CONSTR(FV::List, (rd));
00088     this->fps = NEW_CONSTR(FP::List, (rd));
00089 }
00090 
00091 void CacheLog::Entry::Write(ostream &ofs) const throw (FS::Failure)
00092 {
00093     TextIO::Write(ofs, this->sourceFunc);
00094     this->pk->Write(ofs);
00095     FS::Write(ofs, (char *)(&(this->pkEpoch)), sizeof(this->pkEpoch));
00096 
00097     FS::Write(ofs, (char *)(&this->ci), sizeof(this->ci));
00098     this->value->Write(ofs);
00099     this->kids->Write(ofs);
00100     Model::Write(this->model, ofs);
00101 
00102     this->names->Write(ofs);
00103     this->fps->Write(ofs);
00104 }
00105 
00106 static void Indent(ostream &os, int indent) throw ()
00107 {
00108     for (int i = 0; i < indent; i++) os << ' ';
00109 }
00110 
00111 void CacheLog::Entry::Debug(ostream &s, int indent) const throw ()
00112 {
00113     Indent(s, indent);
00114     s << "pk = " << *pk << ", pkEpoch = " << pkEpoch
00115       << ", ci = " << ci << ", ..." << endl;
00116 }
00117 
00118 void CacheLog::Entry::DebugFull(ostream &s) const throw ()
00119 {
00120     s << "  sourceFunc = " << this->sourceFunc << endl;
00121     s << "  pk         = " << *pk << endl;
00122     s << "  pkEpoch    = " << pkEpoch << endl;
00123 
00124     s << "  ci         = " << ci << endl;
00125     s << "  value      =" << endl; this->value->Print(s, /*indent=*/ 4);
00126     s << "  kids       = "; this->kids->Print(s, /*indent=*/ 4);
00127     s << "  model      = " << this->model << endl;
00128 
00129     s << "  names      =" << endl; this->names->Print(s, /*indent=*/ 4);
00130     s << "  fps        =" << endl; this->fps->Print(s, /*indent=*/ 4);
00131 }

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