Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / cppuhelper / implbase4.hxx
blob639630d202bca0bd04a653d8e568cf6fb7aa4bcc
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_IMPLBASE4_HXX
20 #define INCLUDED_CPPUHELPER_IMPLBASE4_HXX
22 #include <cppuhelper/implbase_ex.hxx>
23 #include <rtl/instance.hxx>
25 namespace cppu
27 /// @cond INTERNAL
29 struct class_data4
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[ 4 + 1 ];
38 template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Impl >
39 struct ImplClassData4
41 class_data* operator ()()
43 static class_data4 s_cd =
45 4 +1, false, 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(css::lang::XTypeProvider)
55 return reinterpret_cast< class_data * >(&s_cd);
59 /// @endcond
61 /** Implementation helper implementing interface css::lang::XTypeProvider
62 and method XInterface::queryInterface(), but no reference counting.
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.
69 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
70 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper4
71 : public css::lang::XTypeProvider
72 , public Ifc1, public Ifc2, public Ifc3, public Ifc4
74 struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
75 public:
76 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
77 { return ImplHelper_query( rType, cd::get(), this ); }
78 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
79 { return ImplHelper_getTypes( cd::get() ); }
80 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
81 { return ImplHelper_getImplementationId( cd::get() ); }
83 #if !defined _MSC_VER // public -> protected changes mangled names there
84 protected:
85 #elif defined __clang__
86 #pragma clang diagnostic push
87 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
88 #endif
89 ~ImplHelper4() throw () {}
90 #if defined _MSC_VER && defined __clang__
91 #pragma clang diagnostic pop
92 #endif
94 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
95 css::uno::XInterface which supports weak mechanism to be held weakly
96 (supporting css::uno::XWeak through ::cppu::OWeakObject).
98 @derive
99 Inherit from this class giving your interface(s) to be implemented as template argument(s).
100 Your sub class defines method implementations for these interface(s).
102 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
103 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper4
104 : public OWeakObject
105 , public css::lang::XTypeProvider
106 , public Ifc1, public Ifc2, public Ifc3, public Ifc4
108 struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
109 public:
110 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
111 { return WeakImplHelper_query( rType, cd::get(), this, static_cast<OWeakObject *>(this) ); }
112 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
113 { OWeakObject::acquire(); }
114 virtual void SAL_CALL release() throw () SAL_OVERRIDE
115 { OWeakObject::release(); }
116 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
117 { return WeakImplHelper_getTypes( cd::get() ); }
118 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
119 { return ImplHelper_getImplementationId( cd::get() ); }
121 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
122 css::uno::XInterface which supports weak mechanism to be held weakly
123 (supporting css::uno::XWeak through ::cppu::OWeakAggObject).
124 In addition, it supports also aggregation meaning object of this class can be aggregated
125 (css::uno::XAggregation through ::cppu::OWeakAggObject).
126 If a delegator is set (this object is aggregated), then incoming queryInterface()
127 calls are delegated to the delegator object. If the delegator does not support the
128 demanded interface, it calls queryAggregation() on its aggregated objects.
130 @derive
131 Inherit from this class giving your interface(s) to be implemented as template argument(s).
132 Your sub class defines method implementations for these interface(s).
134 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
135 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper4
136 : public OWeakAggObject
137 , public css::lang::XTypeProvider
138 , public Ifc1, public Ifc2, public Ifc3, public Ifc4
140 struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
141 public:
142 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
143 { return OWeakAggObject::queryInterface( rType ); }
144 virtual css::uno::Any SAL_CALL queryAggregation( css::uno::Type const & rType ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
145 { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, static_cast<OWeakAggObject *>(this) ); }
146 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
147 { OWeakAggObject::acquire(); }
148 virtual void SAL_CALL release() throw () SAL_OVERRIDE
149 { OWeakAggObject::release(); }
150 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
151 { return WeakAggImplHelper_getTypes( cd::get() ); }
152 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
153 { return ImplHelper_getImplementationId( cd::get() ); }
155 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
156 css::uno::XInterface inherting from a BaseClass.
157 All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
158 if a demanded interface is not supported by this class directly, the request is
159 delegated to the BaseClass.
161 @attention
162 The BaseClass has to be complete in a sense, that css::uno::XInterface
163 and css::lang::XTypeProvider are implemented properly. The
164 BaseClass must have at least one ctor that can be called with six or
165 fewer arguments, of which none is of non-const reference type.
167 @derive
168 Inherit from this class giving your additional interface(s) to be implemented as
169 template argument(s). Your sub class defines method implementations for these interface(s).
171 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
172 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper4
173 : public BaseClass
174 , public Ifc1, public Ifc2, public Ifc3, public Ifc4
176 struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
177 protected:
178 template< typename T1 >
179 explicit ImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
180 template< typename T1, typename T2 >
181 ImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
182 BaseClass(arg1, arg2) {}
183 template< typename T1, typename T2, typename T3 >
184 ImplInheritanceHelper4(
185 T1 const & arg1, T2 const & arg2, T3 const & arg3):
186 BaseClass(arg1, arg2, arg3) {}
187 template< typename T1, typename T2, typename T3, typename T4 >
188 ImplInheritanceHelper4(
189 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
190 BaseClass(arg1, arg2, arg3, arg4) {}
191 template<
192 typename T1, typename T2, typename T3, typename T4, typename T5 >
193 ImplInheritanceHelper4(
194 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
195 T5 const & arg5):
196 BaseClass(arg1, arg2, arg3, arg4, arg5) {}
197 template<
198 typename T1, typename T2, typename T3, typename T4, typename T5,
199 typename T6 >
200 ImplInheritanceHelper4(
201 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
202 T5 const & arg5, T6 const & arg6):
203 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
204 public:
205 ImplInheritanceHelper4() {}
206 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) throw (css::uno::RuntimeException) SAL_OVERRIDE
208 css::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
209 if (aRet.hasValue())
210 return aRet;
211 return BaseClass::queryInterface( rType );
213 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
214 { BaseClass::acquire(); }
215 virtual void SAL_CALL release() throw () SAL_OVERRIDE
216 { BaseClass::release(); }
217 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException) SAL_OVERRIDE
218 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
219 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException) SAL_OVERRIDE
220 { return ImplHelper_getImplementationId( cd::get() ); }
222 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
223 css::uno::XInterface inherting from a BaseClass.
224 All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
225 Upon queryAggregation(), if a demanded interface is not supported by this class directly,
226 the request is delegated to the BaseClass.
228 @attention
229 The BaseClass has to be complete in a sense, that css::uno::XInterface,
230 css::uno::XAggregation and css::lang::XTypeProvider
231 are implemented properly. The BaseClass must have at least one ctor
232 that can be called with six or fewer arguments, of which none is of
233 non-const reference type.
235 @derive
236 Inherit from this class giving your additional interface(s) to be implemented as
237 template argument(s). Your sub class defines method implementations for these interface(s).
239 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
240 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper4
241 : public BaseClass
242 , public Ifc1, public Ifc2, public Ifc3, public Ifc4
244 struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, AggImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
245 protected:
246 template< typename T1 >
247 explicit AggImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
248 template< typename T1, typename T2 >
249 AggImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
250 BaseClass(arg1, arg2) {}
251 template< typename T1, typename T2, typename T3 >
252 AggImplInheritanceHelper4(
253 T1 const & arg1, T2 const & arg2, T3 const & arg3):
254 BaseClass(arg1, arg2, arg3) {}
255 template< typename T1, typename T2, typename T3, typename T4 >
256 AggImplInheritanceHelper4(
257 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
258 BaseClass(arg1, arg2, arg3, arg4) {}
259 template<
260 typename T1, typename T2, typename T3, typename T4, typename T5 >
261 AggImplInheritanceHelper4(
262 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
263 T5 const & arg5):
264 BaseClass(arg1, arg2, arg3, arg4, arg5) {}
265 template<
266 typename T1, typename T2, typename T3, typename T4, typename T5,
267 typename T6 >
268 AggImplInheritanceHelper4(
269 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
270 T5 const & arg5, T6 const & arg6):
271 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
272 public:
273 AggImplInheritanceHelper4() {}
274 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) throw (css::uno::RuntimeException) SAL_OVERRIDE
275 { return BaseClass::queryInterface( rType ); }
276 virtual css::uno::Any SAL_CALL queryAggregation( css::uno::Type const & rType ) throw (css::uno::RuntimeException) SAL_OVERRIDE
278 css::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
279 if (aRet.hasValue())
280 return aRet;
281 return BaseClass::queryAggregation( rType );
283 virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
284 { BaseClass::acquire(); }
285 virtual void SAL_CALL release() throw () SAL_OVERRIDE
286 { BaseClass::release(); }
287 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
288 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
289 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
290 { return ImplHelper_getImplementationId( cd::get() ); }
294 #endif
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */