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 _MODEL_H
00026 #define _MODEL_H
00027
00028 #include <Basics.H>
00029 #include <FS.H>
00030 #include <SRPC.H>
00031 #include <VestaLog.H>
00032 #include <Recovery.H>
00033 #include <SourceOrDerived.H>
00034
00035 class Model {
00036 public:
00037
00038 typedef ShortId T;
00039
00040
00041 static void Log(T model, VestaLog &log) throw (VestaLog::Error)
00042 { log.write((char *)(&model), sizeof(model)); }
00043 static void Recover( T &model, RecoveryReader &rd)
00044 throw (VestaLog::Error, VestaLog::Eof)
00045 { rd.readAll((char *)(&model), sizeof(model)); }
00046
00047
00048 static void Write(T model, std::ostream &ofs) throw (FS::Failure)
00049 { FS::Write(ofs, (char *)(&model), sizeof(model)); }
00050 static void Read( T &model, std::istream &ifs)
00051 throw (FS::EndOfFile, FS::Failure)
00052 { FS::Read(ifs, (char *)(&model), sizeof(model)); }
00053
00054
00055 static void Send(T model, SRPC &srpc) throw (SRPC::failure)
00056 { srpc.send_int(model); }
00057 static T Recv(SRPC &srpc) throw (SRPC::failure)
00058 { return (T)(srpc.recv_int()); }
00059 };
00060
00061 #endif // _MODEL_H