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