LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
implbase2.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_CPPUHELPER_IMPLBASE2_HXX
20 #define INCLUDED_CPPUHELPER_IMPLBASE2_HXX
21 
23 #include <rtl/instance.hxx>
24 
25 namespace cppu
26 {
28 
29  struct class_data2
30  {
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[ 2 + 1 ];
36  };
37 
38  template< typename Ifc1, typename Ifc2, typename Impl > struct ImplClassData2
39  {
40  class_data* operator ()()
41  {
42  static class_data2 s_cd =
43  {
44  2 +1, sal_False, sal_False,
45  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
46  {
47  { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
48  { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
49  { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
50  }
51  };
52  return reinterpret_cast< class_data * >(&s_cd);
53  }
54  };
55 
57 
66  template< class Ifc1, class Ifc2 >
67  class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper2
68  : public com::sun::star::lang::XTypeProvider
69  , public Ifc1, public Ifc2
70  {
71  struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplHelper2<Ifc1, Ifc2> > > {};
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, std::exception) SAL_OVERRIDE
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, std::exception) SAL_OVERRIDE
76  { return ImplHelper_getTypes( cd::get() ); }
77  virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
78  { return ImplHelper_getImplementationId( cd::get() ); }
79 
80 #if !defined _MSC_VER // public -> protected changes mangled names there
81  protected:
82 #endif
83  ~ImplHelper2() throw () {}
84  };
93  template< class Ifc1, class Ifc2 >
94  class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper2
95  : public OWeakObject
96  , public com::sun::star::lang::XTypeProvider
97  , public Ifc1, public Ifc2
98  {
99  struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakImplHelper2<Ifc1, Ifc2> > > {};
100  public:
101  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
102  { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
103  virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
104  { OWeakObject::acquire(); }
105  virtual void SAL_CALL release() throw () SAL_OVERRIDE
106  { OWeakObject::release(); }
107  virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
108  { return WeakImplHelper_getTypes( cd::get() ); }
109  virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
110  { return ImplHelper_getImplementationId( cd::get() ); }
111  };
125  template< class Ifc1, class Ifc2 >
126  class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper2
127  : public OWeakAggObject
128  , public com::sun::star::lang::XTypeProvider
129  , public Ifc1, public Ifc2
130  {
131  struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggImplHelper2<Ifc1, Ifc2> > > {};
132  public:
133  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
134  { return OWeakAggObject::queryInterface( rType ); }
135  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
136  { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
137  virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
139  virtual void SAL_CALL release() throw () SAL_OVERRIDE
141  virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
142  { return WeakAggImplHelper_getTypes( cd::get() ); }
143  virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
144  { return ImplHelper_getImplementationId( cd::get() ); }
145  };
162  template< class BaseClass, class Ifc1, class Ifc2 >
163  class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper2
164  : public BaseClass
165  , public Ifc1, public Ifc2
166  {
167  struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
168  protected:
169  template< typename T1 >
170  explicit ImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
171  template< typename T1, typename T2 >
172  ImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
173  BaseClass(arg1, arg2) {}
174  template< typename T1, typename T2, typename T3 >
176  T1 const & arg1, T2 const & arg2, T3 const & arg3):
177  BaseClass(arg1, arg2, arg3) {}
178  template< typename T1, typename T2, typename T3, typename T4 >
180  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
181  BaseClass(arg1, arg2, arg3, arg4) {}
182  template<
183  typename T1, typename T2, typename T3, typename T4, typename T5 >
185  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
186  T5 const & arg5):
187  BaseClass(arg1, arg2, arg3, arg4, arg5) {}
188  template<
189  typename T1, typename T2, typename T3, typename T4, typename T5,
190  typename T6 >
192  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
193  T5 const & arg5, T6 const & arg6):
194  BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
195  public:
197  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
198  {
199  com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
200  if (aRet.hasValue())
201  return aRet;
202  return BaseClass::queryInterface( rType );
203  }
204  virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
205  { BaseClass::acquire(); }
206  virtual void SAL_CALL release() throw () SAL_OVERRIDE
207  { BaseClass::release(); }
208  virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
209  { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
210  virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
211  { return ImplHelper_getImplementationId( cd::get() ); }
212  };
230  template< class BaseClass, class Ifc1, class Ifc2 >
231  class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper2
232  : public BaseClass
233  , public Ifc1, public Ifc2
234  {
235  struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, AggImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
236  protected:
237  template< typename T1 >
238  explicit AggImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
239  template< typename T1, typename T2 >
240  AggImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
241  BaseClass(arg1, arg2) {}
242  template< typename T1, typename T2, typename T3 >
244  T1 const & arg1, T2 const & arg2, T3 const & arg3):
245  BaseClass(arg1, arg2, arg3) {}
246  template< typename T1, typename T2, typename T3, typename T4 >
248  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
249  BaseClass(arg1, arg2, arg3, arg4) {}
250  template<
251  typename T1, typename T2, typename T3, typename T4, typename T5 >
253  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
254  T5 const & arg5):
255  BaseClass(arg1, arg2, arg3, arg4, arg5) {}
256  template<
257  typename T1, typename T2, typename T3, typename T4, typename T5,
258  typename T6 >
260  T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
261  T5 const & arg5, T6 const & arg6):
262  BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
263  public:
265  virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
266  { return BaseClass::queryInterface( rType ); }
267  virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
268  {
269  com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
270  if (aRet.hasValue())
271  return aRet;
272  return BaseClass::queryAggregation( rType );
273  }
274  virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
275  { BaseClass::acquire(); }
276  virtual void SAL_CALL release() throw () SAL_OVERRIDE
277  { BaseClass::release(); }
278  virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
279  { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
280  virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) SAL_OVERRIDE
281  { return ImplHelper_getImplementationId( cd::get() ); }
282  };
283 }
284 
285 #endif
286 
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual com::sun::star::uno::Any queryInterface(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:73
inline::com::sun::star::uno::Any queryInterface(const ::com::sun::star::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
virtual com::sun::star::uno::Sequence< sal_Int8 > getImplementationId() SAL_OVERRIDE
Definition: implbase2.hxx:77
virtual com::sun::star::uno::Any queryInterface(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:133
virtual com::sun::star::uno::Any queryInterface(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:101
Base class to implement an UNO object supporting weak references, i.e.
Definition: weakagg.hxx:40
virtual com::sun::star::uno::Any queryAggregation(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:135
virtual void release() SAL_OVERRIDE
decreasing m_refCount
Definition: implbase2.hxx:105
unsigned char sal_Bool
Definition: types.h:46
Implementation helper implementing interface com::sun::star::lang::XTypeProvider and queryInterface()...
Definition: implbase2.hxx:67
C++ class representing an IDL meta type.
Definition: Type.h:55
AggImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3)
Definition: implbase2.hxx:243
bool hasValue() const SAL_THROW(())
Tests if any contains a value.
Definition: Any.h:150
AggImplInheritanceHelper2(T1 const &arg1, T2 const &arg2)
Definition: implbase2.hxx:240
#define sal_False
Definition: types.h:47
AggImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4)
Definition: implbase2.hxx:247
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
virtual void release() SAL_OVERRIDE
Definition: implbase2.hxx:276
virtual void acquire() SAL_OVERRIDE
increasing m_refCount
Definition: implbase2.hxx:103
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > getTypes() SAL_OVERRIDE
Definition: implbase2.hxx:208
virtual ::com::sun::star::uno::Any queryInterface(const ::com::sun::star::uno::Type &rType) SAL_OVERRIDE
If a delegator is set, then the delegator is queried for the demanded interface.
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:423
ImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4, T5 const &arg5, T6 const &arg6)
Definition: implbase2.hxx:191
~ImplHelper2()
Definition: implbase2.hxx:83
ImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4)
Definition: implbase2.hxx:179
AggImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4, T5 const &arg5)
Definition: implbase2.hxx:252
virtual void acquire() SAL_OVERRIDE
increasing m_refCount
signed char sal_Int8
Definition: types.h:51
ImplInheritanceHelper2(T1 const &arg1, T2 const &arg2)
Definition: implbase2.hxx:172
virtual com::sun::star::uno::Any queryInterface(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:265
virtual com::sun::star::uno::Any queryInterface(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:197
AggImplInheritanceHelper2(T1 const &arg1)
Definition: implbase2.hxx:238
Definition: Enterable.hxx:26
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > getTypes() SAL_OVERRIDE
Definition: implbase2.hxx:75
ImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3)
Definition: implbase2.hxx:175
C++ class representing an IDL any.
Definition: Any.h:46
virtual void release() SAL_OVERRIDE
If a delegator is set, then the delegators gets released.
Definition: implbase2.hxx:139
virtual com::sun::star::uno::Sequence< sal_Int8 > getImplementationId() SAL_OVERRIDE
Definition: implbase2.hxx:210
AggImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4, T5 const &arg5, T6 const &arg6)
Definition: implbase2.hxx:259
Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star:...
Definition: implbase2.hxx:231
virtual void acquire() SAL_OVERRIDE
Definition: implbase2.hxx:204
virtual void release() SAL_OVERRIDE
If a delegator is set, then the delegators gets released.
#define SAL_NO_VTABLE
Use this for pure virtual classes, e.g.
Definition: types.h:317
virtual com::sun::star::uno::Sequence< sal_Int8 > getImplementationId() SAL_OVERRIDE
Definition: implbase2.hxx:109
virtual void acquire() SAL_OVERRIDE
Definition: implbase2.hxx:274
Base class to implement an UNO object supporting weak references, i.e.
Definition: weak.hxx:43
virtual com::sun::star::uno::Sequence< sal_Int8 > getImplementationId() SAL_OVERRIDE
Definition: implbase2.hxx:280
virtual com::sun::star::uno::Any queryAggregation(com::sun::star::uno::Type const &rType) SAL_OVERRIDE
Definition: implbase2.hxx:267
AggImplInheritanceHelper2()
Definition: implbase2.hxx:264
Helper class for a late-initialized static aggregate, e.g.
Definition: instance.hxx:542
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > getTypes() SAL_OVERRIDE
Definition: implbase2.hxx:107
virtual void release() SAL_OVERRIDE
decreasing m_refCount
Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star:...
Definition: implbase2.hxx:94
Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star:...
Definition: implbase2.hxx:126
ImplInheritanceHelper2()
Definition: implbase2.hxx:196
Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star:...
Definition: implbase2.hxx:163
ImplInheritanceHelper2(T1 const &arg1, T2 const &arg2, T3 const &arg3, T4 const &arg4, T5 const &arg5)
Definition: implbase2.hxx:184
virtual void acquire() SAL_OVERRIDE
If a delegator is set, then the delegators gets acquired.
Definition: implbase2.hxx:137
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > getTypes() SAL_OVERRIDE
Definition: implbase2.hxx:278
virtual com::sun::star::uno::Sequence< sal_Int8 > getImplementationId() SAL_OVERRIDE
Definition: implbase2.hxx:143
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > getTypes() SAL_OVERRIDE
Definition: implbase2.hxx:141
ImplInheritanceHelper2(T1 const &arg1)
Definition: implbase2.hxx:170
virtual void acquire() SAL_OVERRIDE
If a delegator is set, then the delegators gets acquired.
virtual void release() SAL_OVERRIDE
Definition: implbase2.hxx:206
Definition: types.h:391