LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/inc - DisposeHelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 15 60.0 %
Date: 2012-12-27 Functions: 22 25 88.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 CHART2_DISPOSEHELPER_HXX
      20             : #define CHART2_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         943 :     void Dispose( const T & xIntf )
      36             : {
      37             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp(
      38         943 :         xIntf, ::com::sun::star::uno::UNO_QUERY );
      39         943 :     if( xComp.is())
      40          61 :         xComp->dispose();
      41         943 : }
      42             : 
      43             : template< class Intf >
      44         943 :     void DisposeAndClear( ::com::sun::star::uno::Reference< Intf > & rIntf )
      45             : {
      46         943 :     Dispose< ::com::sun::star::uno::Reference< Intf > >( rIntf );
      47         943 :     rIntf.set( 0 );
      48         943 : }
      49             : 
      50             : template< class T >
      51             :     struct DisposeFunctor : public ::std::unary_function< T, void >
      52             : {
      53           0 :     void operator() ( const T & xIntf )
      54             :     {
      55           0 :         Dispose< T >( xIntf );
      56           0 :     }
      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           0 :     void DisposeAllElements( Container & rContainer )
      79             : {
      80           0 :     ::std::for_each( rContainer.begin(), rContainer.end(), DisposeFunctor< typename Container::value_type >());
      81           0 : }
      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             : // CHART2_DISPOSEHELPER_HXX
      93             : #endif
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10