1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_STORE_SOURCE_STORPAGE_HXX
21 #define INCLUDED_STORE_SOURCE_STORPAGE_HXX
23 #include "sal/types.h"
26 #include "lockbyte.hxx"
28 #include "storbase.hxx"
29 #include "storbios.hxx"
30 #include "stortree.hxx"
35 struct OStoreDirectoryPageData
;
36 class OStoreDirectoryPageObject
;
38 /*========================================================================
40 * OStorePageManager interface.
42 *======================================================================*/
43 class OStorePageManager
: public store::OStorePageBIOS
50 /** Initialization (two-phase construction).
52 virtual storeError
initialize (
53 ILockBytes
* pLockBytes
,
54 storeAccessMode eAccessMode
,
55 sal_uInt16
& rnPageSize
) SAL_OVERRIDE
;
58 * @return sal_True upon successful initialization,
59 * sal_False otherwise.
61 inline bool isValid() const;
63 /** DirectoryPage I/O (managed).
65 static storeError
namei (
66 const rtl_String
*pPath
,
67 const rtl_String
*pName
,
71 OStoreDirectoryPageObject
& rPage
, // [out]
73 const rtl_String
* pPath
,
74 const rtl_String
* pName
,
75 storeAccessMode eMode
);
79 OStorePageLink
& rLink
,
80 sal_uInt32
& rAttrib
);
82 /** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)].
86 const OStorePageKey
&rKey
,
91 /** link (insert Source Key as hardlink to Destination).
95 const OStorePageKey
&rSrcKey
,
96 const OStorePageKey
&rDstKey
);
98 /** symlink (insert Source DirectoryPage as symlink to Destination).
99 * @see store_symlink()
102 const rtl_String
*pSrcPath
,
103 const rtl_String
*pSrcName
,
104 const OStorePageKey
&rDstKey
);
107 * @see store_rename()
110 const OStorePageKey
&rSrcKey
,
111 const rtl_String
*pDstPath
,
112 const rtl_String
*pDstName
);
115 * @see store_remove()
118 const OStorePageKey
&rKey
);
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.
125 * @see store_rebuildFile()
133 virtual bool isKindOf (sal_uInt32 nTypeId
) SAL_OVERRIDE
;
138 virtual ~OStorePageManager();
143 typedef OStorePageBIOS base
;
144 typedef OStorePageManager self
;
146 typedef OStoreBTreeEntry entry
;
147 typedef OStoreBTreeNodeData page
;
148 typedef OStoreBTreeNodeObject node
;
150 typedef OStoreDirectoryPageData inode
;
151 typedef PageHolderObject
< inode
> inode_holder_type
;
153 /** IStoreHandle TypeId.
155 static const sal_uInt32 m_nTypeId
;
157 /** IStoreHandle query() template function specialization.
159 friend OStorePageManager
*
160 SAL_CALL query
<> (IStoreHandle
*pHandle
, OStorePageManager
*);
164 OStoreBTreeRootObject m_aRoot
;
166 /** DirectoryPage I/O (managed).
168 storeError
load_dirpage_Impl ( // @@@ => private: iget() @@@
169 const OStorePageKey
&rKey
,
170 OStoreDirectoryPageObject
&rPage
);
172 storeError
save_dirpage_Impl ( // @@@ => private: iget(), rebuild() @@@
173 const OStorePageKey
&rKey
,
174 OStoreDirectoryPageObject
&rPage
);
176 /** find_lookup (node page and index, w/o split).
178 storeError
find_lookup (
179 OStoreBTreeNodeObject
& rNode
,
181 OStorePageKey
const & rKey
);
183 /** remove (possibly down from root).
185 storeError
remove_Impl (entry
& rEntry
);
187 OStorePageManager (const OStorePageManager
&) SAL_DELETED_FUNCTION
;
188 OStorePageManager
& operator= (const OStorePageManager
&) SAL_DELETED_FUNCTION
;
191 inline bool OStorePageManager::isValid() const
193 return (base::isValid() /* @@@ NYI && (m_aRoot.is()) */);
196 template<> inline OStorePageManager
*
197 SAL_CALL
query (IStoreHandle
*pHandle
, SAL_UNUSED_PARAMETER OStorePageManager
*)
199 if (pHandle
&& pHandle
->isKindOf (OStorePageManager::m_nTypeId
))
201 // Handle is kind of OStorePageManager.
202 return static_cast<OStorePageManager
*>(pHandle
);
207 /*========================================================================
211 *======================================================================*/
215 #endif // INCLUDED_STORE_SOURCE_STORPAGE_HXX
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */