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

VestaVal.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 14:27:48 PST 1997 by heydon
00020 // Last modified on Tue Aug  3 16:38:33 EDT 2004 by ken@xorian.net
00021 //      modified on Mon Mar 30 14:37:28 PST 1998 by heydon
00022 
00023 /* This interface defines the type "VestaVal::T", the representation
00024    of a Vesta function result value.
00025 
00026    IMPORTANT: Use of this interface assumes you are linking your
00027    application program with a garbage collector! Also, none of these
00028    classes defines an assignment operator, so objects are copied
00029    field-wise by default. This means that use of the assignment
00030    operator will produce aliases for those fields that are pointer
00031    types. */
00032 
00033 #ifndef _VESTA_VAL_H
00034 #define _VESTA_VAL_H
00035 
00036 #include <Basics.H>
00037 #include <FS.H>
00038 #include <SRPC.H>
00039 #include <VestaLog.H>
00040 #include <Recovery.H>
00041 #include <FP.H>
00042 #include "ImmutableVal.H"
00043 #include "Derived.H"
00044 #include "PrefixTbl.H"
00045 
00046 class VestaVal {
00047   public:
00048     class T {
00049       public:
00050         // data fields
00051         FP::Tag fp;             // fingerprint
00052         Derived::Indices dis;   // reachable deriveds
00053         PrefixTbl prefixTbl;    // table of names used by pickle
00054         Basics::int32 len;      // number of pickled bytes
00055         char *bytes;            // array of pickled bytes
00056 
00057         // constructors/destructor
00058         T() throw ()
00059             : len(0), bytes(NULL) { /*SKIP*/ }
00060         T(char *bytebuff, int len = -1) throw ();
00061         T(RecoveryReader &rd) throw (VestaLog::Error, VestaLog::Eof)
00062             { Recover(rd); }
00063         T(std::istream &ifs) throw (FS::EndOfFile, FS::Failure)
00064             { Read(ifs); }
00065         T(SRPC &srpc) throw (SRPC::failure)
00066             { Recv(srpc); }
00067 
00068         // size
00069         int Size() const throw ()
00070           { return sizeof(this->fp) + this->dis.Size()
00071               + this->prefixTbl.MemorySize()
00072               + sizeof(this->len) + (this->len * sizeof(*(this->bytes))); }
00073 
00074         // logging/recovery
00075         void Log(VestaLog &log) const throw (VestaLog::Error);
00076         void Recover(RecoveryReader &rd)
00077           throw (VestaLog::Error, VestaLog::Eof);
00078 
00079         // write/read
00080         void Write(std::ostream &ofs) const throw (FS::Failure);
00081         void Read(std::istream &ifs) throw (FS::EndOfFile, FS::Failure);
00082 
00083         // read as an immutable value
00084         static ImmutableVal* ReadImmutable(std::istream &ifs)
00085           throw (FS::EndOfFile, FS::Failure);
00086 
00087         // send/receive
00088         void Send(SRPC &srpc) const throw (SRPC::failure);
00089         void Recv(SRPC &srpc) throw (SRPC::failure);
00090  
00091         // print
00092         void Print(std::ostream &os, int indent) const throw ();
00093         /* Print the value as a sequence of lines (each field of the value
00094            begins a new line), with each line indented by "indent" spaces. */
00095       private:
00096         // hide the copy constructor from clients
00097         T(const T&);
00098     };
00099 };
00100 
00101 #endif // _VESTA_VAL_H

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