LibreOffice LibreOffice 4.1 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
implbase.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19 #ifndef _CPPUHELPER_IMPLBASE_HXX_
20 #define _CPPUHELPER_IMPLBASE_HXX_
21
22 #include <osl/mutex.hxx>
23 #include <cppuhelper/weak.hxx>
24 #include <cppuhelper/weakagg.hxx>
25 #include <rtl/instance.hxx>
26
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include "cppuhelperdllapi.h"
30
31 /* This header should not be used anymore.
32 @deprecated
33 */
34
36
37 namespace cppu
38 {
39
43 struct Type_Offset
44 {
47 sal_Int32 nOffset;
50 typelib_InterfaceTypeDescription * pTD;
51 };
55 struct CPPUHELPER_DLLPUBLIC ClassDataBase
56 {
59 sal_Bool bOffsetsInit;
62 sal_Int32 nType2Offset;
63
72 sal_Int32 nClassCode;
73
76 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > * pTypes;
79 ::com::sun::star::uno::Sequence< sal_Int8 > * pId;
80
83 ClassDataBase() SAL_THROW(());
88 ClassDataBase( sal_Int32 nClassCode ) SAL_THROW(());
91 ~ClassDataBase() SAL_THROW(());
92 };
99 struct CPPUHELPER_DLLPUBLIC ClassData : public ClassDataBase
100 {
103 Type_Offset arType2Offset[1];
104
107 void SAL_CALL initTypeProvider() SAL_THROW(());
113 void SAL_CALL writeTypeOffset( const ::com::sun::star::uno::Type & rType, sal_Int32 nOffset )
114 SAL_THROW(());
115
122 ::com::sun::star::uno::Any SAL_CALL query(
123 const ::com::sun::star::uno::Type & rType, ::com::sun::star::lang::XTypeProvider * pBase )
124 SAL_THROW(());
129 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
130 SAL_THROW(());
135 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
136 SAL_THROW(());
137 };
138
142 CPPUHELPER_DLLPUBLIC ::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW(());
143 }
144
145 //
146 // settle down beavis, here comes the macro template hell :]
147 //
148
149 //==================================================================================================
150
151 #if defined _MSC_VER // public -> protected changes mangled names there
152 #define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED public
153 #else
154 #define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED protected
155 #endif
156
170 #define __DEF_IMPLHELPER_PRE( N ) \
171 namespace cppu \
172 { \
173 struct ClassData##N : public ClassDataBase \
174 { \
175 Type_Offset arType2Offset[ N ]; \
176 ClassData##N( sal_Int32 nInClassCode ) SAL_THROW(()) \
177 : ClassDataBase( nInClassCode ) \
178 {} \
179 }; \
180 template< __CLASS_IFC##N > \
181 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelperBase##N \
182 : public ::com::sun::star::lang::XTypeProvider \
183 , __PUBLIC_IFC##N \
184 { \
185 CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
186 ~ImplHelperBase##N() throw () {} \
187 protected: \
188 ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) SAL_THROW(()) \
189 { \
190 ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \
191 if (! rCD.bOffsetsInit) \
192 { \
193 ::osl::MutexGuard aGuard( getImplHelperInitMutex() ); \
194 if (! rCD.bOffsetsInit) \
195 { \
196 char * pBase = (char *)this;
197
199 #define __IFC_WRITEOFFSET( N ) \
200 rCD.writeTypeOffset( ::getCppuType( (const ::com::sun::star::uno::Reference< Ifc##N > *)0 ), \
201 (char *)(Ifc##N *)this - pBase );
202
204 #define __DEF_IMPLHELPER_POST_A( N ) \
205 rCD.bOffsetsInit = sal_True; \
206 } \
207 } \
208 return rCD; \
209 } \
210 }; \
211 template< __CLASS_IFC##N > \
212 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper##N \
213 : public ImplHelperBase##N< __IFC##N > \
214 { \
215 static ClassData##N s_aCD; \
216 public: \
217 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
218 { return this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ); } \
219 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
220 { return this->getClassData( s_aCD ).getTypes(); } \
221 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
222 { return this->getClassData( s_aCD ).getImplementationId(); } \
223 CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
224 ~ImplHelper##N() throw () {} \
225 }; \
226 template< __CLASS_IFC##N > \
227 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper##N \
228 : public ::cppu::OWeakObject \
229 , public ImplHelperBase##N< __IFC##N > \
230 { \
231 static ClassData##N s_aCD; \
232 public: \
233 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
234 { \
235 ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
236 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); \
237 } \
238 virtual void SAL_CALL acquire() throw () \
239 { OWeakObject::acquire(); } \
240 virtual void SAL_CALL release() throw () \
241 { OWeakObject::release(); } \
242 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
243 { return this->getClassData( s_aCD ).getTypes(); } \
244 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
245 { return this->getClassData( s_aCD ).getImplementationId(); } \
246 }; \
247 template< __CLASS_IFC##N > \
248 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper##N \
249 : public ::cppu::OWeakAggObject \
250 , public ImplHelperBase##N< __IFC##N > \
251 { \
252 static ClassData##N s_aCD; \
253 public: \
254 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
255 { return OWeakAggObject::queryInterface( rType ); } \
256 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
257 { \
258 ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
259 return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); \
260 } \
261 virtual void SAL_CALL acquire() throw () \
262 { OWeakAggObject::acquire(); } \
263 virtual void SAL_CALL release() throw () \
264 { OWeakAggObject::release(); } \
265 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
266 { return this->getClassData( s_aCD ).getTypes(); } \
267 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
268 { return this->getClassData( s_aCD ).getImplementationId(); } \
269 };
270
273 #define __DEF_IMPLHELPER_POST_B( N ) \
274 template< __CLASS_IFC##N > \
275 ClassData##N ImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 0 ); \
276 template< __CLASS_IFC##N > \
277 ClassData##N WeakImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 1 ); \
278 template< __CLASS_IFC##N > \
279 ClassData##N WeakAggImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 2 );
280
282 #define __DEF_IMPLHELPER_POST_C( N ) \
283 }
284 //==================================================================================================
287 #define __DEF_IMPLHELPER_POST( N ) \
288 __DEF_IMPLHELPER_POST_A( N ) \
289 __DEF_IMPLHELPER_POST_B( N ) \
290 __DEF_IMPLHELPER_POST_C( N )
291
293
294 #endif
295
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
weakagg.hxx
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:356
_typelib_InterfaceTypeDescription
Type description of an interface.
Definition: typedescription.h:424
instance.hxx
CPPUHELPER_DLLPUBLIC
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
weak.hxx
mutex.hxx
sal_Bool
unsigned char sal_Bool
Definition: types.h:37
sal_Int8
signed char sal_Int8
Definition: types.h:42
cppuhelperdllapi.h
com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >