segment_header_item.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00038 #if !defined( _OESS_1__DB__STORAGE__IMPL__SEGMENT_HEADER_ITEM_HPP_ )
00039 #define _OESS_1__DB__STORAGE__IMPL__SEGMENT_HEADER_ITEM_HPP_
00040 
00041 #include <oess_1/defs/h/types.hpp>
00042 
00043 #include <oess_1/io/h/bin_data_size.hpp>
00044 #include <oess_1/io/h/binstream.hpp>
00045 
00046 #include <oess_1/db/storage/h/chain_id.hpp>
00047 
00048 namespace oess_1 {
00049 
00050 namespace db {
00051 
00052 namespace storage {
00053 
00054 namespace impl {
00055 
00056 //
00057 // segment_header_item_t
00058 //
00059 
00064 class segment_header_item_t
00065   {
00066   public :
00067     enum {
00069       image_size =
00070           oess_1::io::bin_data_size_t< chain_id_t >::image_size +
00071           oess_1::io::bin_data_size_t< chain_id_t >::image_size,
00072 
00075       uints_count = 2
00076     };
00077 
00079     segment_header_item_t()
00080       : m_self( invalid_chain_id )
00081       , m_next( invalid_chain_id )
00082       {}
00083 
00085     explicit segment_header_item_t(
00087       const chain_id_t & self,
00089       const chain_id_t & next = invalid_chain_id )
00090       : m_self( self )
00091       , m_next( next )
00092       {}
00093 
00095     const chain_id_t &
00096     self() const
00097       {
00098         return m_self;
00099       }
00100 
00102     const chain_id_t &
00103     next() const
00104       {
00105         return m_next;
00106       }
00107 
00109     void
00110     change_next( const chain_id_t & next )
00111       {
00112         m_next = next;
00113       }
00114 
00116 
00125     inline oess_1::uint_t *
00126     write_to(
00128       oess_1::uint_t * to ) const
00129       {
00130         *(to++) = m_self;
00131         *(to++) = m_next;
00132             
00133         return to;
00134       }
00135 
00137 
00146     inline const oess_1::uint_t *
00147     read_from(
00148       const oess_1::uint_t * from )
00149       {
00150         m_self = *(from++);
00151         m_next = *(from++);
00152       
00153         return from;
00154       }
00155 
00157 
00158     inline bool
00159     operator<( const segment_header_item_t & o ) const
00160       {
00161         return ( m_self < o.m_self );
00162       }
00163 
00164   private :
00166     chain_id_t  m_self;
00168     chain_id_t  m_next;
00169   };
00170 
00172 inline oess_1::uint_t *
00173 operator<<(
00174   oess_1::uint_t * to,
00175   const segment_header_item_t & what )
00176   {
00177     return what.write_to( to );
00178   }
00179 
00181 inline const oess_1::uint_t *
00182 operator>>(
00183   const oess_1::uint_t * from,
00184   segment_header_item_t & what )
00185   {
00186     return what.read_from( from );
00187   }
00188 
00189 } /* namespace impl */
00190 
00191 } /* namespace storage */
00192 
00193 } /* namespace db */
00194 
00195 } /* namespace oess_1 */
00196 
00197 #endif
00198 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:35 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz