xref: /aoo42x/main/store/source/storpage.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_STORPAGE_HXX_
29*cdf0e10cSrcweir #define _STORE_STORPAGE_HXX_ "$Revision: 1.6.8.2 $"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/types.h"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "object.hxx"
34*cdf0e10cSrcweir #include "lockbyte.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "storbase.hxx"
37*cdf0e10cSrcweir #include "storbios.hxx"
38*cdf0e10cSrcweir #include "stortree.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace store
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir struct OStoreDirectoryPageData;
44*cdf0e10cSrcweir class  OStoreDirectoryPageObject;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir /*========================================================================
47*cdf0e10cSrcweir  *
48*cdf0e10cSrcweir  * OStorePageManager interface.
49*cdf0e10cSrcweir  *
50*cdf0e10cSrcweir  *======================================================================*/
51*cdf0e10cSrcweir class OStorePageManager : public store::OStorePageBIOS
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir public:
54*cdf0e10cSrcweir 	/** Construction.
55*cdf0e10cSrcweir 	 */
56*cdf0e10cSrcweir 	OStorePageManager (void);
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	/** Initialization (two-phase construction).
59*cdf0e10cSrcweir 	 */
60*cdf0e10cSrcweir     virtual storeError initialize (
61*cdf0e10cSrcweir 		ILockBytes *    pLockBytes,
62*cdf0e10cSrcweir 		storeAccessMode eAccessMode,
63*cdf0e10cSrcweir 		sal_uInt16 &    rnPageSize);
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 	/** isValid.
66*cdf0e10cSrcweir 	 *  @return sal_True  upon successful initialization,
67*cdf0e10cSrcweir 	 *          sal_False otherwise.
68*cdf0e10cSrcweir 	 */
69*cdf0e10cSrcweir 	inline sal_Bool isValid (void) const;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	/** DirectoryPage I/O (managed).
72*cdf0e10cSrcweir 	 */
73*cdf0e10cSrcweir 	static storeError namei (
74*cdf0e10cSrcweir 		const rtl_String *pPath,
75*cdf0e10cSrcweir 		const rtl_String *pName,
76*cdf0e10cSrcweir 		OStorePageKey    &rKey);
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	storeError iget (
79*cdf0e10cSrcweir 		OStoreDirectoryPageObject & rPage, // [out]
80*cdf0e10cSrcweir 		sal_uInt32                  nAttrib,
81*cdf0e10cSrcweir 		const rtl_String *          pPath,
82*cdf0e10cSrcweir 		const rtl_String *          pName,
83*cdf0e10cSrcweir 		storeAccessMode             eMode);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	storeError iterate (
86*cdf0e10cSrcweir 		OStorePageKey &  rKey,
87*cdf0e10cSrcweir 		OStorePageLink & rLink,
88*cdf0e10cSrcweir 		sal_uInt32 &     rAttrib);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	/** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)].
91*cdf0e10cSrcweir      *  @see store_attrib()
92*cdf0e10cSrcweir 	 */
93*cdf0e10cSrcweir 	storeError attrib (
94*cdf0e10cSrcweir 		const OStorePageKey &rKey,
95*cdf0e10cSrcweir 		sal_uInt32           nMask1,
96*cdf0e10cSrcweir 		sal_uInt32           nMask2,
97*cdf0e10cSrcweir 		sal_uInt32          &rAttrib);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	/** link (insert Source Key as hardlink to Destination).
100*cdf0e10cSrcweir      *  @see store_link()
101*cdf0e10cSrcweir 	 */
102*cdf0e10cSrcweir 	storeError link (
103*cdf0e10cSrcweir 		const OStorePageKey &rSrcKey,
104*cdf0e10cSrcweir 		const OStorePageKey &rDstKey);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	/** symlink (insert Source DirectoryPage as symlink to Destination).
107*cdf0e10cSrcweir      *  @see store_symlink()
108*cdf0e10cSrcweir 	 */
109*cdf0e10cSrcweir 	storeError symlink (
110*cdf0e10cSrcweir 		const rtl_String    *pSrcPath,
111*cdf0e10cSrcweir 		const rtl_String    *pSrcName,
112*cdf0e10cSrcweir 		const OStorePageKey &rDstKey);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	/** rename.
115*cdf0e10cSrcweir      *  @see store_rename()
116*cdf0e10cSrcweir 	 */
117*cdf0e10cSrcweir 	storeError rename (
118*cdf0e10cSrcweir 		const OStorePageKey &rSrcKey,
119*cdf0e10cSrcweir 		const rtl_String    *pDstPath,
120*cdf0e10cSrcweir 		const rtl_String    *pDstName);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	/** remove.
123*cdf0e10cSrcweir      *  @see store_remove()
124*cdf0e10cSrcweir 	 */
125*cdf0e10cSrcweir 	storeError remove (
126*cdf0e10cSrcweir 		const OStorePageKey &rKey);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	/** rebuild (combines recover and compact from 'Src' to 'Dst').
129*cdf0e10cSrcweir 	 *  @param  pSrcLB [in] accessed readonly.
130*cdf0e10cSrcweir 	 *  @param  pDstLB [in] truncated and accessed readwrite (as initialize()).
131*cdf0e10cSrcweir 	 *  @return store_E_None upon success.
132*cdf0e10cSrcweir      *
133*cdf0e10cSrcweir      *  @see store_rebuildFile()
134*cdf0e10cSrcweir 	 */
135*cdf0e10cSrcweir 	storeError rebuild (
136*cdf0e10cSrcweir 		ILockBytes *pSrcLB,
137*cdf0e10cSrcweir 		ILockBytes *pDstLB);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	/** IStoreHandle.
140*cdf0e10cSrcweir 	 */
141*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir protected:
144*cdf0e10cSrcweir 	/** Destruction.
145*cdf0e10cSrcweir 	*/
146*cdf0e10cSrcweir 	virtual ~OStorePageManager (void);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir private:
149*cdf0e10cSrcweir 	/** Implementation.
150*cdf0e10cSrcweir 	*/
151*cdf0e10cSrcweir 	typedef OStorePageBIOS            base;
152*cdf0e10cSrcweir 	typedef OStorePageManager         self;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	typedef OStoreBTreeEntry          entry;
155*cdf0e10cSrcweir 	typedef OStoreBTreeNodeData       page;
156*cdf0e10cSrcweir 	typedef OStoreBTreeNodeObject     node;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     typedef OStoreDirectoryPageData   inode;
159*cdf0e10cSrcweir     typedef PageHolderObject< inode > inode_holder_type;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	/** IStoreHandle TypeId.
162*cdf0e10cSrcweir 	 */
163*cdf0e10cSrcweir 	static const sal_uInt32 m_nTypeId;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	/** IStoreHandle query() template function specialization.
166*cdf0e10cSrcweir 	 */
167*cdf0e10cSrcweir 	friend OStorePageManager*
168*cdf0e10cSrcweir 	SAL_CALL query<> (IStoreHandle *pHandle, OStorePageManager*);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	/** Representation.
171*cdf0e10cSrcweir 	*/
172*cdf0e10cSrcweir     OStoreBTreeRootObject m_aRoot;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 	/** DirectoryPage I/O (managed).
175*cdf0e10cSrcweir 	 */
176*cdf0e10cSrcweir 	storeError load_dirpage_Impl ( // @@@ => private: iget() @@@
177*cdf0e10cSrcweir 		const OStorePageKey       &rKey,
178*cdf0e10cSrcweir 		OStoreDirectoryPageObject &rPage);
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	storeError save_dirpage_Impl ( // @@@ => private: iget(), rebuild() @@@
181*cdf0e10cSrcweir 		const OStorePageKey       &rKey,
182*cdf0e10cSrcweir 		OStoreDirectoryPageObject &rPage);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	/** find_lookup (node page and index, w/o split).
185*cdf0e10cSrcweir 	*/
186*cdf0e10cSrcweir 	storeError find_lookup (
187*cdf0e10cSrcweir         OStoreBTreeNodeObject & rNode,
188*cdf0e10cSrcweir         sal_uInt16 &            rIndex,
189*cdf0e10cSrcweir         OStorePageKey const &   rKey);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	/** remove (possibly down from root).
192*cdf0e10cSrcweir 	*/
193*cdf0e10cSrcweir 	storeError remove_Impl (entry & rEntry);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	/** Not implemented.
196*cdf0e10cSrcweir 	*/
197*cdf0e10cSrcweir 	OStorePageManager (const OStorePageManager&);
198*cdf0e10cSrcweir 	OStorePageManager& operator= (const OStorePageManager&);
199*cdf0e10cSrcweir };
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir inline sal_Bool OStorePageManager::isValid (void) const
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir 	return (base::isValid() /* @@@ NYI && (m_aRoot.is()) */);
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir template<> inline OStorePageManager*
207*cdf0e10cSrcweir SAL_CALL query (IStoreHandle *pHandle, OStorePageManager*)
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	if (pHandle && pHandle->isKindOf (OStorePageManager::m_nTypeId))
210*cdf0e10cSrcweir 	{
211*cdf0e10cSrcweir 		// Handle is kind of OStorePageManager.
212*cdf0e10cSrcweir 		return static_cast<OStorePageManager*>(pHandle);
213*cdf0e10cSrcweir 	}
214*cdf0e10cSrcweir 	return 0;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir /*========================================================================
218*cdf0e10cSrcweir  *
219*cdf0e10cSrcweir  * The End.
220*cdf0e10cSrcweir  *
221*cdf0e10cSrcweir  *======================================================================*/
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir } // namespace store
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir #endif /* !_STORE_STORPAGE_HXX_ */
226*cdf0e10cSrcweir 
227