nss: upgrade to release 3.73
[LibreOffice.git] / store / source / storbios.hxx
blob6ba09a876e50ba37a4166e779289ebf5da6343b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include "object.hxx"
29 #include "storbase.hxx"
31 namespace store
34 class ILockBytes;
35 class PageCache;
36 struct SuperBlockPage;
38 class OStorePageBIOS : public store::OStoreObject
40 public:
41 /** Construction.
43 OStorePageBIOS();
45 /** Conversion into Mutex&
47 inline operator osl::Mutex& (void) const;
49 /** Initialization.
50 * @param pLockBytes [in]
51 * @param eAccessMode [in]
52 * @param rnPageSize [inout]
53 * @return store_E_None upon success
55 virtual storeError initialize (
56 ILockBytes * pLockBytes,
57 storeAccessMode eAccessMode,
58 sal_uInt16 & rnPageSize);
60 rtl::Reference< PageData::Allocator > & allocator()
62 return m_xAllocator;
65 /** read.
67 storeError read (
68 sal_uInt32 nAddr, void *pData, sal_uInt32 nSize) const;
70 /** write.
72 storeError write (
73 sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize) const;
75 /** isWriteable.
77 inline bool isWriteable() const;
79 /** isValid.
81 inline bool isValid() const;
83 /** Page Access.
85 storeError acquirePage (
86 const OStorePageDescriptor& rDescr, storeAccessMode eMode);
88 storeError releasePage (const OStorePageDescriptor& rDescr);
90 storeError allocate (OStorePageObject& rPage);
92 storeError free (sal_uInt32 nAddr);
94 /** Page I/O.
96 storeError loadObjectAt (
97 OStorePageObject& rPage, sal_uInt32 nAddr);
99 storeError saveObjectAt (
100 OStorePageObject& rPage, sal_uInt32 nAddr);
102 /** close.
103 * @return store_E_None upon success.
105 storeError close();
107 /** flush.
108 * @return store_E_None upon success.
110 storeError flush();
112 protected:
113 /** Destruction (OReference).
115 virtual ~OStorePageBIOS() override;
117 private:
118 /** Representation.
120 rtl::Reference<ILockBytes> m_xLockBytes;
121 osl::Mutex m_aMutex;
123 std::unique_ptr<SuperBlockPage> m_pSuper;
125 bool m_bWriteable;
127 rtl::Reference< PageData::Allocator > m_xAllocator;
128 rtl::Reference< PageCache > m_xCache;
130 /** Page Access (control).
132 public:
133 struct Ace
135 Ace * m_next;
136 Ace * m_prev;
138 sal_uInt32 m_addr;
139 sal_uInt32 m_used;
141 Ace();
142 ~Ace();
144 static int SAL_CALL constructor (void * obj, void * arg);
146 static Ace * find (Ace * head, sal_uInt32 addr);
147 static void insert (Ace * head, Ace * entry);
150 private:
151 Ace m_ace_head;
153 class AceCache;
155 /** Initialization.
157 storeError initialize_Impl (
158 ILockBytes * pLockBytes,
159 storeAccessMode eAccessMode,
160 sal_uInt16 & rnPageSize);
161 void cleanup_Impl();
163 /** Page Maintenance.
165 storeError loadObjectAt_Impl (
166 OStorePageObject & rPage, sal_uInt32 nAddr) const;
167 storeError saveObjectAt_Impl (
168 OStorePageObject & rPage, sal_uInt32 nAddr) const;
170 OStorePageBIOS (const OStorePageBIOS&) = delete;
171 OStorePageBIOS& operator= (const OStorePageBIOS&) = delete;
174 inline OStorePageBIOS::operator osl::Mutex& (void) const
176 return const_cast<osl::Mutex&>(m_aMutex);
178 inline bool OStorePageBIOS::isWriteable() const
180 return m_bWriteable;
182 inline bool OStorePageBIOS::isValid() const
184 return m_xLockBytes.is();
187 } // namespace store
189 #endif // INCLUDED_STORE_SOURCE_STORBIOS_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */