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 _STORE_STORBIOS_HXX_
21 #define _STORE_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
48 OStorePageBIOS (void);
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 (void) const;
86 inline sal_Bool
isValid (void) const;
90 storeError
acquirePage (
91 const OStorePageDescriptor
& rDescr
, storeAccessMode eMode
);
93 storeError
releasePage (const OStorePageDescriptor
& rDescr
);
95 sal_uInt32
getRefererCount (void);
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.
122 storeError
close (void);
125 * @return store_E_None upon success.
127 storeError
flush (void);
131 storeError
size (sal_uInt32
&rnSize
);
139 OStorePageDescriptor m_aDescr
;
145 inline ScanContext (void);
149 inline bool isValid (void) const;
154 storeError
scanBegin (
156 sal_uInt32 nMagic
= 0);
160 storeError
scanNext (
162 OStorePageObject
&rPage
);
165 /** Destruction (OReference).
167 virtual ~OStorePageBIOS (void);
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
);
224 OStorePageBIOS (const OStorePageBIOS
&);
225 OStorePageBIOS
& operator= (const OStorePageBIOS
&);
228 inline OStorePageBIOS::operator osl::Mutex
& (void) const
230 return (osl::Mutex
&)m_aMutex
;
232 inline bool OStorePageBIOS::isWriteable (void) const
236 inline sal_Bool
OStorePageBIOS::isValid (void) const
238 return m_xLockBytes
.is();
241 inline OStorePageBIOS::ScanContext::ScanContext (void)
242 : m_aDescr (0, 0, 0), m_nSize (0), m_nMagic (0)
245 inline bool OStorePageBIOS::ScanContext::isValid (void) const
247 return (m_aDescr
.m_nAddr
< m_nSize
);
250 /*========================================================================
254 *======================================================================*/
258 #endif /* !_STORE_STORBIOS_HXX_ */
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */