LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/store/source - storbios.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 13 61.5 %
Date: 2013-07-09 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _STORE_STORBIOS_HXX_
      21             : #define _STORE_STORBIOS_HXX_
      22             : 
      23             : #include "sal/types.h"
      24             : #include "rtl/ref.hxx"
      25             : #include "osl/mutex.hxx"
      26             : 
      27             : #include "store/types.h"
      28             : #include "object.hxx"
      29             : #include "lockbyte.hxx"
      30             : #include "storbase.hxx"
      31             : #include "storcach.hxx"
      32             : 
      33             : /*========================================================================
      34             :  *
      35             :  * OStorePageBIOS.
      36             :  *
      37             :  *======================================================================*/
      38             : namespace store
      39             : {
      40             : 
      41             : struct SuperBlockPage;
      42             : 
      43             : class OStorePageBIOS : public store::OStoreObject
      44             : {
      45             : public:
      46             :     /** Construction.
      47             :      */
      48             :     OStorePageBIOS (void);
      49             : 
      50             :     /** Conversion into Mutex&
      51             :      */
      52             :     inline operator osl::Mutex& (void) const;
      53             : 
      54             :     /** Initialization.
      55             :      *  @param  pLockBytes [in]
      56             :      *  @param  eAccessMode [in]
      57             :      *  @param  rnPageSize [inout]
      58             :      *  @return store_E_None upon success
      59             :      */
      60             :     virtual storeError initialize (
      61             :         ILockBytes *    pLockBytes,
      62             :         storeAccessMode eAccessMode,
      63             :         sal_uInt16 &    rnPageSize);
      64             : 
      65       93477 :     rtl::Reference< PageData::Allocator > & allocator()
      66             :     {
      67       93477 :         return m_xAllocator;
      68             :     }
      69             : 
      70             :     /** read.
      71             :      */
      72             :     storeError read (
      73             :         sal_uInt32 nAddr, void *pData, sal_uInt32 nSize);
      74             : 
      75             :     /** write.
      76             :      */
      77             :     storeError write (
      78             :         sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize);
      79             : 
      80             :     /** isWriteable.
      81             :      */
      82             :     inline bool isWriteable (void) const;
      83             : 
      84             :     /** isValid.
      85             :      */
      86             :     inline sal_Bool isValid (void) const;
      87             : 
      88             :     /** Page Access.
      89             :      */
      90             :     storeError acquirePage (
      91             :         const OStorePageDescriptor& rDescr, storeAccessMode eMode);
      92             : 
      93             :     storeError releasePage (const OStorePageDescriptor& rDescr);
      94             : 
      95             :     sal_uInt32 getRefererCount (void);
      96             : 
      97             :     /** Page Allocation.
      98             :      */
      99             :     enum Allocation
     100             :     {
     101             :         ALLOCATE_FIRST = 0,
     102             :         ALLOCATE_BEST  = 1,
     103             :         ALLOCATE_EOF   = 2
     104             :     };
     105             : 
     106             :     storeError allocate (
     107             :         OStorePageObject& rPage, Allocation eAllocation = ALLOCATE_FIRST);
     108             : 
     109             :     storeError free (sal_uInt32 nAddr);
     110             : 
     111             :     /** Page I/O.
     112             :      */
     113             :     storeError loadObjectAt (
     114             :         OStorePageObject& rPage, sal_uInt32 nAddr);
     115             : 
     116             :     storeError saveObjectAt (
     117             :         OStorePageObject& rPage, sal_uInt32 nAddr);
     118             : 
     119             :     /** close.
     120             :      *  @return store_E_None upon success.
     121             :      */
     122             :     storeError close (void);
     123             : 
     124             :     /** flush.
     125             :      *  @return store_E_None upon success.
     126             :      */
     127             :     storeError flush (void);
     128             : 
     129             :     /** size.
     130             :      */
     131             :     storeError size (sal_uInt32 &rnSize);
     132             : 
     133             :     /** ScanContext.
     134             :      */
     135             :     struct ScanContext
     136             :     {
     137             :         /** Representation.
     138             :          */
     139             :         OStorePageDescriptor m_aDescr;
     140             :         sal_uInt32           m_nSize;
     141             :         sal_uInt32           m_nMagic;
     142             : 
     143             :         /** Construction.
     144             :          */
     145             :         inline ScanContext (void);
     146             : 
     147             :         /** isValid.
     148             :          */
     149             :         inline bool isValid (void) const;
     150             :     };
     151             : 
     152             :     /** scanBegin.
     153             :      */
     154             :     storeError scanBegin (
     155             :         ScanContext &rCtx,
     156             :         sal_uInt32   nMagic = 0);
     157             : 
     158             :     /** scanNext.
     159             :      */
     160             :     storeError scanNext (
     161             :         ScanContext      &rCtx,
     162             :         OStorePageObject &rPage);
     163             : 
     164             : protected:
     165             :     /** Destruction (OReference).
     166             :      */
     167             :     virtual ~OStorePageBIOS (void);
     168             : 
     169             : private:
     170             :     /** Representation.
     171             :      */
     172             :     rtl::Reference<ILockBytes>    m_xLockBytes;
     173             :     osl::Mutex                    m_aMutex;
     174             : 
     175             :     SuperBlockPage *              m_pSuper;
     176             : 
     177             :     bool                          m_bWriteable;
     178             : 
     179             :     rtl::Reference< PageData::Allocator > m_xAllocator;
     180             :     rtl::Reference< PageCache >   m_xCache;
     181             : 
     182             :     /** Page Access (control).
     183             :      */
     184             : public:
     185             :     struct Ace
     186             :     {
     187             :         Ace *      m_next;
     188             :         Ace *      m_prev;
     189             : 
     190             :         sal_uInt32 m_addr;
     191             :         sal_uInt32 m_used;
     192             : 
     193             :         Ace();
     194             :         ~Ace();
     195             : 
     196             :         static int SAL_CALL constructor (void * obj, void * arg);
     197             : 
     198             :         static Ace * find   (Ace * head, sal_uInt32 addr);
     199             :         static void  insert (Ace * head, Ace * entry);
     200             :     };
     201             : 
     202             : private:
     203             :     Ace m_ace_head;
     204             : 
     205             :     class AceCache;
     206             : 
     207             :     /** Initialization.
     208             :      */
     209             :     storeError initialize_Impl (
     210             :         ILockBytes *    pLockBytes,
     211             :         storeAccessMode eAccessMode,
     212             :         sal_uInt16 &    rnPageSize);
     213             :     void cleanup_Impl();
     214             : 
     215             :     /** Page Maintenance.
     216             :      */
     217             :     storeError loadObjectAt_Impl (
     218             :         OStorePageObject & rPage, sal_uInt32 nAddr);
     219             :     storeError saveObjectAt_Impl (
     220             :         OStorePageObject & rPage, sal_uInt32 nAddr);
     221             : 
     222             :     /** Not implemented.
     223             :      */
     224             :     OStorePageBIOS (const OStorePageBIOS&);
     225             :     OStorePageBIOS& operator= (const OStorePageBIOS&);
     226             : };
     227             : 
     228      908636 : inline OStorePageBIOS::operator osl::Mutex& (void) const
     229             : {
     230      908636 :     return (osl::Mutex&)m_aMutex;
     231             : }
     232       82137 : inline bool OStorePageBIOS::isWriteable (void) const
     233             : {
     234       82137 :     return m_bWriteable;
     235             : }
     236      501743 : inline sal_Bool OStorePageBIOS::isValid (void) const
     237             : {
     238      501743 :     return m_xLockBytes.is();
     239             : }
     240             : 
     241           0 : inline OStorePageBIOS::ScanContext::ScanContext (void)
     242           0 :     : m_aDescr (0, 0, 0), m_nSize (0), m_nMagic (0)
     243             : {
     244           0 : }
     245           0 : inline bool OStorePageBIOS::ScanContext::isValid (void) const
     246             : {
     247           0 :     return (m_aDescr.m_nAddr < m_nSize);
     248             : }
     249             : 
     250             : /*========================================================================
     251             :  *
     252             :  * The End.
     253             :  *
     254             :  *======================================================================*/
     255             : 
     256             : } // namespace store
     257             : 
     258             : #endif /* !_STORE_STORBIOS_HXX_ */
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10