Branch libreoffice-5-0-4
[LibreOffice.git] / include / cppuhelper / implbase5.hxx
blob891a09715889fb2436c5d28ae111c109ccba8592
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CPPUHELPER_IMPLBASE5_HXX
20 #define INCLUDED_CPPUHELPER_IMPLBASE5_HXX
22 #include <cppuhelper/implbase_ex.hxx>
23 #include <rtl/instance.hxx>
25 namespace cppu
27 /// @cond INTERNAL
29 struct class_data5
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 ];
38 template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Impl >
39 struct ImplClassData5
41 class_data* operator ()()
43 static class_data5 s_cd =
45 5 +1, sal_False, sal_False,
46 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
48 CPPUHELPER_DETAIL_TYPEENTRY(Ifc1),
49 CPPUHELPER_DETAIL_TYPEENTRY(Ifc2),
50 CPPUHELPER_DETAIL_TYPEENTRY(Ifc3),
51 CPPUHELPER_DETAIL_TYPEENTRY(Ifc4),
52 CPPUHELPER_DETAIL_TYPEENTRY(Ifc5),
53 CPPUHELPER_DETAIL_TYPEENTRY(com::sun::star::lang::XTypeProvider)
56 return reinterpret_cast< class_data * >(&s_cd);
60 /// @endcond
62 /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
63 and method XInterface::queryInterface(), but no reference counting.
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.
70 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
71 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
75 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
76 public:
77 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 { return ImplHelper_query( rType, cd::get(), this ); }
79 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 { return ImplHelper_getTypes( cd::get() ); }
81 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
82 { return ImplHelper_getImplementationId( cd::get() ); }
84 #if !defined _MSC_VER // public -> protected changes mangled names there
85 protected:
86 #endif
87 ~ImplHelper5() throw () {}
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).
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).
97 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
98 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
103 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
104 public:
105 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 { return WeakImplHelper_query( rType, cd::get(), this, static_cast<OWeakObject *>(this) ); }
107 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
108 { OWeakObject::acquire(); }
109 virtual void SAL_CALL release() throw () SAL_OVERRIDE
110 { OWeakObject::release(); }
111 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 { return WeakImplHelper_getTypes( cd::get() ); }
113 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
114 { return ImplHelper_getImplementationId( cd::get() ); }
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.
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).
129 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
130 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
135 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
136 public:
137 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 { return OWeakAggObject::queryInterface( rType ); }
139 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 { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, static_cast<OWeakAggObject *>(this) ); }
141 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
142 { OWeakAggObject::acquire(); }
143 virtual void SAL_CALL release() throw () SAL_OVERRIDE
144 { OWeakAggObject::release(); }
145 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 { return WeakAggImplHelper_getTypes( cd::get() ); }
147 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
148 { return ImplHelper_getImplementationId( cd::get() ); }
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.
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.
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).
166 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
167 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper5
168 : public BaseClass
169 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
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 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 ImplInheritanceHelper5(
184 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
185 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 ImplInheritanceHelper5() {}
201 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
203 com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
204 if (aRet.hasValue())
205 return aRet;
206 return BaseClass::queryInterface( rType );
208 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
209 { BaseClass::acquire(); }
210 virtual void SAL_CALL release() throw () SAL_OVERRIDE
211 { BaseClass::release(); }
212 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 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
214 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
215 { return ImplHelper_getImplementationId( cd::get() ); }
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.
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.
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).
234 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
235 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper5
236 : public BaseClass
237 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
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 AggImplInheritanceHelper5() {}
269 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 { return BaseClass::queryInterface( rType ); }
271 virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
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 );
278 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
279 { BaseClass::acquire(); }
280 virtual void SAL_CALL release() throw () SAL_OVERRIDE
281 { BaseClass::release(); }
282 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
283 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
284 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
285 { return ImplHelper_getImplementationId( cd::get() ); }
289 #endif
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */