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