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