UDK 3.2.7 C/C++ API Reference
cppuhelper/weakref.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_WEAKREF_HXX_
00029 #define _CPPUHELPER_WEAKREF_HXX_
00030 
00031 #include <com/sun/star/uno/XInterface.hpp>
00032 #include "cppuhelperdllapi.h"
00033 
00034 
00035 namespace com
00036 {
00037 namespace sun
00038 {
00039 namespace star
00040 {
00041 namespace uno
00042 {
00043 
00044 class OWeakRefListener;
00045 
00049 class CPPUHELPER_DLLPUBLIC WeakReferenceHelper
00050 {
00051 public:
00054     inline WeakReferenceHelper() SAL_THROW(())
00055         : m_pImpl( 0 )
00056         {}
00057 
00062     WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
00068     WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
00069         SAL_THROW(());
00072     ~WeakReferenceHelper() SAL_THROW(());
00073 
00078     WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
00079 
00086     WeakReferenceHelper & SAL_CALL operator = (
00087             const ::com::sun::star::uno::Reference<
00088                 ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
00089 
00095     inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
00096         { return (get() == rObj.get()); }
00097 
00102     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const SAL_THROW(());
00107     inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
00108         { return get(); }
00109 
00114     void SAL_CALL clear() SAL_THROW(());
00115 
00116 protected:
00118     OWeakRefListener * m_pImpl;
00120 };
00121 
00127 template< class interface_type >
00128 class WeakReference : public WeakReferenceHelper
00129 {
00130 public:
00133     inline WeakReference() SAL_THROW(())
00134         : WeakReferenceHelper()
00135         {}
00136 
00141     inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW(())
00142         : WeakReferenceHelper( rRef )
00143         {}
00144 
00153     WeakReference & SAL_CALL operator = (
00154             const ::com::sun::star::uno::Reference< interface_type > & xInt )
00155         SAL_THROW(())
00156         { WeakReferenceHelper::operator=(xInt); return *this; }
00157 
00162     inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
00163         { return Reference< interface_type >::query( get() ); }
00164 };
00165 
00166 }
00167 }
00168 }
00169 }
00170 
00171 #endif
00172 
00173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines