bump product version to 4.1.6.2
[LibreOffice.git] / include / cppuhelper / implbase1.hxx
blobead86fe6c56a8869718c7f86b6c0f2f10ddeaf33
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 _CPPUHELPER_IMPLBASE1_HXX_
20 #define _CPPUHELPER_IMPLBASE1_HXX_
22 #include <cppuhelper/implbase_ex.hxx>
23 #include <rtl/instance.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
26 namespace cppu
28 /// @cond INTERNAL
30 struct class_data1
32 sal_Int16 m_nTypes;
33 sal_Bool m_storedTypeRefs;
34 sal_Bool m_storedId;
35 sal_Int8 m_id[ 16 ];
36 type_entry m_typeEntries[ 1 + 1 ];
39 template< typename Ifc1, typename Impl > struct ImplClassData1
41 class_data* operator ()()
43 static class_data1 s_cd =
45 1 +1, sal_False, sal_False,
46 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
48 { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
49 { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
52 return reinterpret_cast< class_data * >(&s_cd);
56 /// @endcond
58 /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
59 and method XInterface::queryInterface(), but no reference counting.
61 @derive
62 Inherit from this class giving your interface(s) to be implemented as template argument(s).
63 Your sub class defines method implementations for these interface(s) including acquire()/
64 release() and delegates incoming queryInterface() calls to this base class.
66 template< class Ifc1 >
67 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper1
68 : public com::sun::star::lang::XTypeProvider
69 , public Ifc1
71 struct cd : public rtl::StaticAggregate< class_data, ImplClassData1 < Ifc1, ImplHelper1<Ifc1> > > {};
72 public:
73 virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
74 { return ImplHelper_query( rType, cd::get(), this ); }
75 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
76 { return ImplHelper_getTypes( cd::get() ); }
77 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
78 { return ImplHelper_getImplementationId( cd::get() ); }
80 #if !defined _MSC_VER // public -> protected changes mangled names there
81 protected:
82 #endif
83 ~ImplHelper1() throw () {}
85 /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
86 com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
87 (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
89 @derive
90 Inherit from this class giving your interface(s) to be implemented as template argument(s).
91 Your sub class defines method implementations for these interface(s).
93 These classes are used when you implement your UNO component.
94 WeakImplHelper1 till WeakImplHelper12 can be used when you want
95 to implement 1 till 12 interfaces in your component.
97 template< class Ifc1 >
98 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper1
99 : public OWeakObject
100 , public com::sun::star::lang::XTypeProvider
101 , public Ifc1
103 struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakImplHelper1< Ifc1 > > > {};
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)
106 { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
107 virtual void SAL_CALL acquire() throw ()
108 { OWeakObject::acquire(); }
109 virtual void SAL_CALL release() throw ()
110 { OWeakObject::release(); }
111 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
112 { return WeakImplHelper_getTypes( cd::get() ); }
113 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
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 >
130 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper1
131 : public OWeakAggObject
132 , public com::sun::star::lang::XTypeProvider
133 , public Ifc1
135 struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggImplHelper1< Ifc1 > > > {};
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)
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)
140 { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
141 virtual void SAL_CALL acquire() throw ()
142 { OWeakAggObject::acquire(); }
143 virtual void SAL_CALL release() throw ()
144 { OWeakAggObject::release(); }
145 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
146 { return WeakAggImplHelper_getTypes( cd::get() ); }
147 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
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 >
167 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper1
168 : public BaseClass
169 , public Ifc1
171 struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, ImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
172 protected:
173 #if (defined __SUNPRO_CC && __SUNPRO_CC <= 0x550)
174 // Hack, to get comphelper::service_decl to work for non-trivial impl classes
175 ImplInheritanceHelper1( com::sun::star::uno::Sequence<com::sun::star::uno::Any> const& args,
176 com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const& xContext ) : BaseClass(args,xContext) {}
177 #endif
178 template< typename T1 >
179 explicit ImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
180 template< typename T1, typename T2 >
181 ImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
182 BaseClass(arg1, arg2) {}
183 template< typename T1, typename T2, typename T3 >
184 ImplInheritanceHelper1(
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 ImplInheritanceHelper1(
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 ImplInheritanceHelper1(
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 ImplInheritanceHelper1(
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 ImplInheritanceHelper1() {}
206 virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
208 com::sun::star::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 ()
214 { BaseClass::acquire(); }
215 virtual void SAL_CALL release() throw ()
216 { BaseClass::release(); }
217 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
218 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
219 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
220 { return ImplHelper_getImplementationId( cd::get() ); }
222 /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
223 com::sun::star::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 com::sun::star::uno::XInterface,
230 com::sun::star::uno::XAggregation and com::sun::star::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 >
240 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper1
241 : public BaseClass
242 , public Ifc1
244 struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, AggImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
245 protected:
246 template< typename T1 >
247 explicit AggImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
248 template< typename T1, typename T2 >
249 AggImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
250 BaseClass(arg1, arg2) {}
251 template< typename T1, typename T2, typename T3 >
252 AggImplInheritanceHelper1(
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 AggImplInheritanceHelper1(
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 AggImplInheritanceHelper1(
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 AggImplInheritanceHelper1(
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 AggImplInheritanceHelper1() {}
274 virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
275 { return BaseClass::queryInterface( rType ); }
276 virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
278 com::sun::star::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 ()
284 { BaseClass::acquire(); }
285 virtual void SAL_CALL release() throw ()
286 { BaseClass::release(); }
287 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
288 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
289 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
290 { return ImplHelper_getImplementationId( cd::get() ); }
294 #endif
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */