xref: /aoo41x/main/store/source/storlckb.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _STORE_STORLCKB_HXX_
29*cdf0e10cSrcweir #define _STORE_STORLCKB_HXX_ "$Revision: 1.6.8.1 $"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/types.h"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "rtl/ustring.h"
34*cdf0e10cSrcweir #include "rtl/ref.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "object.hxx"
37*cdf0e10cSrcweir #include "storbase.hxx"
38*cdf0e10cSrcweir #include "storpage.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace store
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir struct OStoreDataPageData;
44*cdf0e10cSrcweir struct OStoreDirectoryPageData;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir /*========================================================================
47*cdf0e10cSrcweir  *
48*cdf0e10cSrcweir  * OStoreLockBytes interface.
49*cdf0e10cSrcweir  *
50*cdf0e10cSrcweir  *======================================================================*/
51*cdf0e10cSrcweir class OStoreLockBytes : public store::OStoreObject
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir public:
54*cdf0e10cSrcweir 	/** Construction.
55*cdf0e10cSrcweir 	 */
56*cdf0e10cSrcweir 	OStoreLockBytes (void);
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	/** create (two-phase construction).
59*cdf0e10cSrcweir 	 *  @param  pManager [in]
60*cdf0e10cSrcweir 	 *  @param  pPath [in]
61*cdf0e10cSrcweir 	 *  @param  pName [in]
62*cdf0e10cSrcweir 	 *  @param  eMode [in]
63*cdf0e10cSrcweir 	 *  @return store_E_None upon success
64*cdf0e10cSrcweir 	 */
65*cdf0e10cSrcweir 	storeError create (
66*cdf0e10cSrcweir 		OStorePageManager *pManager,
67*cdf0e10cSrcweir 		rtl_String        *pPath,
68*cdf0e10cSrcweir 		rtl_String        *pName,
69*cdf0e10cSrcweir 		storeAccessMode    eAccessMode);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	/** Read at Offset into Buffer.
72*cdf0e10cSrcweir 	 *  @param  nOffset [in]
73*cdf0e10cSrcweir 	 *  @param  pBuffer [out]
74*cdf0e10cSrcweir 	 *  @param  nBytes [in]
75*cdf0e10cSrcweir 	 *  @param  rnDone [out]
76*cdf0e10cSrcweir 	 *  @return store_E_None upon success
77*cdf0e10cSrcweir 	 */
78*cdf0e10cSrcweir 	storeError readAt (
79*cdf0e10cSrcweir 		sal_uInt32  nOffset,
80*cdf0e10cSrcweir 		void       *pBuffer,
81*cdf0e10cSrcweir 		sal_uInt32  nBytes,
82*cdf0e10cSrcweir 		sal_uInt32 &rnDone);
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	/** Write at Offset from Buffer.
85*cdf0e10cSrcweir 	 *  @param  nOffset [in]
86*cdf0e10cSrcweir 	 *  @param  pBuffer [in]
87*cdf0e10cSrcweir 	 *  @param  nBytes [in]
88*cdf0e10cSrcweir 	 *  @param  rnDone [out]
89*cdf0e10cSrcweir 	 *  @return store_E_None upon success
90*cdf0e10cSrcweir 	 */
91*cdf0e10cSrcweir 	storeError writeAt (
92*cdf0e10cSrcweir 		sal_uInt32  nOffset,
93*cdf0e10cSrcweir 		const void *pBuffer,
94*cdf0e10cSrcweir 		sal_uInt32  nBytes,
95*cdf0e10cSrcweir 		sal_uInt32 &rnDone);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	/** flush.
98*cdf0e10cSrcweir 	 *  @return store_E_None upon success
99*cdf0e10cSrcweir 	 */
100*cdf0e10cSrcweir 	storeError flush (void);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	/** setSize.
103*cdf0e10cSrcweir 	 *  @param  nSize [in]
104*cdf0e10cSrcweir 	 *  @return store_E_None upon success
105*cdf0e10cSrcweir 	 */
106*cdf0e10cSrcweir 	storeError setSize (sal_uInt32 nSize);
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	/** stat.
109*cdf0e10cSrcweir 	 *  @paran  rnSize [out]
110*cdf0e10cSrcweir 	 *  @return store_E_None upon success
111*cdf0e10cSrcweir 	 */
112*cdf0e10cSrcweir 	storeError stat (sal_uInt32 &rnSize);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	/** IStoreHandle.
115*cdf0e10cSrcweir 	 */
116*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nMagic);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir protected:
119*cdf0e10cSrcweir 	/** Destruction (OReference).
120*cdf0e10cSrcweir 	 */
121*cdf0e10cSrcweir 	virtual ~OStoreLockBytes (void);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir private:
124*cdf0e10cSrcweir 	/** IStoreHandle TypeId.
125*cdf0e10cSrcweir 	 */
126*cdf0e10cSrcweir 	static const sal_uInt32 m_nTypeId;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	/** IStoreHandle query() template specialization.
129*cdf0e10cSrcweir 	 */
130*cdf0e10cSrcweir 	friend OStoreLockBytes*
131*cdf0e10cSrcweir 	SAL_CALL query<> (IStoreHandle *pHandle, OStoreLockBytes*);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	/** Representation.
134*cdf0e10cSrcweir 	 */
135*cdf0e10cSrcweir 	rtl::Reference<OStorePageManager> m_xManager;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	typedef OStoreDataPageData        data;
138*cdf0e10cSrcweir 	typedef OStoreDirectoryPageData   inode;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     typedef PageHolderObject< inode > inode_holder_type;
141*cdf0e10cSrcweir     inode_holder_type                 m_xNode;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	bool m_bWriteable;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	/** Not implemented.
146*cdf0e10cSrcweir 	 */
147*cdf0e10cSrcweir 	OStoreLockBytes (const OStoreLockBytes&);
148*cdf0e10cSrcweir 	OStoreLockBytes& operator= (const OStoreLockBytes&);
149*cdf0e10cSrcweir };
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir template<> inline OStoreLockBytes*
152*cdf0e10cSrcweir SAL_CALL query (IStoreHandle *pHandle, OStoreLockBytes*)
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	if (pHandle && pHandle->isKindOf (OStoreLockBytes::m_nTypeId))
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		// Handle is kind of OStoreLockBytes.
157*cdf0e10cSrcweir 		return static_cast<OStoreLockBytes*>(pHandle);
158*cdf0e10cSrcweir 	}
159*cdf0e10cSrcweir 	return 0;
160*cdf0e10cSrcweir }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir /*========================================================================
163*cdf0e10cSrcweir  *
164*cdf0e10cSrcweir  * The End.
165*cdf0e10cSrcweir  *
166*cdf0e10cSrcweir  *======================================================================*/
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir } // namespace store
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir #endif /* !_STORE_STORLCKB_HXX_ */
171*cdf0e10cSrcweir 
172