LCOV - code coverage report
Current view: top level - include/cppuhelper - implbase.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 26 84.6 %
Date: 2015-06-13 12:38:46 Functions: 579 1171 49.4 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_CPPUHELPER_IMPLBASE_HXX
      21             : #define INCLUDED_CPPUHELPER_IMPLBASE_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <cstddef>
      26             : #include <exception>
      27             : #include <utility>
      28             : 
      29             : #include <com/sun/star/lang/XTypeProvider.hpp>
      30             : #include <com/sun/star/uno/Any.hxx>
      31             : #include <com/sun/star/uno/RuntimeException.hpp>
      32             : #include <com/sun/star/uno/Sequence.hxx>
      33             : #include <com/sun/star/uno/Type.hxx>
      34             : #include <cppuhelper/implbase_ex.hxx>
      35             : #include <cppuhelper/weak.hxx>
      36             : #include <rtl/instance.hxx>
      37             : #include <sal/types.h>
      38             : 
      39             : #if defined LIBO_INTERNAL_ONLY
      40             : 
      41             : namespace cppu {
      42             : 
      43             : /// @cond INTERNAL
      44             : 
      45             : namespace detail {
      46             : 
      47             : template<std::size_t N> struct class_dataN {
      48             :     sal_Int16 m_nTypes;
      49             :     sal_Bool m_storedTypeRefs;
      50             :     sal_Bool m_storedId;
      51             :     sal_Int8 m_id[16];
      52             :     type_entry m_typeEntries[N + 1];
      53             : };
      54             : 
      55             : template<typename Impl, typename... Ifc> struct ImplClassData {
      56        2453 :     class_data * operator ()() {
      57             :         static class_dataN<sizeof... (Ifc)> s_cd = {
      58             :             sizeof... (Ifc) + 1, false, false, {},
      59             :             {
      60             :                 { { Ifc::static_type },
      61             :                   (reinterpret_cast<sal_IntPtr>(
      62             :                       static_cast<Ifc *>(reinterpret_cast<Impl *>(16)))
      63             :                    - 16)
      64             :                 }...,
      65             :                 CPPUHELPER_DETAIL_TYPEENTRY(css::lang::XTypeProvider)
      66             :             }
      67             :         };
      68        2453 :         return reinterpret_cast<class_data *>(&s_cd);
      69             :     }
      70             : };
      71             : 
      72             : }
      73             : 
      74             : /// @endcond
      75             : 
      76             : /** Implementation helper implementing interfaces
      77             :     com::sun::star::uno::XInterface, com::sun::star::lang::XTypeProvider, and
      78             :     com::sun::star::uno::XWeak (through cppu::OWeakObject).
      79             : 
      80             :     @derive
      81             :     Inherit from this class giving your interface(s) to be implemented as
      82             :     template argument(s).
      83             : */
      84             : template<typename... Ifc>
      85         257 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper:
      86             :     public OWeakObject, public css::lang::XTypeProvider, public Ifc...
      87             : {
      88             :     struct cd:
      89             :         rtl::StaticAggregate<
      90             :             class_data, detail::ImplClassData<WeakImplHelper, Ifc...>>
      91             :     {};
      92             : 
      93             : protected:
      94     2585248 :     WeakImplHelper() {}
      95             : 
      96     2584193 :     virtual ~WeakImplHelper() {}
      97             : 
      98             : public:
      99     4135624 :     css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType)
     100             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     101     4135624 :     { return WeakImplHelper_query(aType, cd::get(), this, this); }
     102             : 
     103    65510113 :     void SAL_CALL acquire() throw () SAL_OVERRIDE { OWeakObject::acquire(); }
     104             : 
     105    65496519 :     void SAL_CALL release() throw () SAL_OVERRIDE { OWeakObject::release(); }
     106             : 
     107       21927 :     css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
     108             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     109       21927 :     { return WeakImplHelper_getTypes(cd::get()); }
     110             : 
     111           0 :     css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
     112             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     113           0 :     { return css::uno::Sequence<sal_Int8>(); }
     114             : };
     115             : 
     116             : /** Implementation helper implementing interfaces
     117             :     com::sun::star::uno::XInterface and com::sun::star::lang::XTypeProvider
     118             :     inherting from a BaseClass.
     119             : 
     120             :     All acquire() and release() calls are delegated to the BaseClass.  Upon
     121             :     queryInterface(), if a demanded interface is not supported by this class
     122             :     directly, the request is delegated to the BaseClass.
     123             : 
     124             :     @attention
     125             :     The BaseClass has to be complete in the sense that
     126             :     com::sun::star::uno::XInterface and com::sun::star::lang::XTypeProvider are
     127             :     implemented properly.
     128             : 
     129             :     @derive
     130             :     Inherit from this class giving your additional interface(s) to be
     131             :     implemented as template argument(s).
     132             : */
     133             : template<typename BaseClass, typename... Ifc>
     134             : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper:
     135             :     public BaseClass, public Ifc...
     136             : {
     137             :     struct cd:
     138             :         rtl::StaticAggregate<
     139             :             class_data, detail::ImplClassData<ImplInheritanceHelper, Ifc...>>
     140             :     {};
     141             : 
     142             : protected:
     143        7075 :     template<typename... Arg> ImplInheritanceHelper(Arg &&... arg):
     144        7075 :         BaseClass(std::forward<Arg>(arg)...)
     145        7075 :     {}
     146             : 
     147        7075 :     virtual ~ImplInheritanceHelper() {}
     148             : 
     149             : public:
     150       60699 :     css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType)
     151             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     152             :     {
     153       60699 :         css::uno::Any ret(ImplHelper_queryNoXInterface(aType, cd::get(), this));
     154       60699 :         return ret.hasValue() ? ret : BaseClass::queryInterface(aType);
     155             :     }
     156             : 
     157      181816 :     void SAL_CALL acquire() throw () SAL_OVERRIDE { BaseClass::acquire(); }
     158             : 
     159      181816 :     void SAL_CALL release() throw () SAL_OVERRIDE { BaseClass::release(); }
     160             : 
     161           3 :     css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
     162             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     163           3 :     { return ImplInhHelper_getTypes(cd::get(), BaseClass::getTypes()); }
     164             : 
     165           0 :     css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
     166             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     167           0 :     { return css::uno::Sequence<sal_Int8>(); }
     168             : };
     169             : 
     170             : }
     171             : 
     172             : #endif
     173             : 
     174             : #endif
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11