lid_t.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='LID_T_H'>
00002 
00003  $Id: lid_t.h,v 1.37 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 LID_T_H
00031 #define LID_T_H
00032 
00033 #include "w_defines.h"
00034 
00035 /*  -- do not edit anything above this line --   </std-header>*/
00036 
00037 #ifndef BASICS_H
00038 #include "basics.h"
00039 #endif
00040 
00041 #ifdef __GNUG__
00042 #pragma interface
00043 #endif
00044 
00045 /*********************************************************************
00046  * Logical IDs
00047  *
00048  ********************************************************************/
00049 
00050 /**\addtogroup IDS 
00051  * The following persistent storage structures have identifiers, not
00052  * all of which(ids) are persistent:
00053  * - Indexes: stid_t (store id)
00054  * - Files:   stid_t (store id)
00055  * - Records: rid_t (record id)
00056  * - Pages:   pid_t (short page id), lpid_t (long page id)
00057  * - Volumes: vid_t (short volume id), lvid_t (long volume id)
00058  * - Device
00059  */
00060 
00061 /*
00062     Physical volume IDs (vid_t) are currently used to make unique
00063     long volume IDs.  This is a temporary hack which we support with
00064     this typedef:
00065 */
00066 typedef uint2_t VID_T;
00067 
00068 #define LVID_T
00069 /**\brief long volume ID.  See \ref IDS. 
00070  *\ingroup IDS
00071  *
00072  * \details A long, almost-unique identifier for a volume, generated from
00073  * a clock and a network address. Written to a volume's header.
00074  * This is the only persistent identifier for a volume, and it is
00075  * used to be sure that one doesn't doubly-mount a volume via different
00076  * paths. 
00077  * Thus, in certain sm methods, the long volume ID is used to identify
00078  * a volume, e.g., in destroy_vol, get_volume_quota.
00079 */
00080 struct lvid_t {
00081     /* usually generated from net addr of creating server */
00082     uint4_t high;
00083     /* usually generated from timeofday when created */
00084     uint4_t low;
00085 
00086     /* do not want constructors for things embeded in objects. */
00087     lvid_t() : high(0), low(0) {}
00088     lvid_t(uint4_t hi, uint4_t lo) : high(hi), low(lo) {}
00089         
00090     bool operator==(const lvid_t& s) const
00091                         {return (low == s.low) && (high == s.high);}
00092     bool operator!=(const lvid_t& s) const
00093                         {return (low != s.low) || (high != s.high);}
00094 
00095     // in lid_t.cpp:
00096     friend ostream& operator<<(ostream&, const lvid_t&);
00097     friend istream& operator>>(istream&, lvid_t&);
00098 
00099     // defined in lid_t.cpp
00100     static const lvid_t null;
00101 };
00102 
00103 
00104 inline w_base_t::uint4_t w_hash(const lvid_t& lv)
00105 {
00106     return lv.high + lv.low;
00107 }
00108 #endif

Generated on Wed Jul 7 17:22:32 2010 for Shore Storage Manager by  doxygen 1.4.7