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