LibreOffice Module cppuhelper (master)  1
compbase.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 
20 #ifndef INCLUDED_CPPUHELPER_COMPBASE_HXX
21 #define INCLUDED_CPPUHELPER_COMPBASE_HXX
22 
23 #include "sal/config.h"
24 
25 #include "com/sun/star/lang/XTypeProvider.hpp"
26 #include "com/sun/star/uno/Any.h"
27 #include "com/sun/star/uno/Reference.h"
28 #include "com/sun/star/uno/Sequence.h"
29 #include "com/sun/star/uno/Type.h"
31 #include "cppuhelper/implbase.hxx"
32 #include "rtl/instance.hxx"
33 #include "sal/types.h"
34 
35 namespace com { namespace sun { namespace star { namespace lang {
36  class XEventListener;
37 } } } }
38 namespace osl { class Mutex; }
39 
40 #if defined LIBO_INTERNAL_ONLY
41 
42 // A replacement for WeakAggComponentImplHelper1 has deliberately been left out,
43 // as the underlying aggregation mechanism is known broken in general and should
44 // not be used.
45 
46 namespace cppu {
47 
64 template<typename... Ifc>
65 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper:
66  public WeakComponentImplHelperBase, public css::lang::XTypeProvider,
67  public Ifc...
68 {
69  struct cd:
70  rtl::StaticAggregate<
71  class_data,
72  detail::ImplClassData<PartialWeakComponentImplHelper, Ifc...>>
73  {};
74 
75 public:
76  PartialWeakComponentImplHelper(osl::Mutex & mutex) SAL_NOEXCEPT:
77  WeakComponentImplHelperBase(mutex) {}
78 
79  css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType) SAL_OVERRIDE
80  { return WeakComponentImplHelper_query(aType, cd::get(), this, this); }
81 
82  void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
83  { WeakComponentImplHelperBase::acquire(); }
84 
85  void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
86  { WeakComponentImplHelperBase::release(); }
87 
88  void SAL_CALL dispose()
89  SAL_OVERRIDE
90  { WeakComponentImplHelperBase::dispose(); }
91 
92  css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() SAL_OVERRIDE
93  { return WeakComponentImplHelper_getTypes(cd::get()); }
94 
95  css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() SAL_OVERRIDE
96  { return css::uno::Sequence<sal_Int8>(); }
97 };
98 
110 template<typename... Ifc>
111 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper:
112  public PartialWeakComponentImplHelper<Ifc...>
113 {
114 public:
115  WeakComponentImplHelper(osl::Mutex & mutex) SAL_NOEXCEPT:
116  PartialWeakComponentImplHelper<Ifc...>(mutex) {}
117 
118  void SAL_CALL addEventListener(
119  css::uno::Reference<css::lang::XEventListener> const & xListener) SAL_OVERRIDE
120  { WeakComponentImplHelperBase::addEventListener(xListener); }
121 
122  void SAL_CALL removeEventListener(
123  css::uno::Reference<css::lang::XEventListener> const & aListener) SAL_OVERRIDE
124  { WeakComponentImplHelperBase::removeEventListener(aListener); }
125 };
126 
127 }
128 
129 #endif
130 
131 #endif
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Any SAL_CALL WeakComponentImplHelper_query(Type const &rType, class_data *cd, void *that, WeakComponentImplHelperBase *pBase)
Sequence< Type > SAL_CALL WeakComponentImplHelper_getTypes(class_data *cd)
std::mutex mutex
exports com.sun.star. lang
#define SAL_NO_VTABLE
void dispose()
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.