LCOV - code coverage report
Current view: top level - chart2/source/inc - DisposeHelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 15 100.0 %
Date: 2012-08-25 Functions: 25 25 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 58 51.7 %

           Branch data     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                 :       1582 :     void Dispose( const T & xIntf )
      36                 :            : {
      37                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp(
      38 [ +  - ][ +  - ]:       1582 :         xIntf, ::com::sun::star::uno::UNO_QUERY );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      39 [ +  + ][ +  + ]:       1582 :     if( xComp.is())
         [ +  + ][ +  + ]
         [ -  + ][ -  + ]
                 [ +  + ]
      40 [ +  - ][ +  - ]:       1582 :         xComp->dispose();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ +  - ][ +  - ]
      41                 :       1582 : }
      42                 :            : 
      43                 :            : template< class Intf >
      44                 :       1412 :     void DisposeAndClear( ::com::sun::star::uno::Reference< Intf > & rIntf )
      45                 :            : {
      46                 :       1412 :     Dispose< ::com::sun::star::uno::Reference< Intf > >( rIntf );
      47                 :       1412 :     rIntf.set( 0 );
      48                 :       1412 : }
      49                 :            : 
      50                 :            : template< class T >
      51                 :            :     struct DisposeFunctor : public ::std::unary_function< T, void >
      52                 :            : {
      53                 :        170 :     void operator() ( const T & xIntf )
      54                 :            :     {
      55                 :        170 :         Dispose< T >( xIntf );
      56                 :        170 :     }
      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                 :        100 :     void DisposeAllElements( Container & rContainer )
      79                 :            : {
      80         [ +  - ]:        100 :     ::std::for_each( rContainer.begin(), rContainer.end(), DisposeFunctor< typename Container::value_type >());
      81                 :        100 : }
      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