Line data Source code
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 INCLUDED_CPPUHELPER_IMPLBASE2_HXX
20 : #define INCLUDED_CPPUHELPER_IMPLBASE2_HXX
21 :
22 : #include <cppuhelper/implbase_ex.hxx>
23 : #include <rtl/instance.hxx>
24 :
25 : namespace cppu
26 : {
27 : /// @cond INTERNAL
28 :
29 : struct class_data2
30 : {
31 : sal_Int16 m_nTypes;
32 : sal_Bool m_storedTypeRefs;
33 : sal_Bool m_storedId;
34 : sal_Int8 m_id[ 16 ];
35 : type_entry m_typeEntries[ 2 + 1 ];
36 : };
37 :
38 : template< typename Ifc1, typename Ifc2, typename Impl > struct ImplClassData2
39 : {
40 1 : class_data* operator ()()
41 : {
42 : static class_data2 s_cd =
43 : {
44 : 2 +1, sal_False, sal_False,
45 : { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
46 : {
47 : { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
48 : { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
49 : { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
50 : }
51 : };
52 1 : return reinterpret_cast< class_data * >(&s_cd);
53 : }
54 : };
55 :
56 : /// @endcond
57 :
58 : /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
59 : and queryInterface(), but no reference counting.
60 :
61 : @derive
62 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
63 : Your base class defines method implementations, acquire(), release() and delegates incoming
64 : queryInterface() calls to this base class.
65 : */
66 : template< class Ifc1, class Ifc2 >
67 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper2
68 : : public com::sun::star::lang::XTypeProvider
69 : , public Ifc1, public Ifc2
70 : {
71 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplHelper2<Ifc1, Ifc2> > > {};
72 : public:
73 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
74 0 : { return ImplHelper_query( rType, cd::get(), this ); }
75 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
76 0 : { return ImplHelper_getTypes( cd::get() ); }
77 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
78 0 : { return ImplHelper_getImplementationId( cd::get() ); }
79 :
80 : #if !defined _MSC_VER // public -> protected changes mangled names there
81 : protected:
82 : #endif
83 0 : ~ImplHelper2() throw () {}
84 : };
85 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
86 : com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
87 : (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
88 :
89 : @derive
90 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
91 : Your sub class defines method implementations for these interface(s).
92 : */
93 : template< class Ifc1, class Ifc2 >
94 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper2
95 : : public OWeakObject
96 : , public com::sun::star::lang::XTypeProvider
97 : , public Ifc1, public Ifc2
98 : {
99 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakImplHelper2<Ifc1, Ifc2> > > {};
100 : public:
101 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
102 0 : { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
103 0 : virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
104 0 : { OWeakObject::acquire(); }
105 0 : virtual void SAL_CALL release() throw () SAL_OVERRIDE
106 0 : { OWeakObject::release(); }
107 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
108 0 : { return WeakImplHelper_getTypes( cd::get() ); }
109 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
110 0 : { return ImplHelper_getImplementationId( cd::get() ); }
111 : };
112 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
113 : com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
114 : (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
115 : In addition, it supports also aggregation meaning object of this class can be aggregated
116 : (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
117 : If a delegator is set (this object is aggregated), then incoming queryInterface()
118 : calls are delegated to the delegator object. If the delegator does not support the
119 : demanded interface, it calls queryAggregation() on its aggregated objects.
120 :
121 : @derive
122 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
123 : Your sub class defines method implementations for these interface(s).
124 : */
125 : template< class Ifc1, class Ifc2 >
126 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper2
127 : : public OWeakAggObject
128 : , public com::sun::star::lang::XTypeProvider
129 : , public Ifc1, public Ifc2
130 : {
131 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggImplHelper2<Ifc1, Ifc2> > > {};
132 : public:
133 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
134 0 : { return OWeakAggObject::queryInterface( rType ); }
135 0 : virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
136 0 : { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
137 0 : virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
138 0 : { OWeakAggObject::acquire(); }
139 0 : virtual void SAL_CALL release() throw () SAL_OVERRIDE
140 0 : { OWeakAggObject::release(); }
141 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
142 0 : { return WeakAggImplHelper_getTypes( cd::get() ); }
143 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
144 0 : { return ImplHelper_getImplementationId( cd::get() ); }
145 : };
146 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
147 : com::sun::star::uno::XInterface inherting from a BaseClass.
148 : All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
149 : if a demanded interface is not supported by this class directly, the request is
150 : delegated to the BaseClass.
151 :
152 : @attention
153 : The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
154 : and com::sun::star::lang::XTypeProvider are implemented properly. The
155 : BaseClass must have at least one ctor that can be called with six or
156 : fewer arguments, of which none is of non-const reference type.
157 :
158 : @derive
159 : Inherit from this class giving your additional interface(s) to be implemented as
160 : template argument(s). Your sub class defines method implementations for these interface(s).
161 : */
162 : template< class BaseClass, class Ifc1, class Ifc2 >
163 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper2
164 : : public BaseClass
165 : , public Ifc1, public Ifc2
166 : {
167 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
168 : protected:
169 : template< typename T1 >
170 0 : explicit ImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
171 : template< typename T1, typename T2 >
172 0 : ImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
173 0 : BaseClass(arg1, arg2) {}
174 : template< typename T1, typename T2, typename T3 >
175 0 : ImplInheritanceHelper2(
176 : T1 const & arg1, T2 const & arg2, T3 const & arg3):
177 0 : BaseClass(arg1, arg2, arg3) {}
178 : template< typename T1, typename T2, typename T3, typename T4 >
179 0 : ImplInheritanceHelper2(
180 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
181 0 : BaseClass(arg1, arg2, arg3, arg4) {}
182 : template<
183 : typename T1, typename T2, typename T3, typename T4, typename T5 >
184 0 : ImplInheritanceHelper2(
185 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
186 : T5 const & arg5):
187 0 : BaseClass(arg1, arg2, arg3, arg4, arg5) {}
188 : template<
189 : typename T1, typename T2, typename T3, typename T4, typename T5,
190 : typename T6 >
191 : ImplInheritanceHelper2(
192 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
193 : T5 const & arg5, T6 const & arg6):
194 : BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
195 : public:
196 0 : ImplInheritanceHelper2() {}
197 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
198 : {
199 0 : com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
200 0 : if (aRet.hasValue())
201 0 : return aRet;
202 0 : return BaseClass::queryInterface( rType );
203 : }
204 0 : virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
205 0 : { BaseClass::acquire(); }
206 0 : virtual void SAL_CALL release() throw () SAL_OVERRIDE
207 0 : { BaseClass::release(); }
208 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
209 0 : { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
210 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
211 0 : { return ImplHelper_getImplementationId( cd::get() ); }
212 : };
213 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
214 : com::sun::star::uno::XInterface inherting from a BaseClass.
215 : All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
216 : Upon queryAggregation(), if a demanded interface is not supported by this class directly,
217 : the request is delegated to the BaseClass.
218 :
219 : @attention
220 : The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
221 : com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
222 : are implemented properly. The BaseClass must have at least one ctor
223 : that can be called with six or fewer arguments, of which none is of
224 : non-const reference type.
225 :
226 : @derive
227 : Inherit from this class giving your additional interface(s) to be implemented as
228 : template argument(s). Your sub class defines method implementations for these interface(s).
229 : */
230 : template< class BaseClass, class Ifc1, class Ifc2 >
231 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper2
232 : : public BaseClass
233 : , public Ifc1, public Ifc2
234 : {
235 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, AggImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
236 : protected:
237 : template< typename T1 >
238 0 : explicit AggImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
239 : template< typename T1, typename T2 >
240 : AggImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
241 : BaseClass(arg1, arg2) {}
242 : template< typename T1, typename T2, typename T3 >
243 : AggImplInheritanceHelper2(
244 : T1 const & arg1, T2 const & arg2, T3 const & arg3):
245 : BaseClass(arg1, arg2, arg3) {}
246 : template< typename T1, typename T2, typename T3, typename T4 >
247 : AggImplInheritanceHelper2(
248 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
249 : BaseClass(arg1, arg2, arg3, arg4) {}
250 : template<
251 : typename T1, typename T2, typename T3, typename T4, typename T5 >
252 : AggImplInheritanceHelper2(
253 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
254 : T5 const & arg5):
255 : BaseClass(arg1, arg2, arg3, arg4, arg5) {}
256 : template<
257 : typename T1, typename T2, typename T3, typename T4, typename T5,
258 : typename T6 >
259 : AggImplInheritanceHelper2(
260 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
261 : T5 const & arg5, T6 const & arg6):
262 : BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
263 : public:
264 0 : AggImplInheritanceHelper2() {}
265 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
266 0 : { return BaseClass::queryInterface( rType ); }
267 0 : virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
268 : {
269 0 : com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
270 0 : if (aRet.hasValue())
271 0 : return aRet;
272 0 : return BaseClass::queryAggregation( rType );
273 : }
274 0 : virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
275 0 : { BaseClass::acquire(); }
276 0 : virtual void SAL_CALL release() throw () SAL_OVERRIDE
277 0 : { BaseClass::release(); }
278 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
279 0 : { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
280 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
281 0 : { return ImplHelper_getImplementationId( cd::get() ); }
282 : };
283 : }
284 :
285 : #endif
286 :
287 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|