tdf#149186: Table of contents editor not showing buttons in Dutch UI
[LibreOffice.git] / store / source / storbios.hxx
blob3cea84bb2494114bc9b99c85990907128601d3c8
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 #pragma once
22 #include <sal/types.h>
23 #include <rtl/ref.hxx>
24 #include <osl/mutex.hxx>
26 #include <store/types.h>
27 #include "object.hxx"
28 #include "storbase.hxx"
30 namespace store
33 class ILockBytes;
34 class PageCache;
35 struct SuperBlockPage;
37 class OStorePageBIOS : public store::OStoreObject
39 public:
40 /** Construction.
42 OStorePageBIOS();
44 /** Conversion into Mutex&
46 inline operator osl::Mutex& (void) const;
48 /** Initialization.
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()
61 return m_xAllocator;
64 /** read.
66 storeError read (
67 sal_uInt32 nAddr, void *pData, sal_uInt32 nSize) const;
69 /** write.
71 storeError write (
72 sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize) const;
74 /** isWriteable.
76 inline bool isWriteable() const;
78 /** isValid.
80 inline bool isValid() const;
82 /** Page Access.
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);
93 /** Page I/O.
95 storeError loadObjectAt (
96 OStorePageObject& rPage, sal_uInt32 nAddr);
98 storeError saveObjectAt (
99 OStorePageObject& rPage, sal_uInt32 nAddr);
101 /** close.
102 * @return store_E_None upon success.
104 storeError close();
106 /** flush.
107 * @return store_E_None upon success.
109 storeError flush();
111 protected:
112 /** Destruction (OReference).
114 virtual ~OStorePageBIOS() override;
116 private:
117 /** Representation.
119 rtl::Reference<ILockBytes> m_xLockBytes;
120 osl::Mutex m_aMutex;
122 std::unique_ptr<SuperBlockPage> m_pSuper;
124 bool m_bWriteable;
126 rtl::Reference< PageData::Allocator > m_xAllocator;
127 rtl::Reference< PageCache > m_xCache;
129 /** Page Access (control).
131 public:
132 struct Ace
134 Ace * m_next;
135 Ace * m_prev;
137 sal_uInt32 m_addr;
138 sal_uInt32 m_used;
140 Ace();
141 ~Ace();
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);
149 private:
150 Ace m_ace_head;
152 class AceCache;
154 /** Initialization.
156 storeError initialize_Impl (
157 ILockBytes * pLockBytes,
158 storeAccessMode eAccessMode,
159 sal_uInt16 & rnPageSize);
160 void cleanup_Impl();
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
179 return m_bWriteable;
181 inline bool OStorePageBIOS::isValid() const
183 return m_xLockBytes.is();
186 } // namespace store
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */