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_STORLCKB_HXX_
25 #define _STORE_STORLCKB_HXX_ "$Revision: 1.6.8.1 $"
26
27 #include "sal/types.h"
28
29 #include "rtl/ustring.h"
30 #include "rtl/ref.hxx"
31
32 #include "object.hxx"
33 #include "storbase.hxx"
34 #include "storpage.hxx"
35
36 namespace store
37 {
38
39 struct OStoreDataPageData;
40 struct OStoreDirectoryPageData;
41
42 /*========================================================================
43 *
44 * OStoreLockBytes interface.
45 *
46 *======================================================================*/
47 class OStoreLockBytes : public store::OStoreObject
48 {
49 public:
50 /** Construction.
51 */
52 OStoreLockBytes (void);
53
54 /** create (two-phase construction).
55 * @param pManager [in]
56 * @param pPath [in]
57 * @param pName [in]
58 * @param eMode [in]
59 * @return store_E_None upon success
60 */
61 storeError create (
62 OStorePageManager *pManager,
63 rtl_String *pPath,
64 rtl_String *pName,
65 storeAccessMode eAccessMode);
66
67 /** Read at Offset into Buffer.
68 * @param nOffset [in]
69 * @param pBuffer [out]
70 * @param nBytes [in]
71 * @param rnDone [out]
72 * @return store_E_None upon success
73 */
74 storeError readAt (
75 sal_uInt32 nOffset,
76 void *pBuffer,
77 sal_uInt32 nBytes,
78 sal_uInt32 &rnDone);
79
80 /** Write at Offset from Buffer.
81 * @param nOffset [in]
82 * @param pBuffer [in]
83 * @param nBytes [in]
84 * @param rnDone [out]
85 * @return store_E_None upon success
86 */
87 storeError writeAt (
88 sal_uInt32 nOffset,
89 const void *pBuffer,
90 sal_uInt32 nBytes,
91 sal_uInt32 &rnDone);
92
93 /** flush.
94 * @return store_E_None upon success
95 */
96 storeError flush (void);
97
98 /** setSize.
99 * @param nSize [in]
100 * @return store_E_None upon success
101 */
102 storeError setSize (sal_uInt32 nSize);
103
104 /** stat.
105 * @paran rnSize [out]
106 * @return store_E_None upon success
107 */
108 storeError stat (sal_uInt32 &rnSize);
109
110 /** IStoreHandle.
111 */
112 virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nMagic);
113
114 protected:
115 /** Destruction (OReference).
116 */
117 virtual ~OStoreLockBytes (void);
118
119 private:
120 /** IStoreHandle TypeId.
121 */
122 static const sal_uInt32 m_nTypeId;
123
124 /** IStoreHandle query() template specialization.
125 */
126 friend OStoreLockBytes*
127 SAL_CALL query<> (IStoreHandle *pHandle, OStoreLockBytes*);
128
129 /** Representation.
130 */
131 rtl::Reference<OStorePageManager> m_xManager;
132
133 typedef OStoreDataPageData data;
134 typedef OStoreDirectoryPageData inode;
135
136 typedef PageHolderObject< inode > inode_holder_type;
137 inode_holder_type m_xNode;
138
139 bool m_bWriteable;
140
141 /** Not implemented.
142 */
143 OStoreLockBytes (const OStoreLockBytes&);
144 OStoreLockBytes& operator= (const OStoreLockBytes&);
145 };
146
147 template<> inline OStoreLockBytes*
query(IStoreHandle * pHandle,OStoreLockBytes *)148 SAL_CALL query (IStoreHandle *pHandle, OStoreLockBytes*)
149 {
150 if (pHandle && pHandle->isKindOf (OStoreLockBytes::m_nTypeId))
151 {
152 // Handle is kind of OStoreLockBytes.
153 return static_cast<OStoreLockBytes*>(pHandle);
154 }
155 return 0;
156 }
157
158 /*========================================================================
159 *
160 * The End.
161 *
162 *======================================================================*/
163
164 } // namespace store
165
166 #endif /* !_STORE_STORLCKB_HXX_ */
167
168