xref: /aoo41x/main/store/source/lockbyte.hxx (revision cdf0e10c)
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_LOCKBYTE_HXX_
29 #define _STORE_LOCKBYTE_HXX_
30 
31 #ifndef _SAL_TYPES_H_
32 #include "sal/types.h"
33 #endif
34 
35 #ifndef _RTL_REF_HXX_
36 #include "rtl/ref.hxx"
37 #endif
38 #ifndef _RTL_USTRING_H_
39 #include "rtl/ustring.h"
40 #endif
41 
42 #ifndef _STORE_TYPES_H_
43 #include "store/types.h"
44 #endif
45 #ifndef _STORE_STORBASE_HXX_
46 #include "storbase.hxx"
47 #endif
48 
49 namespace store
50 {
51 
52 /*========================================================================
53  *
54  * ILockBytes interface.
55  *
56  *======================================================================*/
57 class ILockBytes : public rtl::IReference
58 {
59 public:
60     /**
61         @param  rxAllocator [out]
62         @param  nPageSize [in]
63     */
64     storeError initialize (
65         rtl::Reference< PageData::Allocator > & rxAllocator,
66         sal_uInt16                              nPageSize);
67 
68     /**
69 	    @param  rPage [out]
70 	    @param  nOffset [in]
71      */
72     storeError readPageAt (
73         PageHolder & rPage,
74         sal_uInt32   nOffset);
75 
76     /**
77 	    @param  rPage [in]
78 	    @param  nOffset [in]
79      */
80     storeError writePageAt (
81         PageHolder const & rPage,
82         sal_uInt32         nOffset);
83 
84 	/**
85 	    @param  nOffset [in]
86 	    @param  pBuffer [out]
87 	    @param  nBytes [in]
88 	    @return store_E_None upon success
89 	 */
90 	storeError readAt (
91 		sal_uInt32  nOffset,
92 		void       *pBuffer,
93 		sal_uInt32  nBytes);
94 
95 	/**
96 	    @param  nOffset [in]
97 	    @param  pBuffer [in]
98 	    @param  nBytes [in]
99 	    @return store_E_None upon success
100 	 */
101 	storeError writeAt (
102 		sal_uInt32  nOffset,
103 		const void *pBuffer,
104 		sal_uInt32  nBytes);
105 
106 	/**
107 	    @param  rnSize [out]
108 	    @return store_E_None upon success
109 	 */
110 	storeError getSize (sal_uInt32 & rnSize);
111 
112 	/**
113 	    @param  nSize [in]
114 	    @return store_E_None upon success
115 	 */
116 	storeError setSize (sal_uInt32 nSize);
117 
118 	/**
119 	    @return store_E_None upon success
120 	 */
121 	storeError flush();
122 
123 private:
124     /** Implementation (abstract).
125      */
126     virtual storeError initialize_Impl (
127         rtl::Reference< PageData::Allocator > & rxAllocator,
128         sal_uInt16                              nPageSize) = 0;
129 
130     virtual storeError readPageAt_Impl (
131         PageHolder & rPage,
132         sal_uInt32   nOffset) = 0;
133 
134     virtual storeError writePageAt_Impl (
135         PageHolder const & rPage,
136         sal_uInt32         nOffset) = 0;
137 
138 	virtual storeError readAt_Impl (
139 		sal_uInt32  nOffset,
140 		void       *pBuffer,
141 		sal_uInt32  nBytes) = 0;
142 
143 	virtual storeError writeAt_Impl (
144 		sal_uInt32  nOffset,
145 		const void *pBuffer,
146 		sal_uInt32  nBytes) = 0;
147 
148 	virtual storeError getSize_Impl (
149         sal_uInt32 & rnSize) = 0;
150 
151 	virtual storeError setSize_Impl (
152         sal_uInt32 nSize) = 0;
153 
154 	virtual storeError flush_Impl() = 0;
155 };
156 
157 /*========================================================================
158  *
159  * ILockBytes factories.
160  *
161  *======================================================================*/
162 
163 storeError
164 FileLockBytes_createInstance (
165   rtl::Reference< store::ILockBytes > & rxLockBytes,
166   rtl_uString *   pFilename,
167   storeAccessMode eAccessMode
168 );
169 
170 storeError
171 MemoryLockBytes_createInstance (
172   rtl::Reference< store::ILockBytes > & rxLockBytes
173 );
174 
175 /*========================================================================
176  *
177  * The End.
178  *
179  *======================================================================*/
180 
181 } // namespace store
182 
183 #endif /* !_STORE_LOCKBYTE_HXX_ */
184 
185