00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _GRAPH_LOG_H
00023 #define _GRAPH_LOG_H
00024
00025 #include <time.h>
00026 #include <Basics.H>
00027 #include <FS.H>
00028 #include <VestaLog.H>
00029 #include <Recovery.H>
00030 #include <FP.H>
00031
00032 #include "Model.H"
00033 #include "CacheIndex.H"
00034 #include "Derived.H"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class GraphLog {
00049 public:
00050
00051
00052 enum Kind { RootKind, NodeKind };
00053
00054
00055 class Entry {
00056 public:
00057
00058 Kind kind;
00059 Entry(Kind kind) throw () : kind(kind) { }
00060
00061
00062 virtual void Log(VestaLog &log) const throw (VestaLog::Error)
00063 { log.write((char *)(&(this->kind)), sizeof(this->kind)); }
00064 static Entry *Recover(RecoveryReader &rd)
00065 throw (VestaLog::Error, VestaLog::Eof);
00066
00067
00068 virtual void Write(std::ostream &ofs) const throw (FS::Failure)
00069 { FS::Write(ofs, (char *)(&(this->kind)), sizeof(this->kind)); }
00070 static Entry *Read(std::istream &ifs) throw (FS::Failure, FS::EndOfFile);
00071
00072 virtual void Debug(std::ostream &s) const throw ();
00073
00074
00075
00076 virtual void DebugFull(std::ostream &s) const throw ();
00077
00078
00079
00080 private:
00081
00082 Entry(const Entry &);
00083 };
00084
00085
00086 class Node: public Entry {
00087 public:
00088 Node *next;
00089 CacheEntry::Index ci;
00090 FP::Tag *loc;
00091 Model::T model;
00092 CacheEntry::Indices *kids;
00093 Derived::Indices *refs;
00094
00095
00096 Node(CacheEntry::Index ci, FP::Tag *loc, Model::T model,
00097 CacheEntry::Indices *kids, Derived::Indices *refs) throw ()
00098 : Entry(NodeKind) { Init(ci, loc, model, kids, refs); }
00099 Node(RecoveryReader &rd) throw (VestaLog::Error, VestaLog::Eof)
00100 : Entry(NodeKind) { Recover(rd); }
00101 Node(std::istream &ifs) throw (FS::Failure, FS::EndOfFile)
00102 : Entry(NodeKind) { Read(ifs); }
00103
00104 void Init(CacheEntry::Index ci, FP::Tag *loc, Model::T model,
00105 CacheEntry::Indices *kids, Derived::Indices *refs) throw ();
00106
00107
00108
00109
00110 ~Node() throw () { this->Reset(); }
00111 void Reset() throw ()
00112 { this->loc = NULL; this->kids = NULL; this->refs = NULL; }
00113
00114
00115
00116 void Log(VestaLog &log) const throw (VestaLog::Error);
00117 void Recover(RecoveryReader &rd)
00118 throw (VestaLog::Error, VestaLog::Eof);
00119
00120
00121
00122
00123 void Write(std::ostream &ofs) const throw (FS::Failure);
00124 void Read(std::istream &ifs) throw (FS::Failure, FS::EndOfFile);
00125
00126
00127
00128
00129 void Debug(std::ostream &os) const throw ();
00130 void DebugFull(std::ostream &os) const throw ();
00131 private:
00132
00133 Node(const Node &);
00134 };
00135
00136
00137 class Root: public Entry {
00138 public:
00139 FP::Tag pkgVersion;
00140 Model::T model;
00141 time_t ts;
00142 CacheEntry::Indices *cis;
00143 bool done;
00144
00145
00146 Root(const FP::Tag &pkgVersion, Model::T model,
00147 CacheEntry::Indices *cis, bool done) throw ()
00148 : Entry(RootKind) { Init(pkgVersion, model, cis, done); }
00149 Root(RecoveryReader &rd) throw (VestaLog::Error, VestaLog::Eof)
00150 : Entry(RootKind) { Recover(rd); }
00151 Root(std::istream &ifs) throw (FS::Failure, FS::EndOfFile)
00152 : Entry(RootKind) { Read(ifs); }
00153
00154 void Init(const FP::Tag &pkgVersion, Model::T model,
00155 CacheEntry::Indices *cis, bool done) throw ();
00156
00157
00158
00159
00160 void DeleteContents() throw () { cis = NULL; }
00161
00162
00163
00164 void Log(VestaLog &log) const throw (VestaLog::Error);
00165 void Recover(RecoveryReader &rd)
00166 throw (VestaLog::Error, VestaLog::Eof);
00167
00168
00169
00170
00171 void Write(std::ostream &ofs) const throw (FS::Failure);
00172 void Read(std::istream &ifs) throw (FS::Failure, FS::EndOfFile);
00173
00174
00175
00176
00177 void Debug(std::ostream &os) const throw ();
00178 void DebugFull(std::ostream &os) const throw ();
00179
00180 private:
00181
00182 Root(const Root &);
00183 };
00184 };
00185
00186 #endif // _GRAPH_LOG_H