merge the formfield patch from ooo-build
[ooovba.git] / store / source / storbios.hxx
blobd9a0f982bd3c31436cfacf3d28bfa4f52811b4e7
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: storbios.hxx,v $
7 * $Revision: 1.1.2.3 $
9 * last change: $Author: mhu $ $Date: 2008/10/31 18:28:18 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 #ifndef _STORE_STORBIOS_HXX_
37 #define _STORE_STORBIOS_HXX_ "$Revision: 1.1.2.3 $"
39 #include "sal/types.h"
40 #include "rtl/ref.hxx"
41 #include "osl/mutex.hxx"
43 #include "store/types.h"
44 #include "object.hxx"
45 #include "lockbyte.hxx"
46 #include "storbase.hxx"
47 #include "storcach.hxx"
49 /*========================================================================
51 * OStorePageBIOS.
53 *======================================================================*/
54 namespace store
57 struct OStoreSuperBlockPage;
59 class OStorePageBIOS : public store::OStoreObject
61 public:
62 /** Construction.
64 OStorePageBIOS (void);
66 /** Conversion into Mutex&
68 inline operator osl::Mutex& (void) const;
70 /** Initialization.
71 * @param pLockBytes [in]
72 * @param eAccessMode [in]
73 * @param rnPageSize [inout]
74 * @return store_E_None upon success
76 virtual storeError initialize (
77 ILockBytes * pLockBytes,
78 storeAccessMode eAccessMode,
79 sal_uInt16 & rnPageSize);
81 rtl::Reference< PageData::Allocator > & allocator()
83 return m_xAllocator;
86 /** acquireLock.
88 storeError acquireLock (
89 sal_uInt32 nAddr, sal_uInt32 nSize);
91 /** releaseLock.
93 storeError releaseLock (
94 sal_uInt32 nAddr, sal_uInt32 nSize);
96 /** read.
98 storeError read (
99 sal_uInt32 nAddr, void *pData, sal_uInt32 nSize);
101 /** write.
103 storeError write (
104 sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize);
106 /** isModified.
108 inline bool isModified (void) const;
110 /** isWriteable.
112 inline bool isWriteable (void) const;
114 /** isValid.
116 inline sal_Bool isValid (void) const;
118 /** Page Access.
120 storeError acquirePage (
121 const OStorePageDescriptor& rDescr, storeAccessMode eMode);
123 storeError releasePage (
124 const OStorePageDescriptor& rDescr, storeAccessMode eMode);
126 sal_uInt32 getRefererCount (void);
128 /** Page Allocation.
130 enum Allocation
132 ALLOCATE_FIRST = 0,
133 ALLOCATE_BEST = 1,
134 ALLOCATE_EOF = 2
137 storeError allocate (
138 OStorePageObject& rPage, Allocation eAllocation = ALLOCATE_FIRST);
140 storeError free (
141 OStorePageData & /* rData */, sal_uInt32 nAddr);
143 /** Page I/O.
145 storeError loadObjectAt (
146 OStorePageObject& rPage, sal_uInt32 nAddr);
148 storeError saveObjectAt (
149 OStorePageObject& rPage, sal_uInt32 nAddr);
151 /** close.
152 * @return store_E_None upon success.
154 storeError close (void);
156 /** flush.
157 * @return store_E_None upon success.
159 storeError flush (void);
161 /** size.
163 storeError size (sal_uInt32 &rnSize);
165 /** ScanContext.
167 struct ScanContext
169 /** Representation.
171 OStorePageDescriptor m_aDescr;
172 sal_uInt32 m_nSize;
173 sal_uInt32 m_nMagic;
175 /** Construction.
177 inline ScanContext (void);
179 /** isValid.
181 inline bool isValid (void) const;
184 /** scanBegin.
186 storeError scanBegin (
187 ScanContext &rCtx,
188 sal_uInt32 nMagic = 0);
190 /** scanNext.
192 storeError scanNext (
193 ScanContext &rCtx,
194 OStorePageObject &rPage);
196 protected:
197 /** Destruction (OReference).
199 virtual ~OStorePageBIOS (void);
201 private:
202 /** Representation.
204 rtl::Reference<ILockBytes> m_xLockBytes;
205 osl::Mutex m_aMutex;
207 typedef OStoreSuperBlockPage SuperPage;
208 SuperPage *m_pSuper;
210 bool m_bModified;
211 bool m_bWriteable;
213 rtl::Reference< PageData::Allocator > m_xAllocator;
214 rtl::Reference< PageCache > m_xCache;
216 /** Page Access (control).
218 public:
219 struct Ace
221 Ace * m_next;
222 Ace * m_prev;
224 sal_uInt32 m_addr;
225 sal_uInt32 m_used;
227 Ace();
228 ~Ace();
230 static int SAL_CALL constructor (void * obj, void * arg);
232 static Ace * find (Ace * head, sal_uInt32 addr);
233 static void insert (Ace * head, Ace * entry);
236 private:
237 Ace m_ace_head;
239 class AceCache;
241 /** create (SuperBlock).
243 storeError create (sal_uInt16 nPageSize);
245 /** SuperBlock verification and repair.
247 storeError verify (SuperPage *&rpSuper);
248 storeError repair (SuperPage *&rpSuper);
250 /** Page Maintenance.
252 storeError peek (
253 OStorePageData &rData);
254 storeError poke (
255 OStorePageData &rData);
257 storeError loadObjectAt_Impl (
258 OStorePageObject & rPage, sal_uInt32 nAddr);
259 storeError saveObjectAt_Impl (
260 OStorePageObject & rPage, sal_uInt32 nAddr);
262 /** Not implemented.
264 OStorePageBIOS (const OStorePageBIOS&);
265 OStorePageBIOS& operator= (const OStorePageBIOS&);
268 inline OStorePageBIOS::operator osl::Mutex& (void) const
270 return (osl::Mutex&)m_aMutex;
272 inline bool OStorePageBIOS::isModified (void) const
274 return m_bModified;
276 inline bool OStorePageBIOS::isWriteable (void) const
278 return m_bWriteable;
280 inline sal_Bool OStorePageBIOS::isValid (void) const
282 return m_xLockBytes.is();
285 inline OStorePageBIOS::ScanContext::ScanContext (void)
286 : m_aDescr (0, 0, 0), m_nSize (0), m_nMagic (0)
289 inline bool OStorePageBIOS::ScanContext::isValid (void) const
291 return (m_aDescr.m_nAddr < m_nSize);
294 /*========================================================================
296 * The End.
298 *======================================================================*/
300 } // namespace store
302 #endif /* !_STORE_STORBIOS_HXX_ */