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