LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/cppuhelper - weak.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 12 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _CPPUHELPER_WEAK_HXX_
      29                 :            : #define _CPPUHELPER_WEAK_HXX_
      30                 :            : 
      31                 :            : #include <osl/interlck.h>
      32                 :            : #include <rtl/alloc.h>
      33                 :            : #include <cppuhelper/weakref.hxx>
      34                 :            : #include <cppuhelper/queryinterface.hxx>
      35                 :            : #include <com/sun/star/uno/XWeak.hpp>
      36                 :            : #include "cppuhelperdllapi.h"
      37                 :            : 
      38                 :            : 
      39                 :            : namespace cppu
      40                 :            : {
      41                 :            : 
      42                 :            : class OWeakConnectionPoint;
      43                 :            : 
      44                 :            : /** Base class to implement an UNO object supporting weak references, i.e. the object can be held
      45                 :            :     weakly (by a ::com::sun::star::uno::WeakReference).
      46                 :            :     This implementation copes with reference counting.  Upon last release(), the virtual dtor
      47                 :            :     is called.
      48                 :            : 
      49                 :            :     @derive
      50                 :            :     Inherit from this class and delegate acquire()/ release() calls.
      51                 :            : */
      52                 :            : class CPPUHELPER_DLLPUBLIC OWeakObject : public ::com::sun::star::uno::XWeak
      53                 :            : {
      54                 :            :     friend class OWeakConnectionPoint;
      55                 :            : 
      56                 :            : protected:
      57                 :            :     /** Virtual dtor.
      58                 :            : 
      59                 :            :         @attention
      60                 :            :         Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any
      61                 :            :         exception upon destruction!
      62                 :            :     */
      63                 :            :     virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
      64                 :            : 
      65                 :            :     /** disposes and resets m_pWeakConnectionPoint
      66                 :            :         @precond
      67                 :            :             m_refCount equals 0
      68                 :            :     */
      69                 :            :     void    disposeWeakConnectionPoint();
      70                 :            : 
      71                 :            :     /** reference count.
      72                 :            : 
      73                 :            :         @attention
      74                 :            :         Don't modify manually!  Use acquire() and release().
      75                 :            :     */
      76                 :            :     oslInterlockedCount m_refCount;
      77                 :            : 
      78                 :            :     /// @cond INTERNAL
      79                 :            : 
      80                 :            :     /** Container of all weak reference listeners and the connection point from the weak reference.
      81                 :            :     */
      82                 :            :     OWeakConnectionPoint * m_pWeakConnectionPoint;
      83                 :            : 
      84                 :            :     /** reserved for future use. do not use.
      85                 :            :     */
      86                 :            :     void * m_pReserved;
      87                 :            : 
      88                 :            :     /// @endcond
      89                 :            : 
      90                 :            : public:
      91                 :            :     /// @cond INTERNAL
      92                 :            :     // these are here to force memory de/allocation to sal lib.
      93                 :   10054060 :     inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
      94                 :   10054060 :         { return ::rtl_allocateMemory( nSize ); }
      95                 :    9972680 :     inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
      96                 :    9972680 :         { ::rtl_freeMemory( pMem ); }
      97                 :            :     inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
      98                 :            :         { return pMem; }
      99                 :            :     inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
     100                 :            :         {}
     101                 :            :     /// @endcond
     102                 :            : 
     103                 :            : #ifdef _MSC_VER
     104                 :            :     /** Default Constructor.  Sets the reference count to zero.
     105                 :            :         Accidentally occurs in msvc mapfile = > had to be outlined.
     106                 :            :     */
     107                 :            :     OWeakObject() SAL_THROW(());
     108                 :            : #else
     109                 :            :     /** Default Constructor.  Sets the reference count to zero.
     110                 :            :     */
     111                 :   11496521 :     inline OWeakObject() SAL_THROW(())
     112                 :            :         : m_refCount( 0 )
     113                 :   11496521 :         , m_pWeakConnectionPoint( 0 )
     114                 :   11496521 :         {}
     115                 :            : #endif
     116                 :            :     /** Dummy copy constructor.  Set the reference count to zero.
     117                 :            : 
     118                 :            :         @param rObj dummy param
     119                 :            :     */
     120                 :          9 :     inline OWeakObject( const OWeakObject & rObj ) SAL_THROW(())
     121                 :            :         : com::sun::star::uno::XWeak()
     122                 :            :         , m_refCount( 0 )
     123                 :          9 :         , m_pWeakConnectionPoint( 0 )
     124                 :            :         {
     125                 :            :         (void) rObj;
     126                 :          9 :         }
     127                 :            :     /** Dummy assignment operator. Does not affect reference count.
     128                 :            : 
     129                 :            :         @return this OWeakObject
     130                 :            :     */
     131                 :            :     inline OWeakObject & SAL_CALL operator = ( const OWeakObject &)
     132                 :            :         SAL_THROW(())
     133                 :            :         { return *this; }
     134                 :            : 
     135                 :            :     /** Basic queryInterface() implementation supporting \::com::sun::star::uno::XWeak and
     136                 :            :         \::com::sun::star::uno::XInterface.
     137                 :            : 
     138                 :            :         @param rType demanded type
     139                 :            :         @return demanded type or empty any
     140                 :            :     */
     141                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
     142                 :            :         const ::com::sun::star::uno::Type & rType )
     143                 :            :         throw (::com::sun::star::uno::RuntimeException);
     144                 :            :     /** increasing m_refCount
     145                 :            :     */
     146                 :            :     virtual void SAL_CALL acquire()
     147                 :            :         throw ();
     148                 :            :     /** decreasing m_refCount
     149                 :            :     */
     150                 :            :     virtual void SAL_CALL release()
     151                 :            :         throw ();
     152                 :            : 
     153                 :            :     /** XWeak::queryAdapter() implementation
     154                 :            : 
     155                 :            :         @return a \::com::sun::star::uno::XAdapter reference
     156                 :            :     */
     157                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter()
     158                 :            :         throw (::com::sun::star::uno::RuntimeException);
     159                 :            : 
     160                 :            :     /** Cast operator to XInterface reference.
     161                 :            : 
     162                 :            :         @return XInterface reference
     163                 :            :     */
     164                 :    3701593 :     inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () SAL_THROW(())
     165                 :    3701593 :         { return this; }
     166                 :            : };
     167                 :            : 
     168                 :            : }
     169                 :            : 
     170                 :            : #endif
     171                 :            : 
     172                 :            : 
     173                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10