xref: /aoo41x/main/store/source/storpage.hxx (revision 1a5fa39b)
1*1a5fa39bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1a5fa39bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1a5fa39bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1a5fa39bSAndrew Rist  * distributed with this work for additional information
6*1a5fa39bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1a5fa39bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1a5fa39bSAndrew Rist  * "License"); you may not use this file except in compliance
9*1a5fa39bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1a5fa39bSAndrew Rist  *
11*1a5fa39bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1a5fa39bSAndrew Rist  *
13*1a5fa39bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1a5fa39bSAndrew Rist  * software distributed under the License is distributed on an
15*1a5fa39bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1a5fa39bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*1a5fa39bSAndrew Rist  * specific language governing permissions and limitations
18*1a5fa39bSAndrew Rist  * under the License.
19*1a5fa39bSAndrew Rist  *
20*1a5fa39bSAndrew Rist  *************************************************************/
21*1a5fa39bSAndrew Rist 
22*1a5fa39bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _STORE_STORPAGE_HXX_
25cdf0e10cSrcweir #define _STORE_STORPAGE_HXX_ "$Revision: 1.6.8.2 $"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/types.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "object.hxx"
30cdf0e10cSrcweir #include "lockbyte.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "storbase.hxx"
33cdf0e10cSrcweir #include "storbios.hxx"
34cdf0e10cSrcweir #include "stortree.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace store
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir struct OStoreDirectoryPageData;
40cdf0e10cSrcweir class  OStoreDirectoryPageObject;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir /*========================================================================
43cdf0e10cSrcweir  *
44cdf0e10cSrcweir  * OStorePageManager interface.
45cdf0e10cSrcweir  *
46cdf0e10cSrcweir  *======================================================================*/
47cdf0e10cSrcweir class OStorePageManager : public store::OStorePageBIOS
48cdf0e10cSrcweir {
49cdf0e10cSrcweir public:
50cdf0e10cSrcweir 	/** Construction.
51cdf0e10cSrcweir 	 */
52cdf0e10cSrcweir 	OStorePageManager (void);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	/** Initialization (two-phase construction).
55cdf0e10cSrcweir 	 */
56cdf0e10cSrcweir     virtual storeError initialize (
57cdf0e10cSrcweir 		ILockBytes *    pLockBytes,
58cdf0e10cSrcweir 		storeAccessMode eAccessMode,
59cdf0e10cSrcweir 		sal_uInt16 &    rnPageSize);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	/** isValid.
62cdf0e10cSrcweir 	 *  @return sal_True  upon successful initialization,
63cdf0e10cSrcweir 	 *          sal_False otherwise.
64cdf0e10cSrcweir 	 */
65cdf0e10cSrcweir 	inline sal_Bool isValid (void) const;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	/** DirectoryPage I/O (managed).
68cdf0e10cSrcweir 	 */
69cdf0e10cSrcweir 	static storeError namei (
70cdf0e10cSrcweir 		const rtl_String *pPath,
71cdf0e10cSrcweir 		const rtl_String *pName,
72cdf0e10cSrcweir 		OStorePageKey    &rKey);
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	storeError iget (
75cdf0e10cSrcweir 		OStoreDirectoryPageObject & rPage, // [out]
76cdf0e10cSrcweir 		sal_uInt32                  nAttrib,
77cdf0e10cSrcweir 		const rtl_String *          pPath,
78cdf0e10cSrcweir 		const rtl_String *          pName,
79cdf0e10cSrcweir 		storeAccessMode             eMode);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	storeError iterate (
82cdf0e10cSrcweir 		OStorePageKey &  rKey,
83cdf0e10cSrcweir 		OStorePageLink & rLink,
84cdf0e10cSrcweir 		sal_uInt32 &     rAttrib);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	/** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)].
87cdf0e10cSrcweir      *  @see store_attrib()
88cdf0e10cSrcweir 	 */
89cdf0e10cSrcweir 	storeError attrib (
90cdf0e10cSrcweir 		const OStorePageKey &rKey,
91cdf0e10cSrcweir 		sal_uInt32           nMask1,
92cdf0e10cSrcweir 		sal_uInt32           nMask2,
93cdf0e10cSrcweir 		sal_uInt32          &rAttrib);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	/** link (insert Source Key as hardlink to Destination).
96cdf0e10cSrcweir      *  @see store_link()
97cdf0e10cSrcweir 	 */
98cdf0e10cSrcweir 	storeError link (
99cdf0e10cSrcweir 		const OStorePageKey &rSrcKey,
100cdf0e10cSrcweir 		const OStorePageKey &rDstKey);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	/** symlink (insert Source DirectoryPage as symlink to Destination).
103cdf0e10cSrcweir      *  @see store_symlink()
104cdf0e10cSrcweir 	 */
105cdf0e10cSrcweir 	storeError symlink (
106cdf0e10cSrcweir 		const rtl_String    *pSrcPath,
107cdf0e10cSrcweir 		const rtl_String    *pSrcName,
108cdf0e10cSrcweir 		const OStorePageKey &rDstKey);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	/** rename.
111cdf0e10cSrcweir      *  @see store_rename()
112cdf0e10cSrcweir 	 */
113cdf0e10cSrcweir 	storeError rename (
114cdf0e10cSrcweir 		const OStorePageKey &rSrcKey,
115cdf0e10cSrcweir 		const rtl_String    *pDstPath,
116cdf0e10cSrcweir 		const rtl_String    *pDstName);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	/** remove.
119cdf0e10cSrcweir      *  @see store_remove()
120cdf0e10cSrcweir 	 */
121cdf0e10cSrcweir 	storeError remove (
122cdf0e10cSrcweir 		const OStorePageKey &rKey);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	/** rebuild (combines recover and compact from 'Src' to 'Dst').
125cdf0e10cSrcweir 	 *  @param  pSrcLB [in] accessed readonly.
126cdf0e10cSrcweir 	 *  @param  pDstLB [in] truncated and accessed readwrite (as initialize()).
127cdf0e10cSrcweir 	 *  @return store_E_None upon success.
128cdf0e10cSrcweir      *
129cdf0e10cSrcweir      *  @see store_rebuildFile()
130cdf0e10cSrcweir 	 */
131cdf0e10cSrcweir 	storeError rebuild (
132cdf0e10cSrcweir 		ILockBytes *pSrcLB,
133cdf0e10cSrcweir 		ILockBytes *pDstLB);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	/** IStoreHandle.
136cdf0e10cSrcweir 	 */
137cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir protected:
140cdf0e10cSrcweir 	/** Destruction.
141cdf0e10cSrcweir 	*/
142cdf0e10cSrcweir 	virtual ~OStorePageManager (void);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir private:
145cdf0e10cSrcweir 	/** Implementation.
146cdf0e10cSrcweir 	*/
147cdf0e10cSrcweir 	typedef OStorePageBIOS            base;
148cdf0e10cSrcweir 	typedef OStorePageManager         self;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	typedef OStoreBTreeEntry          entry;
151cdf0e10cSrcweir 	typedef OStoreBTreeNodeData       page;
152cdf0e10cSrcweir 	typedef OStoreBTreeNodeObject     node;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     typedef OStoreDirectoryPageData   inode;
155cdf0e10cSrcweir     typedef PageHolderObject< inode > inode_holder_type;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	/** IStoreHandle TypeId.
158cdf0e10cSrcweir 	 */
159cdf0e10cSrcweir 	static const sal_uInt32 m_nTypeId;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	/** IStoreHandle query() template function specialization.
162cdf0e10cSrcweir 	 */
163cdf0e10cSrcweir 	friend OStorePageManager*
164cdf0e10cSrcweir 	SAL_CALL query<> (IStoreHandle *pHandle, OStorePageManager*);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	/** Representation.
167cdf0e10cSrcweir 	*/
168cdf0e10cSrcweir     OStoreBTreeRootObject m_aRoot;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	/** DirectoryPage I/O (managed).
171cdf0e10cSrcweir 	 */
172cdf0e10cSrcweir 	storeError load_dirpage_Impl ( // @@@ => private: iget() @@@
173cdf0e10cSrcweir 		const OStorePageKey       &rKey,
174cdf0e10cSrcweir 		OStoreDirectoryPageObject &rPage);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	storeError save_dirpage_Impl ( // @@@ => private: iget(), rebuild() @@@
177cdf0e10cSrcweir 		const OStorePageKey       &rKey,
178cdf0e10cSrcweir 		OStoreDirectoryPageObject &rPage);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	/** find_lookup (node page and index, w/o split).
181cdf0e10cSrcweir 	*/
182cdf0e10cSrcweir 	storeError find_lookup (
183cdf0e10cSrcweir         OStoreBTreeNodeObject & rNode,
184cdf0e10cSrcweir         sal_uInt16 &            rIndex,
185cdf0e10cSrcweir         OStorePageKey const &   rKey);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	/** remove (possibly down from root).
188cdf0e10cSrcweir 	*/
189cdf0e10cSrcweir 	storeError remove_Impl (entry & rEntry);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	/** Not implemented.
192cdf0e10cSrcweir 	*/
193cdf0e10cSrcweir 	OStorePageManager (const OStorePageManager&);
194cdf0e10cSrcweir 	OStorePageManager& operator= (const OStorePageManager&);
195cdf0e10cSrcweir };
196cdf0e10cSrcweir 
isValid(void) const197cdf0e10cSrcweir inline sal_Bool OStorePageManager::isValid (void) const
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	return (base::isValid() /* @@@ NYI && (m_aRoot.is()) */);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir template<> inline OStorePageManager*
query(IStoreHandle * pHandle,OStorePageManager *)203cdf0e10cSrcweir SAL_CALL query (IStoreHandle *pHandle, OStorePageManager*)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	if (pHandle && pHandle->isKindOf (OStorePageManager::m_nTypeId))
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		// Handle is kind of OStorePageManager.
208cdf0e10cSrcweir 		return static_cast<OStorePageManager*>(pHandle);
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir 	return 0;
211cdf0e10cSrcweir }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir /*========================================================================
214cdf0e10cSrcweir  *
215cdf0e10cSrcweir  * The End.
216cdf0e10cSrcweir  *
217cdf0e10cSrcweir  *======================================================================*/
218cdf0e10cSrcweir 
219cdf0e10cSrcweir } // namespace store
220cdf0e10cSrcweir 
221cdf0e10cSrcweir #endif /* !_STORE_STORPAGE_HXX_ */
222cdf0e10cSrcweir 
223