00001 /*<std-header orig-src='shore' incl-file-exclusion='STID_T_H'> 00002 00003 $Id: stid_t.h,v 1.16 2012/01/02 17:02:10 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 #include <sthread.h> 00059 #include <w_hashing.h> 00060 00061 /**\brief A class that performs comparisons of snum_t for use with std::map */ 00062 struct compare_snum_t 00063 { 00064 bool operator() (snum_t const &a, snum_t const &b) const 00065 { 00066 return a < b; 00067 } 00068 }; 00069 00070 /**\brief Store ID. See \ref IDS. 00071 *\ingroup IDS 00072 * \details 00073 * This class represents a store identifier. 00074 * A store id is part of record identifiers, and by itself, it 00075 * identifies files and indexes. 00076 * It contains a volume identifier, vid_t. 00077 * 00078 * 00079 * See \ref IDS. 00080 */ 00081 struct stid_t { 00082 vid_t vol; 00083 fill2 filler; // vol is 2 bytes, store is now 4 00084 snum_t store; 00085 00086 stid_t(); 00087 stid_t(const stid_t& s); 00088 stid_t(vid_t vid, snum_t snum); 00089 00090 bool operator==(const stid_t& s) const; 00091 bool operator!=(const stid_t& s) const; 00092 00093 friend ostream& operator<<(ostream&, const stid_t& s); 00094 friend istream& operator>>(istream&, stid_t& s); 00095 00096 static const stid_t null; 00097 operator const void*() const; 00098 00099 w_base_t::uint4_t hash() const; 00100 private: 00101 static const w_hashing::hash2 _hash; 00102 }; 00103 00104 inline stid_t::stid_t(const stid_t& s) : vol(s.vol), store(s.store) 00105 {} 00106 00107 inline stid_t::stid_t() : vol(0), store(0) 00108 {} 00109 00110 inline stid_t::stid_t(vid_t v, snum_t s) : vol(v), store(s) 00111 {} 00112 00113 inline stid_t::operator const void*() const 00114 { 00115 return vol ? (void*) 1 : 0; 00116 } 00117 00118 00119 inline bool stid_t::operator==(const stid_t& s) const 00120 { 00121 return (vol == s.vol) && (store == s.store); 00122 } 00123 00124 inline bool stid_t::operator!=(const stid_t& s) const 00125 { 00126 return ! (*this == s); 00127 } 00128 00129 inline w_base_t::uint4_t stid_t::hash() const 00130 { 00131 return _hash(w_base_t::uint8_t((vol.vol<<16) + store)); 00132 } 00133 00134 /*<std-footer incl-file-exclusion='STID_T_H'> -- do not edit anything below this line -- */ 00135 00136 #endif /*</std-footer>*/