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