Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / store / source / storpage.hxx
blobc1de9ea2d7173b21b13a2a896f273fc179cffe63
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _STORE_STORPAGE_HXX_
30 #define _STORE_STORPAGE_HXX_
32 #include "sal/types.h"
34 #include "object.hxx"
35 #include "lockbyte.hxx"
37 #include "storbase.hxx"
38 #include "storbios.hxx"
39 #include "stortree.hxx"
41 namespace store
44 struct OStoreDirectoryPageData;
45 class OStoreDirectoryPageObject;
47 /*========================================================================
49 * OStorePageManager interface.
51 *======================================================================*/
52 class OStorePageManager : public store::OStorePageBIOS
54 public:
55 /** Construction.
57 OStorePageManager (void);
59 /** Initialization (two-phase construction).
61 virtual storeError initialize (
62 ILockBytes * pLockBytes,
63 storeAccessMode eAccessMode,
64 sal_uInt16 & rnPageSize);
66 /** isValid.
67 * @return sal_True upon successful initialization,
68 * sal_False otherwise.
70 inline sal_Bool isValid (void) const;
72 /** DirectoryPage I/O (managed).
74 static storeError namei (
75 const rtl_String *pPath,
76 const rtl_String *pName,
77 OStorePageKey &rKey);
79 storeError iget (
80 OStoreDirectoryPageObject & rPage, // [out]
81 sal_uInt32 nAttrib,
82 const rtl_String * pPath,
83 const rtl_String * pName,
84 storeAccessMode eMode);
86 storeError iterate (
87 OStorePageKey & rKey,
88 OStorePageLink & rLink,
89 sal_uInt32 & rAttrib);
91 /** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)].
92 * @see store_attrib()
94 storeError attrib (
95 const OStorePageKey &rKey,
96 sal_uInt32 nMask1,
97 sal_uInt32 nMask2,
98 sal_uInt32 &rAttrib);
100 /** link (insert Source Key as hardlink to Destination).
101 * @see store_link()
103 storeError link (
104 const OStorePageKey &rSrcKey,
105 const OStorePageKey &rDstKey);
107 /** symlink (insert Source DirectoryPage as symlink to Destination).
108 * @see store_symlink()
110 storeError symlink (
111 const rtl_String *pSrcPath,
112 const rtl_String *pSrcName,
113 const OStorePageKey &rDstKey);
115 /** rename.
116 * @see store_rename()
118 storeError rename (
119 const OStorePageKey &rSrcKey,
120 const rtl_String *pDstPath,
121 const rtl_String *pDstName);
123 /** remove.
124 * @see store_remove()
126 storeError remove (
127 const OStorePageKey &rKey);
129 /** rebuild (combines recover and compact from 'Src' to 'Dst').
130 * @param pSrcLB [in] accessed readonly.
131 * @param pDstLB [in] truncated and accessed readwrite (as initialize()).
132 * @return store_E_None upon success.
134 * @see store_rebuildFile()
136 storeError rebuild (
137 ILockBytes *pSrcLB,
138 ILockBytes *pDstLB);
140 /** IStoreHandle.
142 virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
144 protected:
145 /** Destruction.
147 virtual ~OStorePageManager (void);
149 private:
150 /** Implementation.
152 typedef OStorePageBIOS base;
153 typedef OStorePageManager self;
155 typedef OStoreBTreeEntry entry;
156 typedef OStoreBTreeNodeData page;
157 typedef OStoreBTreeNodeObject node;
159 typedef OStoreDirectoryPageData inode;
160 typedef PageHolderObject< inode > inode_holder_type;
162 /** IStoreHandle TypeId.
164 static const sal_uInt32 m_nTypeId;
166 /** IStoreHandle query() template function specialization.
168 friend OStorePageManager*
169 SAL_CALL query<> (IStoreHandle *pHandle, OStorePageManager*);
171 /** Representation.
173 OStoreBTreeRootObject m_aRoot;
175 /** DirectoryPage I/O (managed).
177 storeError load_dirpage_Impl ( // @@@ => private: iget() @@@
178 const OStorePageKey &rKey,
179 OStoreDirectoryPageObject &rPage);
181 storeError save_dirpage_Impl ( // @@@ => private: iget(), rebuild() @@@
182 const OStorePageKey &rKey,
183 OStoreDirectoryPageObject &rPage);
185 /** find_lookup (node page and index, w/o split).
187 storeError find_lookup (
188 OStoreBTreeNodeObject & rNode,
189 sal_uInt16 & rIndex,
190 OStorePageKey const & rKey);
192 /** remove (possibly down from root).
194 storeError remove_Impl (entry & rEntry);
196 /** Not implemented.
198 OStorePageManager (const OStorePageManager&);
199 OStorePageManager& operator= (const OStorePageManager&);
202 inline sal_Bool OStorePageManager::isValid (void) const
204 return (base::isValid() /* @@@ NYI && (m_aRoot.is()) */);
207 template<> inline OStorePageManager*
208 SAL_CALL query (IStoreHandle *pHandle, SAL_UNUSED_PARAMETER OStorePageManager*)
210 if (pHandle && pHandle->isKindOf (OStorePageManager::m_nTypeId))
212 // Handle is kind of OStorePageManager.
213 return static_cast<OStorePageManager*>(pHandle);
215 return 0;
218 /*========================================================================
220 * The End.
222 *======================================================================*/
224 } // namespace store
226 #endif /* !_STORE_STORPAGE_HXX_ */
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */