CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / store / source / storbios.hxx
blob5eb60bc5b86125dba3bcf1bbc6daf1ec26fa5d7b
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 OStorePageBIOS();
42 /** Conversion into Mutex&
44 inline operator osl::Mutex& (void) const;
46 /** Initialization.
47 * @param pLockBytes [in]
48 * @param eAccessMode [in]
49 * @param rnPageSize [inout]
50 * @return store_E_None upon success
52 virtual storeError initialize (
53 ILockBytes * pLockBytes,
54 storeAccessMode eAccessMode,
55 sal_uInt16 & rnPageSize);
57 rtl::Reference< PageData::Allocator > & allocator()
59 return m_xAllocator;
62 storeError read (
63 sal_uInt32 nAddr, void *pData, sal_uInt32 nSize) const;
65 storeError write (
66 sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize) const;
68 inline bool isWriteable() const;
70 inline bool isValid() const;
72 storeError acquirePage (
73 const OStorePageDescriptor& rDescr, storeAccessMode eMode);
75 storeError releasePage (const OStorePageDescriptor& rDescr);
77 storeError allocate (OStorePageObject& rPage);
79 storeError free (sal_uInt32 nAddr);
81 /** Page I/O.
83 storeError loadObjectAt (
84 OStorePageObject& rPage, sal_uInt32 nAddr);
86 storeError saveObjectAt (
87 OStorePageObject& rPage, sal_uInt32 nAddr);
89 /** close.
90 @return store_E_None upon success.
92 storeError close();
94 /** flush.
95 @return store_E_None upon success.
97 storeError flush();
99 protected:
100 virtual ~OStorePageBIOS() override;
102 private:
103 rtl::Reference<ILockBytes> m_xLockBytes;
104 osl::Mutex m_aMutex;
106 std::unique_ptr<SuperBlockPage> m_pSuper;
108 bool m_bWriteable;
110 rtl::Reference< PageData::Allocator > m_xAllocator;
111 rtl::Reference< PageCache > m_xCache;
113 public:
114 /** Page Access (control).
116 struct Ace
118 Ace * m_next;
119 Ace * m_prev;
121 sal_uInt32 m_addr;
122 sal_uInt32 m_used;
124 Ace();
125 ~Ace();
127 static int SAL_CALL constructor (void * obj, void * arg);
129 static Ace * find (Ace * head, sal_uInt32 addr);
130 static void insert (Ace * head, Ace * entry);
133 private:
134 Ace m_ace_head;
136 class AceCache;
138 storeError initialize_Impl (
139 ILockBytes * pLockBytes,
140 storeAccessMode eAccessMode,
141 sal_uInt16 & rnPageSize);
142 void cleanup_Impl();
144 storeError loadObjectAt_Impl (
145 OStorePageObject & rPage, sal_uInt32 nAddr) const;
146 storeError saveObjectAt_Impl (
147 OStorePageObject & rPage, sal_uInt32 nAddr) const;
149 OStorePageBIOS (const OStorePageBIOS&) = delete;
150 OStorePageBIOS& operator= (const OStorePageBIOS&) = delete;
153 inline OStorePageBIOS::operator osl::Mutex& (void) const
155 return const_cast<osl::Mutex&>(m_aMutex);
158 inline bool OStorePageBIOS::isWriteable() const
160 return m_bWriteable;
163 inline bool OStorePageBIOS::isValid() const
165 return m_xLockBytes.is();
168 } // namespace store
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */