kvl_t.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='KVL_T_H'>
00002 
00003  $Id: kvl_t.h,v 1.10 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 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     v.calc_kvl(h), g = 0;
00102 }
00103 
00104 inline NORET
00105 kvl_t::kvl_t(stid_t id, const cvec_t& v1, const cvec_t& v2)
00106     : stid(id)  
00107 {
00108     v1.calc_kvl(h); v2.calc_kvl(g);
00109 }
00110 
00111 inline NORET
00112 kvl_t::~kvl_t()
00113 {
00114 }
00115 
00116 inline NORET
00117 kvl_t::kvl_t(const kvl_t& k)
00118     : stid(k.stid), h(k.h), g(k.g)
00119 {
00120 }
00121 
00122 inline kvl_t& 
00123 kvl_t::operator=(const kvl_t& k)
00124 {
00125     stid = k.stid;
00126     h = k.h, g = k.g;
00127     return *this;
00128 }
00129     
00130 
00131 inline kvl_t&
00132 kvl_t::set(stid_t s, const cvec_t& v)
00133 {
00134     stid = s, v.calc_kvl(h), g = 0;
00135     return *this;
00136 }
00137 
00138 inline kvl_t& 
00139 kvl_t::set(stid_t s, const cvec_t& v1, const cvec_t& v2)
00140 {
00141     stid = s, v1.calc_kvl(h), v2.calc_kvl(g);
00142     return *this;
00143 }
00144 
00145 inline bool
00146 kvl_t::operator==(const kvl_t& k) const
00147 {
00148     return h == k.h && g == k.g;
00149 }
00150 
00151 inline bool
00152 kvl_t::operator!=(const kvl_t& k) const
00153 {
00154     return ! (*this == k);
00155 }
00156 
00157 /*<std-footer incl-file-exclusion='KVL_T_H'>  -- do not edit anything below this line -- */
00158 
00159 #endif          /*</std-footer>*/

Generated on Thu Dec 9 08:42:26 2010 for Shore Storage Manager by  doxygen 1.4.7