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

Model.H

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 // Created on Fri Nov  7 09:50:08 PST 1997 by heydon
00020 // Last modified on Tue Aug  3 16:27:14 EDT 2004 by ken@xorian.net
00021 //      modified on Mon Nov 10 12:41:27 PST 1997 by heydon
00022 
00023 // Defines the type "Model::T", which is a "ShortId".
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     // Model type
00038     typedef ShortId T;
00039 
00040     // log/recover
00041     static void Log(T model, VestaLog &log) throw (VestaLog::Error)
00042         { log.write((char *)(&model), sizeof(model)); }
00043     static void Recover(/*OUT*/ T &model, RecoveryReader &rd)
00044         throw (VestaLog::Error, VestaLog::Eof)
00045         { rd.readAll((char *)(&model), sizeof(model)); }
00046 
00047     // write/read
00048     static void Write(T model, std::ostream &ofs) throw (FS::Failure)
00049         { FS::Write(ofs, (char *)(&model), sizeof(model)); }
00050     static void Read(/*OUT*/ T &model, std::istream &ifs)
00051         throw (FS::EndOfFile, FS::Failure)
00052         { FS::Read(ifs, (char *)(&model), sizeof(model)); }
00053 
00054     // send/receive
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

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