00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _PK_PREFIX_H
00026 #define _PK_PREFIX_H
00027
00028 #include <Basics.H>
00029 #include <SRPC.H>
00030 #include <FP.H>
00031
00032 class PKPrefix {
00033 public:
00034 static int Granularity() throw ();
00035
00036
00037 class T {
00038 public:
00039 T() throw () { }
00040
00041
00042 T(const FP::Tag& fp) throw ()
00043 { this->w = fp.Word0(); Init(Granularity()); }
00044
00045
00046 T(const FP::Tag& fp, int gran) throw ()
00047 { this->w = fp.Word0(); Init(gran); }
00048
00049
00050
00051
00052 Text Pathname(int sigBits, int arcBits) const throw ();
00053
00054
00055
00056
00057
00058
00059 void Write(std::ostream &ofs) const throw (FS::Failure)
00060 { FS::Write(ofs, (char *)(&(this->w)), sizeof(this->w)); }
00061 void Read(std::istream &ifs) throw (FS::EndOfFile, FS::Failure)
00062 { FS::Read(ifs, (char *)(&(this->w)), sizeof(this->w)); }
00063
00064
00065
00066
00067 void Send(SRPC &srpc) const throw (SRPC::failure)
00068 { srpc.send_int64(this->w); }
00069 void Recv(SRPC &srpc) throw (SRPC::failure)
00070 { this->w = srpc.recv_int64(); }
00071
00072
00073 friend std::ostream& operator << (std::ostream &os, const T &pfx) throw ();
00074 friend bool operator == (const T &pfx1, const T &pfx2) throw ()
00075 { return pfx1.w == pfx2.w; }
00076 friend bool operator != (const T &pfx1, const T &pfx2) throw ()
00077 { return pfx1.w != pfx2.w; }
00078
00079
00080 Word Hash() const throw () { return this->w; };
00081
00082
00083 private:
00084 Word w;
00085
00086 void Init(int gran) throw();
00087
00088 };
00089
00090 class List {
00091 public:
00092 PKPrefix::T *pfx;
00093 int len;
00094
00095 List() throw () : len(0), pfx(NULL) { }
00096 List(SRPC &srpc) throw (SRPC::failure) { Recv(srpc); }
00097
00098
00099 void Write(std::ostream &ofs) const throw (FS::Failure);
00100 void Read(std::istream &ifs) throw (FS::EndOfFile, FS::Failure);
00101
00102
00103 void Send(SRPC &srpc) const throw (SRPC::failure);
00104 void Recv(SRPC &srpc) throw (SRPC::failure);
00105
00106
00107 void Print(std::ostream &os, int indent) const throw ();
00108 private:
00109
00110 List(const List&);
00111 };
00112 };
00113
00114 #endif // _PK_PREFIX_H