00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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, 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( 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, 4);
00126 s << " kids = "; this->kids->Print(s, 4);
00127 s << " model = " << this->model << endl;
00128
00129 s << " names =" << endl; this->names->Print(s, 4);
00130 s << " fps =" << endl; this->fps->Print(s, 4);
00131 }