1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CPPUHELPER_IMPLBASE3_HXX_
24 #define _CPPUHELPER_IMPLBASE3_HXX_
25 
26 #include <cppuhelper/implbase_ex.hxx>
27 #include <rtl/instance.hxx>
28 
29 namespace cppu
30 {
31     /** @internal */
32     struct class_data3
33     {
34         sal_Int16 m_nTypes;
35         sal_Bool m_storedTypeRefs;
36         sal_Bool m_storedId;
37         sal_Int8 m_id[ 16 ];
38         type_entry m_typeEntries[ 3 + 1 ];
39     };
40 
41     /** @internal */
42     template< typename Ifc1, typename Ifc2, typename Ifc3, typename Impl > struct ImplClassData3
43     {
operator ()cppu::ImplClassData344         class_data* operator ()()
45         {
46             static class_data3 s_cd =
47             {
48                 3 +1, sal_False, sal_False,
49                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
50                 {
51 					{ { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
52 					{ { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
53 					{ { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
54 					{ { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
55                 }
56             };
57             return reinterpret_cast< class_data * >(&s_cd);
58         }
59     };
60 
61     /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider
62         and method XInterface::queryInterface(), but no reference counting.
63 
64         @derive
65         Inherit from this class giving your interface(s) to be implemented as template argument(s).
66         Your sub class defines method implementations for these interface(s) including acquire()/
67         release() and delegates incoming queryInterface() calls to this base class.
68     */
69     template< class Ifc1, class Ifc2, class Ifc3 >
70     class SAL_NO_VTABLE ImplHelper3
71         : public ::com::sun::star::lang::XTypeProvider
72         , public Ifc1, public Ifc2, public Ifc3
73     {
74         /** @internal */
75         struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
76     public:
queryInterface(::com::sun::star::uno::Type const & rType)77         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
78             { return ImplHelper_query( rType, cd::get(), this ); }
getTypes()79         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
80             { return ImplHelper_getTypes( cd::get() ); }
getImplementationId()81         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
82             { return ImplHelper_getImplementationId( cd::get() ); }
83     };
84     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
85         ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
86         (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
87 
88         @derive
89         Inherit from this class giving your interface(s) to be implemented as template argument(s).
90         Your sub class defines method implementations for these interface(s).
91     */
92     template< class Ifc1, class Ifc2, class Ifc3 >
93     class SAL_NO_VTABLE WeakImplHelper3
94         : public OWeakObject
95         , public ::com::sun::star::lang::XTypeProvider
96         , public Ifc1, public Ifc2, public Ifc3
97     {
98         /** @internal */
99         struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
100     public:
queryInterface(::com::sun::star::uno::Type const & rType)101         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
102             { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
acquire()103         virtual void SAL_CALL acquire() throw ()
104             { OWeakObject::acquire(); }
release()105         virtual void SAL_CALL release() throw ()
106             { OWeakObject::release(); }
getTypes()107         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
108             { return WeakImplHelper_getTypes( cd::get() ); }
getImplementationId()109         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
110             { 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, class Ifc3 >
126     class SAL_NO_VTABLE WeakAggImplHelper3
127         : public OWeakAggObject
128         , public ::com::sun::star::lang::XTypeProvider
129         , public Ifc1, public Ifc2, public Ifc3
130     {
131         /** @internal */
132         struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggImplHelper3<Ifc1, Ifc2, Ifc3> > > {};
133     public:
queryInterface(::com::sun::star::uno::Type const & rType)134         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
135             { return OWeakAggObject::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)136         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
137             { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
acquire()138         virtual void SAL_CALL acquire() throw ()
139             { OWeakAggObject::acquire(); }
release()140         virtual void SAL_CALL release() throw ()
141             { OWeakAggObject::release(); }
getTypes()142         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
143             { return WeakAggImplHelper_getTypes( cd::get() ); }
getImplementationId()144         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
145             { return ImplHelper_getImplementationId( cd::get() ); }
146     };
147     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
148         ::com::sun::star::uno::XInterface inherting from a BaseClass.
149         All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
150         if a demanded interface is not supported by this class directly, the request is
151         delegated to the BaseClass.
152 
153         @attention
154         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface
155         and ::com::sun::star::lang::XTypeProvider are implemented properly.  The
156         BaseClass must have at least one ctor that can be called with six or
157         fewer arguments, of which none is of non-const reference type.
158         also has to have a default ctor.
159 
160         @derive
161         Inherit from this class giving your additional interface(s) to be implemented as
162         template argument(s). Your sub class defines method implementations for these interface(s).
163     */
164     template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 >
165     class SAL_NO_VTABLE ImplInheritanceHelper3
166         : public BaseClass
167         , public Ifc1, public Ifc2, public Ifc3
168     {
169         /** @internal */
170         struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {};
171     protected:
172         template< typename T1 >
ImplInheritanceHelper3(T1 const & arg1)173         explicit ImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {}
174         template< typename T1, typename T2 >
ImplInheritanceHelper3(T1 const & arg1,T2 const & arg2)175         ImplInheritanceHelper3(T1 const & arg1, T2 const & arg2):
176             BaseClass(arg1, arg2) {}
177         template< typename T1, typename T2, typename T3 >
ImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3)178         ImplInheritanceHelper3(
179             T1 const & arg1, T2 const & arg2, T3 const & arg3):
180             BaseClass(arg1, arg2, arg3) {}
181         template< typename T1, typename T2, typename T3, typename T4 >
ImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)182         ImplInheritanceHelper3(
183             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
184             BaseClass(arg1, arg2, arg3, arg4) {}
185         template<
186             typename T1, typename T2, typename T3, typename T4, typename T5 >
ImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)187         ImplInheritanceHelper3(
188             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
189             T5 const & arg5):
190             BaseClass(arg1, arg2, arg3, arg4, arg5) {}
191         template<
192             typename T1, typename T2, typename T3, typename T4, typename T5,
193             typename T6 >
ImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)194         ImplInheritanceHelper3(
195             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
196             T5 const & arg5, T6 const & arg6):
197             BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
198     public:
ImplInheritanceHelper3()199         ImplInheritanceHelper3() {}
queryInterface(::com::sun::star::uno::Type const & rType)200         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
201             {
202                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
203                 if (aRet.hasValue())
204                     return aRet;
205                 return BaseClass::queryInterface( rType );
206             }
acquire()207         virtual void SAL_CALL acquire() throw ()
208             { BaseClass::acquire(); }
release()209         virtual void SAL_CALL release() throw ()
210             { BaseClass::release(); }
getTypes()211         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
212             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()213         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
214             { return ImplHelper_getImplementationId( cd::get() ); }
215     };
216     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
217         ::com::sun::star::uno::XInterface inherting from a BaseClass.
218         All acquire(),  release() and queryInterface() calls are delegated to the BaseClass.
219         Upon queryAggregation(), if a demanded interface is not supported by this class directly,
220         the request is delegated to the BaseClass.
221 
222         @attention
223         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface,
224         ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider
225         are implemented properly.  The BaseClass must have at least one ctor
226         that can be called with six or fewer arguments, of which none is of
227         non-const reference type.
228 
229         @derive
230         Inherit from this class giving your additional interface(s) to be implemented as
231         template argument(s). Your sub class defines method implementations for these interface(s).
232     */
233     template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 >
234     class SAL_NO_VTABLE AggImplInheritanceHelper3
235         : public BaseClass
236         , public Ifc1, public Ifc2, public Ifc3
237     {
238         /** @internal */
239         struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, AggImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {};
240     protected:
241         template< typename T1 >
AggImplInheritanceHelper3(T1 const & arg1)242         explicit AggImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {}
243         template< typename T1, typename T2 >
AggImplInheritanceHelper3(T1 const & arg1,T2 const & arg2)244         AggImplInheritanceHelper3(T1 const & arg1, T2 const & arg2):
245             BaseClass(arg1, arg2) {}
246         template< typename T1, typename T2, typename T3 >
AggImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3)247         AggImplInheritanceHelper3(
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 >
AggImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)251         AggImplInheritanceHelper3(
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 >
AggImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)256         AggImplInheritanceHelper3(
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 >
AggImplInheritanceHelper3(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)263         AggImplInheritanceHelper3(
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:
AggImplInheritanceHelper3()268         AggImplInheritanceHelper3() {}
queryInterface(::com::sun::star::uno::Type const & rType)269         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
270             { return BaseClass::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)271         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
272             {
273                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
274                 if (aRet.hasValue())
275                     return aRet;
276                 return BaseClass::queryAggregation( rType );
277             }
acquire()278         virtual void SAL_CALL acquire() throw ()
279             { BaseClass::acquire(); }
release()280         virtual void SAL_CALL release() throw ()
281             { BaseClass::release(); }
getTypes()282         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
283             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()284         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
285             { return ImplHelper_getImplementationId( cd::get() ); }
286     };
287 }
288 
289 #endif
290