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