LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/tools - weakbase.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 50 58 86.2 %
Date: 2012-08-25 Functions: 32 35 91.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 16 87.5 %

           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                 :            : 
      20                 :            : #ifndef _TOOLS_WEAKBASE_HXX_
      21                 :            : #define _TOOLS_WEAKBASE_HXX_
      22                 :            : 
      23                 :            : #include <tools/weakbase.h>
      24                 :            : 
      25                 :            : /// see weakbase.h for documentation
      26                 :            : 
      27                 :            : namespace tools
      28                 :            : {
      29                 :            : 
      30                 :            : template< class reference_type >
      31                 :     183623 : inline WeakReference< reference_type >::WeakReference()
      32                 :            : {
      33                 :     183623 :     mpWeakConnection = new WeakConnection<reference_type>( 0 );
      34                 :     183623 :     mpWeakConnection->acquire();
      35                 :     183623 : }
      36                 :            : 
      37                 :            : template< class reference_type >
      38                 :     259281 : inline WeakReference< reference_type >::WeakReference( reference_type* pReference )
      39                 :            : {
      40 [ +  + ][ +  + ]:     259281 :     if( pReference )
      41                 :     169591 :         mpWeakConnection = pReference->getWeakConnection();
      42                 :            :     else
      43                 :      89690 :         mpWeakConnection = new WeakConnection<reference_type>( 0 );
      44                 :            : 
      45                 :     259281 :     mpWeakConnection->acquire();
      46                 :     259281 : }
      47                 :            : 
      48                 :            : template< class reference_type >
      49                 :          0 : inline WeakReference< reference_type >::WeakReference( const WeakReference< reference_type >& rWeakRef )
      50                 :            : {
      51                 :          0 :     mpWeakConnection = rWeakRef.mpWeakConnection;
      52                 :          0 :     mpWeakConnection->acquire();
      53                 :          0 : }
      54                 :            : 
      55                 :            : template< class reference_type >
      56                 :     442482 : inline WeakReference< reference_type >::~WeakReference()
      57                 :            : {
      58                 :     442482 :     mpWeakConnection->release();
      59                 :     442482 : }
      60                 :            : 
      61                 :            : template< class reference_type >
      62                 :    5498876 : inline bool WeakReference< reference_type >::is() const
      63                 :            : {
      64                 :    5498876 :     return mpWeakConnection->mpReference != 0;
      65                 :            : }
      66                 :            : 
      67                 :            : template< class reference_type >
      68                 :    1757801 : inline reference_type * WeakReference< reference_type >::get() const
      69                 :            : {
      70                 :    1757801 :     return mpWeakConnection->mpReference;
      71                 :            : }
      72                 :            : 
      73                 :            : template< class reference_type >
      74                 :     699706 : inline void WeakReference< reference_type >::reset( reference_type* pReference )
      75                 :            : {
      76                 :     699706 :     mpWeakConnection->release();
      77                 :            : 
      78         [ +  + ]:     699706 :     if( pReference )
      79                 :     371835 :         mpWeakConnection = pReference->getWeakConnection();
      80                 :            :     else
      81                 :     327871 :         mpWeakConnection = new WeakConnection<reference_type>( 0 );
      82                 :            : 
      83                 :     699706 :     mpWeakConnection->acquire();
      84                 :     699706 : }
      85                 :            : 
      86                 :            : template< class reference_type >
      87                 :    3519814 : inline reference_type * WeakReference< reference_type >::operator->() const
      88                 :            : {
      89                 :            :     OSL_PRECOND(mpWeakConnection, "tools::WeakReference::operator->() : null body");
      90                 :    3519814 :     return mpWeakConnection->mpReference;
      91                 :            : }
      92                 :            : 
      93                 :            : template< class reference_type >
      94                 :            : inline sal_Bool WeakReference< reference_type >::operator==(const reference_type * pReferenceObject) const
      95                 :            : {
      96                 :            :     return mpWeakConnection->mpReference == pReferenceObject;
      97                 :            : }
      98                 :            : 
      99                 :            : template< class reference_type >
     100                 :          0 : inline sal_Bool WeakReference< reference_type >::operator==(const WeakReference<reference_type> & handle) const
     101                 :            : {
     102                 :          0 :     return mpWeakConnection == handle.mpWeakConnection;
     103                 :            : }
     104                 :            : 
     105                 :            : template< class reference_type >
     106                 :          0 : inline sal_Bool WeakReference< reference_type >::operator!=(const WeakReference<reference_type> & handle) const
     107                 :            : {
     108                 :          0 :     return mpWeakConnection != handle.mpWeakConnection;
     109                 :            : }
     110                 :            : 
     111                 :            : template< class reference_type >
     112                 :            : inline sal_Bool WeakReference< reference_type >::operator<(const WeakReference<reference_type> & handle) const
     113                 :            : {
     114                 :            :     return mpWeakConnection->mpReference < handle.mpWeakConnection->mpReference;
     115                 :            : }
     116                 :            : 
     117                 :            : template< class reference_type >
     118                 :            : inline sal_Bool WeakReference< reference_type >::operator>(const WeakReference<reference_type> & handle) const
     119                 :            : {
     120                 :            :     return mpWeakConnection->mpReference > handle.mpWeakConnection->mpReference;
     121                 :            : }
     122                 :            : 
     123                 :            : template< class reference_type >
     124                 :      89826 : inline WeakReference<reference_type>& WeakReference<reference_type>::operator= (
     125                 :            :     const WeakReference<reference_type>& rReference)
     126                 :            : {
     127         [ +  - ]:      89826 :     if (&rReference != this)
     128                 :            :     {
     129                 :      89826 :         mpWeakConnection->release();
     130                 :            : 
     131                 :      89826 :         mpWeakConnection = rReference.mpWeakConnection;
     132                 :      89826 :         mpWeakConnection->acquire();
     133                 :            :     }
     134                 :      89826 :     return *this;
     135                 :            : }
     136                 :            : 
     137                 :            : template< class reference_type >
     138                 :     165550 : inline WeakBase< reference_type >::WeakBase()
     139                 :            : {
     140                 :     165550 :     mpWeakConnection = 0;
     141                 :     165550 : }
     142                 :            : 
     143                 :            : template< class reference_type >
     144                 :     164686 : inline WeakBase< reference_type >::~WeakBase()
     145                 :            : {
     146         [ +  + ]:     164686 :     if( mpWeakConnection )
     147                 :            :     {
     148                 :     107591 :         mpWeakConnection->mpReference = 0;
     149                 :     107591 :         mpWeakConnection->release();
     150                 :     107591 :         mpWeakConnection = 0;
     151                 :            :     }
     152                 :     164686 : }
     153                 :            : 
     154                 :            : template< class reference_type >
     155                 :      57349 : inline void WeakBase< reference_type >::clearWeak()
     156                 :            : {
     157         [ +  + ]:      57349 :     if( mpWeakConnection )
     158                 :      12114 :         mpWeakConnection->mpReference = 0;
     159                 :      57349 : }
     160                 :            : 
     161                 :            : template< class reference_type >
     162                 :     541426 : inline WeakConnection< reference_type >* WeakBase< reference_type >::getWeakConnection()
     163                 :            : {
     164 [ +  + ][ -  + ]:     541426 :     if( !mpWeakConnection )
     165                 :            :     {
     166                 :     107695 :         mpWeakConnection = new WeakConnection< reference_type >( static_cast< reference_type* >( this ) );
     167                 :     107695 :         mpWeakConnection->acquire();
     168                 :            :     }
     169                 :     541426 :     return mpWeakConnection;
     170                 :            : }
     171                 :            : 
     172                 :            : }
     173                 :            : 
     174                 :            : #endif
     175                 :            : 
     176                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10