LCOV - code coverage report
Current view: top level - chart2/source/inc - DisposeHelper.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 15 15 100.0 %
Date: 2014-11-03 Functions: 25 25 100.0 %
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             : #ifndef INCLUDED_CHART2_SOURCE_INC_DISPOSEHELPER_HXX
      20             : #define INCLUDED_CHART2_SOURCE_INC_DISPOSEHELPER_HXX
      21             : 
      22             : #include <com/sun/star/uno/Reference.hxx>
      23             : #include <com/sun/star/lang/XComponent.hpp>
      24             : 
      25             : #include <functional>
      26             : #include <algorithm>
      27             : #include <utility>
      28             : 
      29             : namespace chart
      30             : {
      31             : namespace DisposeHelper
      32             : {
      33             : 
      34             : template< class T >
      35       17041 :     void Dispose( const T & xIntf )
      36             : {
      37             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp(
      38       17041 :         xIntf, ::com::sun::star::uno::UNO_QUERY );
      39       17041 :     if( xComp.is())
      40        4464 :         xComp->dispose();
      41       17041 : }
      42             : 
      43             : template< class Intf >
      44       16878 :     void DisposeAndClear( ::com::sun::star::uno::Reference< Intf > & rIntf )
      45             : {
      46       16878 :     Dispose< ::com::sun::star::uno::Reference< Intf > >( rIntf );
      47       16878 :     rIntf.set( 0 );
      48       16878 : }
      49             : 
      50             : template< class T >
      51             :     struct DisposeFunctor : public ::std::unary_function< T, void >
      52             : {
      53         163 :     void operator() ( const T & xIntf )
      54             :     {
      55         163 :         Dispose< T >( xIntf );
      56         163 :     }
      57             : };
      58             : 
      59             : template< typename T >
      60             :     struct DisposeFirstOfPairFunctor : public ::std::unary_function< T, void >
      61             : {
      62             :     void operator() ( const T & rElem )
      63             :     {
      64             :         Dispose< typename T::first_type >( rElem.first );
      65             :     }
      66             : };
      67             : 
      68             : template< typename T >
      69             :     struct DisposeSecondOfPairFunctor : public ::std::unary_function< T, void >
      70             : {
      71             :     void operator() ( const T & rElem )
      72             :     {
      73             :         Dispose< typename T::second_type >( rElem.second );
      74             :     }
      75             : };
      76             : 
      77             : template< class Container >
      78          68 :     void DisposeAllElements( Container & rContainer )
      79             : {
      80          68 :     ::std::for_each( rContainer.begin(), rContainer.end(), DisposeFunctor< typename Container::value_type >());
      81          68 : }
      82             : 
      83             : template< class Map >
      84             :     void DisposeAllMapElements( Map & rContainer )
      85             : {
      86             :     ::std::for_each( rContainer.begin(), rContainer.end(), DisposeSecondOfPairFunctor< typename Map::value_type >());
      87             : }
      88             : 
      89             : } //  namespace DisposeHelper
      90             : } //  namespace chart
      91             : 
      92             : // INCLUDED_CHART2_SOURCE_INC_DISPOSEHELPER_HXX
      93             : #endif
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10