Branch libreoffice-5-0-4
[LibreOffice.git] / store / source / storpage.hxx
blobf400a3fbd25eb0905a3e3e38a3bfde3d05691026
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
25 #include "object.hxx"
26 #include "lockbyte.hxx"
28 #include "storbase.hxx"
29 #include "storbios.hxx"
30 #include "stortree.hxx"
32 namespace store
35 struct OStoreDirectoryPageData;
36 class OStoreDirectoryPageObject;
38 /*========================================================================
40 * OStorePageManager interface.
42 *======================================================================*/
43 class OStorePageManager : public store::OStorePageBIOS
45 public:
46 /** Construction.
48 OStorePageManager();
50 /** Initialization (two-phase construction).
52 virtual storeError initialize (
53 ILockBytes * pLockBytes,
54 storeAccessMode eAccessMode,
55 sal_uInt16 & rnPageSize) SAL_OVERRIDE;
57 /** isValid.
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,
68 OStorePageKey &rKey);
70 storeError iget (
71 OStoreDirectoryPageObject & rPage, // [out]
72 sal_uInt32 nAttrib,
73 const rtl_String * pPath,
74 const rtl_String * pName,
75 storeAccessMode eMode);
77 storeError iterate (
78 OStorePageKey & rKey,
79 OStorePageLink & rLink,
80 sal_uInt32 & rAttrib);
82 /** attrib [nAttrib = ((nAttrib & ~nMask1) | nMask2)].
83 * @see store_attrib()
85 storeError attrib (
86 const OStorePageKey &rKey,
87 sal_uInt32 nMask1,
88 sal_uInt32 nMask2,
89 sal_uInt32 &rAttrib);
91 /** link (insert Source Key as hardlink to Destination).
92 * @see store_link()
94 storeError link (
95 const OStorePageKey &rSrcKey,
96 const OStorePageKey &rDstKey);
98 /** symlink (insert Source DirectoryPage as symlink to Destination).
99 * @see store_symlink()
101 storeError symlink (
102 const rtl_String *pSrcPath,
103 const rtl_String *pSrcName,
104 const OStorePageKey &rDstKey);
106 /** rename.
107 * @see store_rename()
109 storeError rename (
110 const OStorePageKey &rSrcKey,
111 const rtl_String *pDstPath,
112 const rtl_String *pDstName);
114 /** remove.
115 * @see store_remove()
117 storeError 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()
127 storeError rebuild (
128 ILockBytes *pSrcLB,
129 ILockBytes *pDstLB);
131 /** IStoreHandle.
133 virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
135 protected:
136 /** Destruction.
138 virtual ~OStorePageManager();
140 private:
141 /** Implementation.
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*);
162 /** Representation.
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,
180 sal_uInt16 & rIndex,
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);
204 return 0;
207 /*========================================================================
209 * The End.
211 *======================================================================*/
213 } // namespace store
215 #endif // INCLUDED_STORE_SOURCE_STORPAGE_HXX
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */