Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / store / source / lockbyte.hxx
blob8a6d01cc027dca4ee4a2ef236100bbbdbd610916
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _STORE_LOCKBYTE_HXX_
30 #define _STORE_LOCKBYTE_HXX_
32 #include "sal/types.h"
34 #include "rtl/ref.hxx"
35 #include "rtl/ustring.h"
37 #include "store/types.h"
38 #include "storbase.hxx"
40 namespace store
43 /*========================================================================
45 * ILockBytes interface.
47 *======================================================================*/
48 class ILockBytes : public rtl::IReference
50 public:
51 /**
52 @param rxAllocator [out]
53 @param nPageSize [in]
55 storeError initialize (
56 rtl::Reference< PageData::Allocator > & rxAllocator,
57 sal_uInt16 nPageSize);
59 /**
60 @param rPage [out]
61 @param nOffset [in]
63 storeError readPageAt (
64 PageHolder & rPage,
65 sal_uInt32 nOffset);
67 /**
68 @param rPage [in]
69 @param nOffset [in]
71 storeError writePageAt (
72 PageHolder const & rPage,
73 sal_uInt32 nOffset);
75 /**
76 @param nOffset [in]
77 @param pBuffer [out]
78 @param nBytes [in]
79 @return store_E_None upon success
81 storeError readAt (
82 sal_uInt32 nOffset,
83 void *pBuffer,
84 sal_uInt32 nBytes);
86 /**
87 @param nOffset [in]
88 @param pBuffer [in]
89 @param nBytes [in]
90 @return store_E_None upon success
92 storeError writeAt (
93 sal_uInt32 nOffset,
94 const void *pBuffer,
95 sal_uInt32 nBytes);
97 /**
98 @param rnSize [out]
99 @return store_E_None upon success
101 storeError getSize (sal_uInt32 & rnSize);
104 @param nSize [in]
105 @return store_E_None upon success
107 storeError setSize (sal_uInt32 nSize);
110 @return store_E_None upon success
112 storeError flush();
114 protected:
115 ~ILockBytes() {}
117 private:
118 /** Implementation (abstract).
120 virtual storeError initialize_Impl (
121 rtl::Reference< PageData::Allocator > & rxAllocator,
122 sal_uInt16 nPageSize) = 0;
124 virtual storeError readPageAt_Impl (
125 PageHolder & rPage,
126 sal_uInt32 nOffset) = 0;
128 virtual storeError writePageAt_Impl (
129 PageHolder const & rPage,
130 sal_uInt32 nOffset) = 0;
132 virtual storeError readAt_Impl (
133 sal_uInt32 nOffset,
134 void *pBuffer,
135 sal_uInt32 nBytes) = 0;
137 virtual storeError writeAt_Impl (
138 sal_uInt32 nOffset,
139 const void *pBuffer,
140 sal_uInt32 nBytes) = 0;
142 virtual storeError getSize_Impl (
143 sal_uInt32 & rnSize) = 0;
145 virtual storeError setSize_Impl (
146 sal_uInt32 nSize) = 0;
148 virtual storeError flush_Impl() = 0;
151 /*========================================================================
153 * ILockBytes factories.
155 *======================================================================*/
157 storeError
158 FileLockBytes_createInstance (
159 rtl::Reference< store::ILockBytes > & rxLockBytes,
160 rtl_uString * pFilename,
161 storeAccessMode eAccessMode
164 storeError
165 MemoryLockBytes_createInstance (
166 rtl::Reference< store::ILockBytes > & rxLockBytes
169 /*========================================================================
171 * The End.
173 *======================================================================*/
175 } // namespace store
177 #endif /* !_STORE_LOCKBYTE_HXX_ */
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */