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 .
22 #include <sal/types.h>
23 #include <rtl/ref.hxx>
24 #include <osl/mutex.hxx>
26 #include <store/types.h>
28 #include "storbase.hxx"
35 struct SuperBlockPage
;
37 class OStorePageBIOS
: public store::OStoreObject
44 /** Conversion into Mutex&
46 inline operator osl::Mutex
& (void) const;
49 * @param pLockBytes [in]
50 * @param eAccessMode [in]
51 * @param rnPageSize [inout]
52 * @return store_E_None upon success
54 virtual storeError
initialize (
55 ILockBytes
* pLockBytes
,
56 storeAccessMode eAccessMode
,
57 sal_uInt16
& rnPageSize
);
59 rtl::Reference
< PageData::Allocator
> & allocator()
67 sal_uInt32 nAddr
, void *pData
, sal_uInt32 nSize
) const;
72 sal_uInt32 nAddr
, const void *pData
, sal_uInt32 nSize
) const;
76 inline bool isWriteable() const;
80 inline bool isValid() const;
84 storeError
acquirePage (
85 const OStorePageDescriptor
& rDescr
, storeAccessMode eMode
);
87 storeError
releasePage (const OStorePageDescriptor
& rDescr
);
89 storeError
allocate (OStorePageObject
& rPage
);
91 storeError
free (sal_uInt32 nAddr
);
95 storeError
loadObjectAt (
96 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
98 storeError
saveObjectAt (
99 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
102 * @return store_E_None upon success.
107 * @return store_E_None upon success.
112 /** Destruction (OReference).
114 virtual ~OStorePageBIOS() override
;
119 rtl::Reference
<ILockBytes
> m_xLockBytes
;
122 std::unique_ptr
<SuperBlockPage
> m_pSuper
;
126 rtl::Reference
< PageData::Allocator
> m_xAllocator
;
127 rtl::Reference
< PageCache
> m_xCache
;
129 /** Page Access (control).
143 static int SAL_CALL
constructor (void * obj
, void * arg
);
145 static Ace
* find (Ace
* head
, sal_uInt32 addr
);
146 static void insert (Ace
* head
, Ace
* entry
);
156 storeError
initialize_Impl (
157 ILockBytes
* pLockBytes
,
158 storeAccessMode eAccessMode
,
159 sal_uInt16
& rnPageSize
);
162 /** Page Maintenance.
164 storeError
loadObjectAt_Impl (
165 OStorePageObject
& rPage
, sal_uInt32 nAddr
) const;
166 storeError
saveObjectAt_Impl (
167 OStorePageObject
& rPage
, sal_uInt32 nAddr
) const;
169 OStorePageBIOS (const OStorePageBIOS
&) = delete;
170 OStorePageBIOS
& operator= (const OStorePageBIOS
&) = delete;
173 inline OStorePageBIOS::operator osl::Mutex
& (void) const
175 return const_cast<osl::Mutex
&>(m_aMutex
);
177 inline bool OStorePageBIOS::isWriteable() const
181 inline bool OStorePageBIOS::isValid() const
183 return m_xLockBytes
.is();
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */