Branch libreoffice-5-0-4
[LibreOffice.git] / include / cppuhelper / compbase.hxx
blobae578de1af8ab383847d083c1ac79c286198f0fb
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 .
20 #ifndef INCLUDED_CPPUHELPER_COMPBASE_HXX
21 #define INCLUDED_CPPUHELPER_COMPBASE_HXX
23 #include <sal/config.h>
25 #include <exception>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <com/sun/star/uno/RuntimeException.hpp>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/uno/Type.hxx>
33 #include <cppuhelper/compbase_ex.hxx>
34 #include <cppuhelper/implbase.hxx>
35 #include <rtl/instance.hxx>
36 #include <sal/types.h>
38 namespace com { namespace sun { namespace star { namespace lang {
39 class XEventListener;
40 } } } }
41 namespace osl { class Mutex; }
43 #if defined LIBO_INTERNAL_ONLY
45 namespace cppu {
47 /** Implementation helper implementing interfaces
48 com::sun::star::uno::XInterface, com::sun::star::lang::XTypeProvider, and
49 com::sun::star::lang::XComponent.
51 Upon disposing objects of this class, sub-classes receive a disposing()
52 call.
54 @attention
55 The mutex reference passed to the constructor has to outlive the constructed
56 instance.
58 template<typename... Ifc>
59 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper:
60 public WeakComponentImplHelperBase, public css::lang::XTypeProvider,
61 public Ifc...
63 struct cd:
64 rtl::StaticAggregate<
65 class_data, detail::ImplClassData<WeakComponentImplHelper, Ifc...>>
66 {};
68 public:
69 WeakComponentImplHelper(osl::Mutex & mutex) throw ():
70 WeakComponentImplHelperBase(mutex) {}
72 css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType)
73 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
74 { return WeakComponentImplHelper_query(aType, cd::get(), this, this); }
76 void SAL_CALL acquire() throw () SAL_OVERRIDE
77 { WeakComponentImplHelperBase::acquire(); }
79 void SAL_CALL release() throw () SAL_OVERRIDE
80 { WeakComponentImplHelperBase::release(); }
82 void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception)
83 SAL_OVERRIDE
84 { WeakComponentImplHelperBase::dispose(); }
86 void SAL_CALL addEventListener(
87 css::uno::Reference<css::lang::XEventListener> const & xListener)
88 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
89 { WeakComponentImplHelperBase::addEventListener(xListener); }
91 void SAL_CALL removeEventListener(
92 css::uno::Reference<css::lang::XEventListener> const & aListener)
93 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
94 { WeakComponentImplHelperBase::removeEventListener(aListener); }
96 css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
97 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
98 { return WeakComponentImplHelper_getTypes(cd::get()); }
100 css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
101 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
102 { return css::uno::Sequence<sal_Int8>(); }
107 #endif
109 #endif
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */