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