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

VForward.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 //
00020 // VForward.H
00021 // Last modified on Wed Jul 21 01:13:00 EDT 2004 by ken@xorian.net
00022 //      modified on Wed Nov 27 13:04:42 PST 1996 by mann
00023 //
00024 // A forwarding pointer for a renamed object, so that its old LongId
00025 // still works.
00026 
00027 #ifndef _VFWD
00028 #define _VFWD 1
00029 
00030 // Below we describe the packed representation of a VForward.  See
00031 // VDirChangeable.H for a description of the pseudo-C++ notation.
00032 //
00033 // packed struct VForward {
00034 //     Bit8 spare1: 1;
00035 //     Bit8 visited: 1;               // bool, used by GC
00036 //     Bit8 spare2: 2;
00037 //     Bit8 typecode: 4;              // Must be VMemPool::vForward, used by GC
00038 //     LongId longid;
00039 // };
00040 
00041 struct VForward {
00042     Bit8 rep[1 + sizeof(LongId)];
00043 
00044     inline bool visited() throw()
00045       { return (bool) ((rep[0] & 2) != 0); };
00046     inline void setVisited(bool newval) throw()
00047       { rep[0] = (rep[0] & 0xfd) | ((int)newval << 1); };
00048 
00049     inline LongId* longid() throw() { return (LongId*) &rep[1]; };
00050 
00051   private:
00052     // Warning: these methods reuse (smash) part of the longid
00053     inline Bit32 redirection() throw()
00054       { Bit32 ret; memcpy(&ret, &rep[1], sizeof(Bit32)); return ret; };
00055     inline void setRedirection(Bit32 val) throw()
00056       { memcpy(&rep[1], &val, sizeof(Bit32)); };
00057 
00058   public:
00059     // Return a short pointer to a new VForward allocated in the VMemPool
00060     static Bit32 create(const LongId& longid) throw();
00061 
00062     // Garbage collection support
00063     static void markCallback(void* closure, VMemPool::typeCode type) throw();
00064     static bool sweepCallback(void* closure, VMemPool::typeCode type,
00065                               void* addr, Bit32& size) throw();
00066     static void rebuildCallback(void* closure, VMemPool::typeCode type,
00067                                 void* addr, Bit32& size) throw();
00068 
00069     // Checkpointing
00070     Bit32 checkpoint(Bit32& nextSP, std::fstream& ckpt) throw();
00071 };
00072 
00073 #endif // _VFWD

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