UDK 3.2.7 C/C++ API Reference
cppuhelper/weak.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*************************************************************************
00003  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 #ifndef _CPPUHELPER_WEAK_HXX_
00029 #define _CPPUHELPER_WEAK_HXX_
00030 
00031 #include <osl/interlck.h>
00032 #include <rtl/alloc.h>
00033 #include <cppuhelper/weakref.hxx>
00034 #include <cppuhelper/queryinterface.hxx>
00035 #include <com/sun/star/uno/XWeak.hpp>
00036 #include "cppuhelperdllapi.h"
00037 
00038 
00039 namespace cppu
00040 {
00041 
00042 class OWeakConnectionPoint;
00043 
00052 class CPPUHELPER_DLLPUBLIC OWeakObject : public ::com::sun::star::uno::XWeak
00053 {
00054     friend class OWeakConnectionPoint;
00055 
00056 protected:
00063     virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
00064 
00069     void    disposeWeakConnectionPoint();
00070 
00076     oslInterlockedCount m_refCount;
00077 
00079 
00082     OWeakConnectionPoint * m_pWeakConnectionPoint;
00083 
00086     void * m_pReserved;
00087 
00089 
00090 public:
00092     // these are here to force memory de/allocation to sal lib.
00093     inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
00094         { return ::rtl_allocateMemory( nSize ); }
00095     inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
00096         { ::rtl_freeMemory( pMem ); }
00097     inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
00098         { return pMem; }
00099     inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
00100         {}
00102 
00103 #ifdef _MSC_VER
00104 
00107     OWeakObject() SAL_THROW(());
00108 #else
00109 
00111     inline OWeakObject() SAL_THROW(())
00112         : m_refCount( 0 )
00113         , m_pWeakConnectionPoint( 0 )
00114         {}
00115 #endif
00116 
00120     inline OWeakObject( const OWeakObject & rObj ) SAL_THROW(())
00121         : com::sun::star::uno::XWeak()
00122         , m_refCount( 0 )
00123         , m_pWeakConnectionPoint( 0 )
00124         {
00125         (void) rObj;
00126         }
00131     inline OWeakObject & SAL_CALL operator = ( const OWeakObject &)
00132         SAL_THROW(())
00133         { return *this; }
00134 
00141     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
00142         const ::com::sun::star::uno::Type & rType )
00143         throw (::com::sun::star::uno::RuntimeException);
00146     virtual void SAL_CALL acquire()
00147         throw ();
00150     virtual void SAL_CALL release()
00151         throw ();
00152 
00157     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter()
00158         throw (::com::sun::star::uno::RuntimeException);
00159 
00164     inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () SAL_THROW(())
00165         { return this; }
00166 };
00167 
00168 }
00169 
00170 #endif
00171 
00172 
00173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines