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

VestaAttribsRep.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 // VestaAttribsRep.H
00021 // Last modified on Wed Jul 21 13:27:58 EDT 2004 by ken@xorian.net
00022 //      modified on Thu Jul 19 18:44:56 PDT 2001 by mann
00023 //
00024 // Mutable attributes for Vesta sources.
00025 //
00026 
00027 #ifndef _VATTRR
00028 #define _VATTRR 1
00029 
00030 #include "Basics.H"
00031 #include "VMemPool.H"
00032 #include "VestaSource.H"
00033 
00034 
00035 // Packed representation of a VestaAttribsRep, using the
00036 // pseudo-C++ notation described in VDirChangeable.H.
00037 //
00038 // packed struct VestaAttribsRep {
00039 //     Bit8 spare: 1;
00040 //     Bit8 visited: 1;          // bool, used by GC
00041 //     Bit8 op: 2;               // VestaSource::attribOp
00042 //     Bit8 typecode: 4;         // Must equal VMemPool::vAttrib
00043 //     VestaAttribsRep@ next;
00044 //     Bit32 timestamp;          // time of this change; used in replication
00045 //     char name[];              // NUL-terminated
00046 //     char value[];             // NUL-terminated
00047 // };
00048 
00049 // Some numbers derived from above
00050 #define VATTR_FLAGS 0
00051 #define VATTR_NEXT 1
00052 #define VATTR_TIMESTAMP 5
00053 #define VATTR_NAME 9
00054 #define VATTR_MINSIZE 11         // if name = value = ""
00055 
00056 class VestaAttribsRep {
00057   public:
00058     Bit8 rep[VATTR_MINSIZE]; // plus strlen(name) + strlen(value)
00059     inline bool visited() throw()
00060       { return (bool) ((rep[0] & 2) != 0); };
00061     inline void setVisited(bool newval) throw()
00062       { rep[0] = (rep[0] & 0xfd) | ((int)newval << 1); };
00063     inline VestaSource::attribOp op() throw()
00064       { return (VestaSource::attribOp) ((rep[VATTR_FLAGS] >> 2) & 3); };
00065     inline void setOp(VestaSource::attribOp op) throw()
00066       { rep[VATTR_FLAGS] = (rep[VATTR_FLAGS] & 0xf3) | (((int) op) << 2); };
00067     inline Bit32 next() throw()
00068       { Bit32 val; memcpy(&val, &rep[VATTR_NEXT], 4); return val; };
00069     inline void setNext(Bit32 newval) throw()
00070       { memcpy(&rep[VATTR_NEXT], &newval, 4); };
00071     inline time_t timestamp() throw()
00072       { Bit32 val; memcpy(&val, &rep[VATTR_TIMESTAMP], 4);
00073         return (time_t) val; };
00074     inline const char* name() throw()
00075       { return (const char*) &rep[VATTR_NAME]; };
00076     inline const char* value(int namelen) throw() // if you know strlen(name)
00077       { return (const char*) &rep[VATTR_NAME + namelen + 1]; };
00078     inline const char* value() throw() // if you don't know strlen(name)
00079       { return (const char*) &rep[VATTR_NAME + strlen(name()) + 1]; };
00080 
00081     // Return a pointer to a new VestaAttribsRep allocated in
00082     // the VMemPool.
00083     static VestaAttribsRep*
00084       create(VestaSource::attribOp op, const char* name,
00085              const char* value, time_t timestamp) throw();
00086 
00087     // VMemPool GC support
00088     void mark() throw();
00089     static void markCallback(void* closure, VMemPool::typeCode type) throw();
00090     static bool sweepCallback(void* closure, VMemPool::typeCode type,
00091                               void* addr, Bit32& size) throw();
00092     static void rebuildCallback(void* closure, VMemPool::typeCode type,
00093                                 void* addr, Bit32& size) throw();
00094 
00095     // Checkpoint support
00096   Bit32 checkpoint(Bit32& nextSP, std::fstream& ckpt) throw();
00097 };
00098 
00099 #endif //_VATTRR

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