1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_STORE_SOURCE_STORBIOS_HXX
21 #define INCLUDED_STORE_SOURCE_STORBIOS_HXX
23 #include "sal/types.h"
24 #include "rtl/ref.hxx"
25 #include "osl/mutex.hxx"
27 #include "store/types.h"
29 #include "lockbyte.hxx"
30 #include "storbase.hxx"
31 #include "storcach.hxx"
33 /*========================================================================
37 *======================================================================*/
41 struct SuperBlockPage
;
43 class OStorePageBIOS
: public store::OStoreObject
50 /** Conversion into Mutex&
52 inline operator osl::Mutex
& (void) const;
55 * @param pLockBytes [in]
56 * @param eAccessMode [in]
57 * @param rnPageSize [inout]
58 * @return store_E_None upon success
60 virtual storeError
initialize (
61 ILockBytes
* pLockBytes
,
62 storeAccessMode eAccessMode
,
63 sal_uInt16
& rnPageSize
);
65 rtl::Reference
< PageData::Allocator
> & allocator()
73 sal_uInt32 nAddr
, void *pData
, sal_uInt32 nSize
);
78 sal_uInt32 nAddr
, const void *pData
, sal_uInt32 nSize
);
82 inline bool isWriteable() const;
86 inline bool isValid() const;
90 storeError
acquirePage (
91 const OStorePageDescriptor
& rDescr
, storeAccessMode eMode
);
93 storeError
releasePage (const OStorePageDescriptor
& rDescr
);
95 sal_uInt32
getRefererCount();
106 storeError
allocate (
107 OStorePageObject
& rPage
, Allocation eAllocation
= ALLOCATE_FIRST
);
109 storeError
free (sal_uInt32 nAddr
);
113 storeError
loadObjectAt (
114 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
116 storeError
saveObjectAt (
117 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
120 * @return store_E_None upon success.
125 * @return store_E_None upon success.
131 storeError
size (sal_uInt32
&rnSize
);
139 OStorePageDescriptor m_aDescr
;
145 inline ScanContext();
149 inline bool isValid() const;
154 storeError
scanBegin (
156 sal_uInt32 nMagic
= 0);
160 storeError
scanNext (
162 OStorePageObject
&rPage
);
165 /** Destruction (OReference).
167 virtual ~OStorePageBIOS();
172 rtl::Reference
<ILockBytes
> m_xLockBytes
;
175 SuperBlockPage
* m_pSuper
;
179 rtl::Reference
< PageData::Allocator
> m_xAllocator
;
180 rtl::Reference
< PageCache
> m_xCache
;
182 /** Page Access (control).
196 static int SAL_CALL
constructor (void * obj
, void * arg
);
198 static Ace
* find (Ace
* head
, sal_uInt32 addr
);
199 static void insert (Ace
* head
, Ace
* entry
);
209 storeError
initialize_Impl (
210 ILockBytes
* pLockBytes
,
211 storeAccessMode eAccessMode
,
212 sal_uInt16
& rnPageSize
);
215 /** Page Maintenance.
217 storeError
loadObjectAt_Impl (
218 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
219 storeError
saveObjectAt_Impl (
220 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
222 OStorePageBIOS (const OStorePageBIOS
&) SAL_DELETED_FUNCTION
;
223 OStorePageBIOS
& operator= (const OStorePageBIOS
&) SAL_DELETED_FUNCTION
;
226 inline OStorePageBIOS::operator osl::Mutex
& (void) const
228 return (osl::Mutex
&)m_aMutex
;
230 inline bool OStorePageBIOS::isWriteable() const
234 inline bool OStorePageBIOS::isValid() const
236 return m_xLockBytes
.is();
239 inline OStorePageBIOS::ScanContext::ScanContext()
240 : m_aDescr (0, 0, 0), m_nSize (0), m_nMagic (0)
243 inline bool OStorePageBIOS::ScanContext::isValid() const
245 return (m_aDescr
.m_nAddr
< m_nSize
);
248 /*========================================================================
252 *======================================================================*/
256 #endif // INCLUDED_STORE_SOURCE_STORBIOS_HXX
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */