1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _STORE_LOCKBYTE_HXX_ 25 #define _STORE_LOCKBYTE_HXX_ 26 27 #ifndef _SAL_TYPES_H_ 28 #include "sal/types.h" 29 #endif 30 31 #ifndef _RTL_REF_HXX_ 32 #include "rtl/ref.hxx" 33 #endif 34 #ifndef _RTL_USTRING_H_ 35 #include "rtl/ustring.h" 36 #endif 37 38 #ifndef _STORE_TYPES_H_ 39 #include "store/types.h" 40 #endif 41 #ifndef _STORE_STORBASE_HXX_ 42 #include "storbase.hxx" 43 #endif 44 45 namespace store 46 { 47 48 /*======================================================================== 49 * 50 * ILockBytes interface. 51 * 52 *======================================================================*/ 53 class ILockBytes : public rtl::IReference 54 { 55 public: 56 /** 57 @param rxAllocator [out] 58 @param nPageSize [in] 59 */ 60 storeError initialize ( 61 rtl::Reference< PageData::Allocator > & rxAllocator, 62 sal_uInt16 nPageSize); 63 64 /** 65 @param rPage [out] 66 @param nOffset [in] 67 */ 68 storeError readPageAt ( 69 PageHolder & rPage, 70 sal_uInt32 nOffset); 71 72 /** 73 @param rPage [in] 74 @param nOffset [in] 75 */ 76 storeError writePageAt ( 77 PageHolder const & rPage, 78 sal_uInt32 nOffset); 79 80 /** 81 @param nOffset [in] 82 @param pBuffer [out] 83 @param nBytes [in] 84 @return store_E_None upon success 85 */ 86 storeError readAt ( 87 sal_uInt32 nOffset, 88 void *pBuffer, 89 sal_uInt32 nBytes); 90 91 /** 92 @param nOffset [in] 93 @param pBuffer [in] 94 @param nBytes [in] 95 @return store_E_None upon success 96 */ 97 storeError writeAt ( 98 sal_uInt32 nOffset, 99 const void *pBuffer, 100 sal_uInt32 nBytes); 101 102 /** 103 @param rnSize [out] 104 @return store_E_None upon success 105 */ 106 storeError getSize (sal_uInt32 & rnSize); 107 108 /** 109 @param nSize [in] 110 @return store_E_None upon success 111 */ 112 storeError setSize (sal_uInt32 nSize); 113 114 /** 115 @return store_E_None upon success 116 */ 117 storeError flush(); 118 119 private: 120 /** Implementation (abstract). 121 */ 122 virtual storeError initialize_Impl ( 123 rtl::Reference< PageData::Allocator > & rxAllocator, 124 sal_uInt16 nPageSize) = 0; 125 126 virtual storeError readPageAt_Impl ( 127 PageHolder & rPage, 128 sal_uInt32 nOffset) = 0; 129 130 virtual storeError writePageAt_Impl ( 131 PageHolder const & rPage, 132 sal_uInt32 nOffset) = 0; 133 134 virtual storeError readAt_Impl ( 135 sal_uInt32 nOffset, 136 void *pBuffer, 137 sal_uInt32 nBytes) = 0; 138 139 virtual storeError writeAt_Impl ( 140 sal_uInt32 nOffset, 141 const void *pBuffer, 142 sal_uInt32 nBytes) = 0; 143 144 virtual storeError getSize_Impl ( 145 sal_uInt32 & rnSize) = 0; 146 147 virtual storeError setSize_Impl ( 148 sal_uInt32 nSize) = 0; 149 150 virtual storeError flush_Impl() = 0; 151 }; 152 153 /*======================================================================== 154 * 155 * ILockBytes factories. 156 * 157 *======================================================================*/ 158 159 storeError 160 FileLockBytes_createInstance ( 161 rtl::Reference< store::ILockBytes > & rxLockBytes, 162 rtl_uString * pFilename, 163 storeAccessMode eAccessMode 164 ); 165 166 storeError 167 MemoryLockBytes_createInstance ( 168 rtl::Reference< store::ILockBytes > & rxLockBytes 169 ); 170 171 /*======================================================================== 172 * 173 * The End. 174 * 175 *======================================================================*/ 176 177 } // namespace store 178 179 #endif /* !_STORE_LOCKBYTE_HXX_ */ 180 181