From 0d44e98d6aa2c390fd9bcdd97290f463b136ddb6 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 7 Jan 2015 12:18:56 +0100 Subject: Variadic cppu::WeakImplHelper Change-Id: Ia02a7c94ca282f28fa3c191dd65a71b6bf031792 --- cppuhelper/source/factory.cxx | 4 +- include/cppuhelper/implbase.hxx | 116 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 include/cppuhelper/implbase.hxx diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index e288dad52fbd..ea0b14108774 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -873,7 +873,7 @@ sal_Bool SAL_CALL ORegistryFactoryHelper::releaseOnNotification() throw(::com::s return retVal; } -class OFactoryProxyHelper : public WeakImplHelper3< XServiceInfo, XSingleServiceFactory, +class OFactoryProxyHelper : public WeakImplHelper< XServiceInfo, XSingleServiceFactory, XUnloadingPreference > { Reference xFactory; diff --git a/include/cppuhelper/implbase.hxx b/include/cppuhelper/implbase.hxx new file mode 100644 index 000000000000..813ea3d0cf42 --- /dev/null +++ b/include/cppuhelper/implbase.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CPPUHELPER_IMPLBASE_HXX +#define INCLUDED_CPPUHELPER_IMPLBASE_HXX + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined LIBO_INTERNAL_ONLY + +namespace cppu { + +/// @cond INTERNAL + +namespace detail { + +template struct class_dataN { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[16]; + type_entry m_typeEntries[N + 1]; +}; + +template struct ImplClassData { + class_data * operator ()() { + static class_dataN s_cd = { + sizeof... (Ifc) + 1, false, false, {}, + { + { { Ifc::static_type }, + (reinterpret_cast( + static_cast(reinterpret_cast(16))) + - 16) + }..., + CPPUHELPER_DETAIL_TYPEENTRY(css::lang::XTypeProvider) + } + }; + return reinterpret_cast(&s_cd); + } +}; + +} + +/// @endcond + +/** Implementation helper implementing interfaces + com::sun::star::uno::XInterface, com::sun::star::lang::XTypeProvider, and + com::sun::star::uno::XWeak (through cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as + template argument(s). +*/ +template +class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper: + public OWeakObject, public css::lang::XTypeProvider, public Ifc... +{ + struct cd: + rtl::StaticAggregate< + class_data, detail::ImplClassData> + {}; + +public: + css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType) + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE + { return WeakImplHelper_query(aType, cd::get(), this, this); } + + void SAL_CALL acquire() throw () SAL_OVERRIDE { OWeakObject::acquire(); } + + void SAL_CALL release() throw () SAL_OVERRIDE { OWeakObject::release(); } + + css::uno::Sequence SAL_CALL getTypes() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE + { return WeakImplHelper_getTypes(cd::get()); } + + css::uno::Sequence SAL_CALL getImplementationId() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE + { return css::uno::Sequence(); } +}; + +} + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit