kvl_t.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='KVL_T_H'>
00002 
00003  $Id: kvl_t.h,v 1.12 2012/01/02 21:52:20 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 KVL_T_H
00031 #define KVL_T_H
00032 
00033 #include "w_defines.h"
00034 
00035 /*  -- do not edit anything above this line --   </std-header>*/
00036 
00037 /* NB: you must already have defined the type size_t,
00038  * (which is defined include "basics.h") before you include this.
00039  */
00040 
00041 #ifdef __GNUG__
00042 #pragma interface
00043 #endif
00044 
00045 #ifndef STID_T_H
00046 #include "stid_t.h"
00047 #endif
00048 #ifndef VEC_T_H
00049 #include "vec_t.h"
00050 #endif
00051 
00052 /**\brief Key-Value Lock identifier.
00053  *
00054  * \details
00055  * Used by the lock manager.
00056  */
00057 struct kvl_t {
00058     stid_t            stid;
00059     w_base_t::uint4_t        h;
00060     w_base_t::uint4_t        g;
00061 
00062     static const cvec_t eof;
00063     static const cvec_t bof;
00064 
00065     // Empty key-value
00066     NORET            kvl_t();
00067     // Empty key-value lock id for a store ID.
00068     NORET            kvl_t(stid_t id, const cvec_t& v);
00069     // Empty key-value lock id for a store ID.
00070     NORET            kvl_t(
00071         stid_t                _stid,
00072         const cvec_t&         v1, 
00073         const cvec_t&         v2);
00074 
00075     NORET            ~kvl_t();
00076     
00077     NORET            kvl_t(const kvl_t& k);
00078 
00079     kvl_t&             operator=(const kvl_t& k);
00080 
00081     kvl_t&             set(stid_t s, const cvec_t& v);
00082     kvl_t&             set(stid_t s,
00083         const cvec_t&         v1,
00084         const cvec_t&         v2);
00085     bool operator==(const kvl_t& k) const;
00086     bool operator!=(const kvl_t& k) const;
00087     friend ostream& operator<<(ostream&, const kvl_t& k);
00088     friend istream& operator>>(istream&, kvl_t& k);
00089 };
00090 
00091 inline NORET
00092 kvl_t::kvl_t()
00093     : stid(stid_t::null), h(0), g(0)
00094 {
00095 }
00096 
00097 inline NORET
00098 kvl_t::kvl_t(stid_t id, const cvec_t& v)
00099     : stid(id)
00100 {
00101  // don't waste "g" for uni_btree. uses different hash seed
00102     v.calc_kvl(h), v.calc_kvl2(g); 
00103     v.calc_kvl(h), v.calc_kvl2(g); 
00104 }
00105 
00106 inline NORET
00107 kvl_t::kvl_t(stid_t id, const cvec_t& v1, const cvec_t& v2)
00108     : stid(id)  
00109 {
00110     v1.calc_kvl(h); v2.calc_kvl(g);
00111 }
00112 
00113 inline NORET
00114 kvl_t::~kvl_t()
00115 {
00116 }
00117 
00118 inline NORET
00119 kvl_t::kvl_t(const kvl_t& k)
00120     : stid(k.stid), h(k.h), g(k.g)
00121 {
00122 }
00123 
00124 inline kvl_t& 
00125 kvl_t::operator=(const kvl_t& k)
00126 {
00127     stid = k.stid;
00128     h = k.h, g = k.g;
00129     return *this;
00130 }
00131     
00132 
00133 inline kvl_t&
00134 kvl_t::set(stid_t s, const cvec_t& v)
00135 {
00136  // don't waste "g" for uni_btree. uses different hash seed
00137     stid = s, v.calc_kvl(h), v.calc_kvl2(g); 
00138     return *this;
00139 }
00140 
00141 inline kvl_t& 
00142 kvl_t::set(stid_t s, const cvec_t& v1, const cvec_t& v2)
00143 {
00144     stid = s, v1.calc_kvl(h), v2.calc_kvl(g);
00145     return *this;
00146 }
00147 
00148 inline bool
00149 kvl_t::operator==(const kvl_t& k) const
00150 {
00151     return h == k.h && g == k.g;
00152 }
00153 
00154 inline bool
00155 kvl_t::operator!=(const kvl_t& k) const
00156 {
00157     return ! (*this == k);
00158 }
00159 
00160 /*<std-footer incl-file-exclusion='KVL_T_H'>  -- do not edit anything below this line -- */
00161 
00162 #endif          /*</std-footer>*/

Generated on Mon Jan 2 15:13:56 2012 for Shore Storage Manager by  doxygen 1.4.7