00001 /*<std-header orig-src='shore' incl-file-exclusion='VID_T_H'> 00002 00003 $Id: vid_t.h,v 1.28 2010/06/23 23:43:29 nhall Exp $ 00004 00005 SHORE -- Scalable Heterogeneous Object REpository 00006 00007 Copyright (c) 1994-99 Computer Sciences Department, University of 00008 Wisconsin -- Madison 00009 All Rights Reserved. 00010 00011 Permission to use, copy, modify and distribute this software and its 00012 documentation is hereby granted, provided that both the copyright 00013 notice and this permission notice appear in all copies of the 00014 software, derivative works or modified versions, and any portions 00015 thereof, and that both notices appear in supporting documentation. 00016 00017 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY 00018 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS 00019 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND 00020 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 00021 00022 This software was developed with support by the Advanced Research 00023 Project Agency, ARPA order number 018 (formerly 8230), monitored by 00024 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518. 00025 Further funding for this work was provided by DARPA through 00026 Rome Research Laboratory Contract No. F30602-97-2-0247. 00027 00028 */ 00029 00030 #ifndef VID_T_H 00031 #define VID_T_H 00032 00033 #include "w_defines.h" 00034 00035 /* -- do not edit anything above this line -- </std-header>*/ 00036 00037 #ifdef __GNUG__ 00038 // implementation is in lid_t.cpp 00039 #pragma interface 00040 #endif 00041 00042 /**\brief Volume ID. See \ref IDS. 00043 *\ingroup IDS 00044 * \details 00045 * This class represents a volume identifier, the id that is persistent 00046 * in the database. It is usually a short integer. 00047 * Its size is two bytes. 00048 * 00049 * A volume id is part of record identifiers and store identifiers, 00050 * as well as part of "long" page identifiers. 00051 * 00052 * See \ref IDS. 00053 */ 00054 struct vid_t { 00055 00056 enum { 00057 first_local = 1 00058 }; 00059 00060 vid_t() : vol(0) {} 00061 vid_t(uint2_t v) : vol(v) {} 00062 void init_local() {vol = first_local;} 00063 00064 void incr_local() { 00065 vol++; 00066 } 00067 00068 // This function casts a vid_t to a uint2_t. It is needed 00069 // in lid_t.h where there is a hack to use vid_t to 00070 // create a long volume ID. 00071 operator uint2_t () const {return vol;} 00072 00073 // Data Members 00074 uint2_t vol; 00075 00076 static const vid_t null; 00077 friend inline ostream& operator<<(ostream&, const vid_t& v); 00078 friend inline istream& operator>>(istream&, vid_t& v); 00079 friend bool operator==(const vid_t& v1, const vid_t& v2) { 00080 return v1.vol == v2.vol; 00081 } 00082 friend bool operator!=(const vid_t& v1, const vid_t& v2) { 00083 return v1.vol != v2.vol; 00084 } 00085 }; 00086 00087 inline ostream& operator<<(ostream& o, const vid_t& v) 00088 { 00089 return o << v.vol; 00090 } 00091 00092 inline istream& operator>>(istream& i, vid_t& v) 00093 { 00094 return i >> v.vol; 00095 } 00096 00097 /*<std-footer incl-file-exclusion='VID_T_H'> -- do not edit anything below this line -- */ 00098 00099 #endif /*</std-footer>*/