1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: storbios.hxx,v $
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,
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"
45 #include "lockbyte.hxx"
46 #include "storbase.hxx"
47 #include "storcach.hxx"
49 /*========================================================================
53 *======================================================================*/
57 struct OStoreSuperBlockPage
;
59 class OStorePageBIOS
: public store::OStoreObject
64 OStorePageBIOS (void);
66 /** Conversion into Mutex&
68 inline operator osl::Mutex
& (void) const;
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()
88 storeError
acquireLock (
89 sal_uInt32 nAddr
, sal_uInt32 nSize
);
93 storeError
releaseLock (
94 sal_uInt32 nAddr
, sal_uInt32 nSize
);
99 sal_uInt32 nAddr
, void *pData
, sal_uInt32 nSize
);
104 sal_uInt32 nAddr
, const void *pData
, sal_uInt32 nSize
);
108 inline bool isModified (void) const;
112 inline bool isWriteable (void) const;
116 inline sal_Bool
isValid (void) const;
120 storeError
acquirePage (
121 const OStorePageDescriptor
& rDescr
, storeAccessMode eMode
);
123 storeError
releasePage (
124 const OStorePageDescriptor
& rDescr
, storeAccessMode eMode
);
126 sal_uInt32
getRefererCount (void);
137 storeError
allocate (
138 OStorePageObject
& rPage
, Allocation eAllocation
= ALLOCATE_FIRST
);
141 OStorePageData
& /* rData */, sal_uInt32 nAddr
);
145 storeError
loadObjectAt (
146 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
148 storeError
saveObjectAt (
149 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
152 * @return store_E_None upon success.
154 storeError
close (void);
157 * @return store_E_None upon success.
159 storeError
flush (void);
163 storeError
size (sal_uInt32
&rnSize
);
171 OStorePageDescriptor m_aDescr
;
177 inline ScanContext (void);
181 inline bool isValid (void) const;
186 storeError
scanBegin (
188 sal_uInt32 nMagic
= 0);
192 storeError
scanNext (
194 OStorePageObject
&rPage
);
197 /** Destruction (OReference).
199 virtual ~OStorePageBIOS (void);
204 rtl::Reference
<ILockBytes
> m_xLockBytes
;
207 typedef OStoreSuperBlockPage SuperPage
;
213 rtl::Reference
< PageData::Allocator
> m_xAllocator
;
214 rtl::Reference
< PageCache
> m_xCache
;
216 /** Page Access (control).
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
);
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.
253 OStorePageData
&rData
);
255 OStorePageData
&rData
);
257 storeError
loadObjectAt_Impl (
258 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
259 storeError
saveObjectAt_Impl (
260 OStorePageObject
& rPage
, sal_uInt32 nAddr
);
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
276 inline bool OStorePageBIOS::isWriteable (void) const
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 /*========================================================================
298 *======================================================================*/
302 #endif /* !_STORE_STORBIOS_HXX_ */