Line data Source code
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 :
20 : /** This header generates the following template classes with a variable number
21 : of interfaces:
22 :
23 : comphelper::PartialWeakComponentImplHelper<N> <typename Ifc1, ...,
24 : typename Ifc<N> >
25 :
26 : as already present in headers cppuhelper/implbase<1-12>.hxx and
27 : cppuhelper/compbase<1-12>.hxx.
28 : <N> denotes the number of interface types passed as template arguments.
29 : Don't use this header for interface numbers up to 12;
30 : always use the existing cppuhelper/(impl|comp)base<1-12>.hxx headers
31 : for this purpose, which eases debugging.
32 :
33 : Including this header requires a little discipline, because it has no
34 : include guards. Please use the following external include guard rule
35 : where <N> is the number of interface types:
36 :
37 : #ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_<N>
38 : #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_<N>
39 : #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER <N>
40 : #include <comphelper/implbase_var.hxx>
41 : #endif
42 :
43 : Additionally you can
44 :
45 : #define COMPHELPER_IMPLBASE_MAX_CTOR_ARGS <N>
46 :
47 : to control the maximum number of templated ctor arguments for the
48 : ImplInheritanceHelper<N> classes.
49 : The default is a maximum of 6 arguments.
50 : */
51 :
52 : #ifndef COMPHELPER_IMPLBASE_INTERFACE_NUMBER
53 : #error "you have to define COMPHELPER_IMPLBASE_INTERFACE_NUMBER prior to including comphelper/implbase_var.hxx!"
54 : #endif // ! defined(COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
55 :
56 : #if !defined(COMPHELPER_IMPLBASE_TEST_PHASE) && COMPHELPER_IMPLBASE_INTERFACE_NUMBER <= 12
57 : #error "include proper header file: cppuhelper/implbase<N>.hxx or cppuhelper/compbase<N>.hxx!"
58 : #endif
59 :
60 : #ifndef COMPHELPER_IMPLBASE_MAX_CTOR_ARGS
61 : #define COMPHELPER_IMPLBASE_MAX_CTOR_ARGS 6 // default
62 : #endif
63 :
64 : #include <cppuhelper/implbase_ex.hxx>
65 : #include <rtl/instance.hxx>
66 : #include <cppuhelper/compbase_ex.hxx>
67 :
68 : #include <boost/preprocessor/cat.hpp>
69 : #include <boost/preprocessor/repetition.hpp>
70 : #include <boost/preprocessor/arithmetic/add.hpp>
71 :
72 : namespace comphelper {
73 :
74 : // Suppress warnings about hidden functions in case any of the IfcN has
75 : // functions named dispose, addEventListener, or removeEventListener:
76 :
77 : namespace detail {
78 :
79 : struct BOOST_PP_CAT(class_data, COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
80 : {
81 : sal_Int16 m_nTypes;
82 : sal_Bool m_storedTypeRefs;
83 : sal_Bool m_storedId;
84 : sal_Int8 m_id[16];
85 : ::cppu::type_entry m_typeEntries[COMPHELPER_IMPLBASE_INTERFACE_NUMBER + 1];
86 : };
87 :
88 : /// @internal
89 : template < BOOST_PP_ENUM_PARAMS(COMPHELPER_IMPLBASE_INTERFACE_NUMBER,
90 : typename Ifc), typename Impl >
91 : struct BOOST_PP_CAT(ImplClassData, COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
92 : {
93 20 : ::cppu::class_data * operator()() {
94 : static BOOST_PP_CAT(class_data, COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
95 : s_cd = {
96 : COMPHELPER_IMPLBASE_INTERFACE_NUMBER + 1, sal_False, sal_False,
97 : { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
98 : {
99 : #define COMPHELPER_IMPLBASE_classdataList(z_, n_, unused_) \
100 : { { BOOST_PP_CAT(Ifc, n_)::static_type }, \
101 : reinterpret_cast<sal_IntPtr>( static_cast< BOOST_PP_CAT(Ifc, n_) * >( \
102 : reinterpret_cast<Impl *>(16) ) ) - 16 },
103 : BOOST_PP_REPEAT(COMPHELPER_IMPLBASE_INTERFACE_NUMBER,
104 : COMPHELPER_IMPLBASE_classdataList, ~)
105 : #undef COMPHELPER_IMPLBASE_classdataList
106 : { { ::com::sun::star::lang::XTypeProvider::static_type },
107 : reinterpret_cast<sal_IntPtr>(
108 : static_cast< ::com::sun::star::lang::XTypeProvider * >(
109 : reinterpret_cast<Impl *>(16) ) ) - 16 }
110 : }
111 : };
112 20 : return reinterpret_cast< ::cppu::class_data * >(&s_cd);
113 : }
114 : };
115 :
116 : } // namespace detail
117 :
118 : template < BOOST_PP_ENUM_PARAMS(COMPHELPER_IMPLBASE_INTERFACE_NUMBER,
119 : typename Ifc) >
120 101 : class SAL_NO_VTABLE BOOST_PP_CAT(PartialWeakComponentImplHelper,
121 : COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
122 : : public ::cppu::WeakComponentImplHelperBase,
123 : public ::com::sun::star::lang::XTypeProvider,
124 : BOOST_PP_ENUM_PARAMS(COMPHELPER_IMPLBASE_INTERFACE_NUMBER, public Ifc)
125 : {
126 : /// @internal
127 : struct cd : public ::rtl::StaticAggregate<
128 : ::cppu::class_data,
129 : BOOST_PP_CAT(detail::ImplClassData,
130 : COMPHELPER_IMPLBASE_INTERFACE_NUMBER)
131 : <
132 : BOOST_PP_ENUM_PARAMS(COMPHELPER_IMPLBASE_INTERFACE_NUMBER, Ifc),
133 : BOOST_PP_CAT(PartialWeakComponentImplHelper,
134 : COMPHELPER_IMPLBASE_INTERFACE_NUMBER)<
135 : BOOST_PP_ENUM_PARAMS(COMPHELPER_IMPLBASE_INTERFACE_NUMBER, Ifc)>
136 : > > {};
137 :
138 : public:
139 109 : BOOST_PP_CAT(PartialWeakComponentImplHelper, COMPHELPER_IMPLBASE_INTERFACE_NUMBER)(
140 109 : ::osl::Mutex & rMutex ) : WeakComponentImplHelperBase(rMutex) {}
141 :
142 : virtual ::com::sun::star::uno::Any
143 15943 : SAL_CALL queryInterface( ::com::sun::star::uno::Type const& rType )
144 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
145 : {
146 : return ::cppu::WeakComponentImplHelper_query(
147 : rType, cd::get(), this,
148 15943 : static_cast< ::cppu::WeakComponentImplHelperBase * >(this) );
149 : }
150 40339 : virtual void SAL_CALL acquire() throw () SAL_OVERRIDE
151 40339 : { WeakComponentImplHelperBase::acquire(); }
152 40324 : virtual void SAL_CALL release() throw () SAL_OVERRIDE
153 40324 : { WeakComponentImplHelperBase::release(); }
154 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
155 2 : SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
156 2 : { return ::cppu::WeakComponentImplHelper_getTypes( cd::get() ); }
157 : virtual ::com::sun::star::uno::Sequence<sal_Int8>
158 0 : SAL_CALL getImplementationId()
159 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
160 0 : { return ::cppu::ImplHelper_getImplementationId( cd::get() ); }
161 : };
162 :
163 :
164 : } // namespace comphelper
165 :
166 : // undef for multiple use/inclusion of this header:
167 : #undef COMPHELPER_IMPLBASE_MAX_CTOR_ARGS
168 : #undef COMPHELPER_IMPLBASE_INTERFACE_NUMBER
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|