00001 /*<std-header orig-src='shore' incl-file-exclusion='STID_T_H'> 00002 00003 $Id: stid_t.h,v 1.13 2010/05/26 01:20:12 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 STID_T_H 00031 #define STID_T_H 00032 00033 #include "w_defines.h" 00034 00035 /* -- do not edit anything above this line -- </std-header>*/ 00036 00037 #ifdef __GNUC__ 00038 #pragma implementation 00039 #endif 00040 00041 /**\brief Store Number 00042 *\ingroup IDS 00043 * \details 00044 * This type represents a store number, 00045 * used when the volume id is implied somehow. 00046 * 00047 * See \ref IDS. 00048 */ 00049 typedef uint4_t snum_t; 00050 00051 #ifndef VID_T_H 00052 #include <vid_t.h> 00053 #endif 00054 #ifndef DEVID_T_H 00055 #include <devid_t.h> 00056 #endif 00057 00058 #define STID_T 00059 /**\brief A class that performs comparisons of snum_t for use with std::map */ 00060 struct compare_snum_t 00061 { 00062 bool operator() (snum_t const &a, snum_t const &b) const 00063 { 00064 return a < b; 00065 } 00066 }; 00067 00068 /**\brief Store ID. See \ref IDS. 00069 *\ingroup IDS 00070 * \details 00071 * This class represents a store identifier. 00072 * A store id is part of record identifiers, and by itself, it 00073 * identifies files and indexes. 00074 * It contains a volume identifier, vid_t. 00075 * 00076 * 00077 * See \ref IDS. 00078 */ 00079 struct stid_t { 00080 vid_t vol; 00081 fill2 filler; // vol is 2 bytes, store is now 4 00082 snum_t store; 00083 00084 stid_t(); 00085 stid_t(const stid_t& s); 00086 stid_t(vid_t vid, snum_t snum); 00087 00088 bool operator==(const stid_t& s) const; 00089 bool operator!=(const stid_t& s) const; 00090 00091 friend ostream& operator<<(ostream&, const stid_t& s); 00092 friend istream& operator>>(istream&, stid_t& s); 00093 00094 static const stid_t null; 00095 operator const void*() const; 00096 }; 00097 00098 inline stid_t::stid_t(const stid_t& s) : vol(s.vol), store(s.store) 00099 {} 00100 00101 inline stid_t::stid_t() : vol(0), store(0) 00102 {} 00103 00104 inline stid_t::stid_t(vid_t v, snum_t s) : vol(v), store(s) 00105 {} 00106 00107 inline stid_t::operator const void*() const 00108 { 00109 return vol ? (void*) 1 : 0; 00110 } 00111 00112 inline bool stid_t::operator==(const stid_t& s) const 00113 { 00114 return (vol == s.vol) && (store == s.store); 00115 } 00116 00117 inline bool stid_t::operator!=(const stid_t& s) const 00118 { 00119 return ! (*this == s); 00120 } 00121 00122 00123 inline w_base_t::uint4_t w_hash(const stid_t &s) 00124 { 00125 return (s.vol.vol << 16) ^ s.store; 00126 } 00127 00128 /*<std-footer incl-file-exclusion='STID_T_H'> -- do not edit anything below this line -- */ 00129 00130 #endif /*</std-footer>*/