LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/cppuhelper - weakref.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 18 100.0 %
Date: 2012-12-27 Functions: 151 406 37.2 %
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 _CPPUHELPER_WEAKREF_HXX_
      20             : #define _CPPUHELPER_WEAKREF_HXX_
      21             : 
      22             : #include <com/sun/star/uno/XInterface.hpp>
      23             : #include "cppuhelperdllapi.h"
      24             : 
      25             : 
      26             : namespace com
      27             : {
      28             : namespace sun
      29             : {
      30             : namespace star
      31             : {
      32             : namespace uno
      33             : {
      34             : 
      35             : class OWeakRefListener;
      36             : 
      37             : /** The WeakReferenceHelper holds a weak reference to an object. This object must implement
      38             :     the ::com::sun::star::uno::XWeak interface.  The implementation is thread safe.
      39             : */
      40             : class CPPUHELPER_DLLPUBLIC WeakReferenceHelper
      41             : {
      42             : public:
      43             :     /** Default ctor.  Creates an empty weak reference.
      44             :     */
      45       90944 :     inline WeakReferenceHelper() SAL_THROW(())
      46       90944 :         : m_pImpl( 0 )
      47       90944 :         {}
      48             : 
      49             :     /** Copy ctor.  Initialize this reference with the same interface as in rWeakRef.
      50             : 
      51             :         @param rWeakRef another weak ref
      52             :     */
      53             :     WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
      54             :     /** Initialize this reference with the hard interface reference xInt. If the implementation
      55             :         behind xInt does not support XWeak or XInt is null then this reference will be null.
      56             : 
      57             :         @param xInt another hard interface reference
      58             :     */
      59             :     WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
      60             :         SAL_THROW(());
      61             :     /** Releases this reference.
      62             :     */
      63             :     ~WeakReferenceHelper() SAL_THROW(());
      64             : 
      65             :     /** Releases this reference and takes over rWeakRef.
      66             : 
      67             :         @param rWeakRef another weak ref
      68             :     */
      69             :     WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
      70             : 
      71             :     /** Releases this reference and takes over hard reference xInt.
      72             :         If the implementation behind xInt does not support XWeak
      73             :         or XInt is null, then this reference is null.
      74             : 
      75             :         @param xInt another hard reference
      76             :     */
      77             :     WeakReferenceHelper & SAL_CALL operator = (
      78             :             const ::com::sun::star::uno::Reference<
      79             :                 ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
      80             : 
      81             :     /** Returns true if both weak refs reference to the same object.
      82             : 
      83             :         @param rObj another weak ref
      84             :         @return true, if both weak refs reference to the same object.
      85             :     */
      86        6076 :     inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
      87        6076 :         { return (get() == rObj.get()); }
      88             : 
      89             :     /**  Gets a hard reference to the object.
      90             : 
      91             :          @return hard reference or null, if the weakly referenced interface has gone
      92             :     */
      93             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const SAL_THROW(());
      94             :     /**  Gets a hard reference to the object.
      95             : 
      96             :          @return hard reference or null, if the weakly referenced interface has gone
      97             :     */
      98     1165131 :     inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
      99     1165131 :         { return get(); }
     100             : 
     101             :     /** Releases this reference.
     102             : 
     103             :         @since UDK 3.2.12
     104             :     */
     105             :     void SAL_CALL clear() SAL_THROW(());
     106             : 
     107             : protected:
     108             :     /// @cond INTERNAL
     109             :     OWeakRefListener * m_pImpl;
     110             :     /// @endcond
     111             : };
     112             : 
     113             : /** The WeakReference<> holds a weak reference to an object. This object must implement
     114             :     the ::com::sun::star::uno::XWeak interface.  The implementation is thread safe.
     115             : 
     116             :     @tparam interface_type type of interface
     117             : */
     118             : template< class interface_type >
     119      238371 : class WeakReference : public WeakReferenceHelper
     120             : {
     121             : public:
     122             :     /** Default ctor.  Creates an empty weak reference.
     123             :     */
     124       64525 :     inline WeakReference() SAL_THROW(())
     125       64525 :         : WeakReferenceHelper()
     126       64525 :         {}
     127             : 
     128             :     /** Copy ctor.  Initialize this reference with a hard reference.
     129             : 
     130             :         @param rRef another hard ref
     131             :     */
     132       28930 :     inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW(())
     133       28930 :         : WeakReferenceHelper( rRef )
     134       28930 :         {}
     135             : 
     136             :     /** Releases this reference and takes over hard reference xInt.
     137             :         If the implementation behind xInt does not support XWeak
     138             :         or XInt is null, then this reference is null.
     139             : 
     140             :         @param xInt another hard reference
     141             : 
     142             :         @since UDK 3.2.12
     143             :     */
     144       52071 :     WeakReference & SAL_CALL operator = (
     145             :             const ::com::sun::star::uno::Reference< interface_type > & xInt )
     146             :         SAL_THROW(())
     147       52071 :         { WeakReferenceHelper::operator=(xInt); return *this; }
     148             : 
     149             :     /**  Gets a hard reference to the object.
     150             : 
     151             :          @return hard reference or null, if the weakly referenced interface has gone
     152             :     */
     153       82591 :     inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
     154       82591 :         { return Reference< interface_type >::query( get() ); }
     155             : };
     156             : 
     157             : }
     158             : }
     159             : }
     160             : }
     161             : 
     162             : #endif
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10