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  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 #ifndef _CPPUHELPER_WEAKREF_HXX_
00020 #define _CPPUHELPER_WEAKREF_HXX_
00021 
00022 #include <com/sun/star/uno/XInterface.hpp>
00023 #include "cppuhelperdllapi.h"
00024 
00025 
00026 namespace com
00027 {
00028 namespace sun
00029 {
00030 namespace star
00031 {
00032 namespace uno
00033 {
00034 
00035 class OWeakRefListener;
00036 
00040 class CPPUHELPER_DLLPUBLIC WeakReferenceHelper
00041 {
00042 public:
00045     inline WeakReferenceHelper() SAL_THROW(())
00046         : m_pImpl( 0 )
00047         {}
00048 
00053     WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
00059     WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
00060         SAL_THROW(());
00063     ~WeakReferenceHelper() SAL_THROW(());
00064 
00069     WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
00070 
00077     WeakReferenceHelper & SAL_CALL operator = (
00078             const ::com::sun::star::uno::Reference<
00079                 ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
00080 
00086     inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
00087         { return (get() == rObj.get()); }
00088 
00093     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const SAL_THROW(());
00098     inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
00099         { return get(); }
00100 
00105     void SAL_CALL clear() SAL_THROW(());
00106 
00107 protected:
00109     OWeakRefListener * m_pImpl;
00111 };
00112 
00118 template< class interface_type >
00119 class WeakReference : public WeakReferenceHelper
00120 {
00121 public:
00124     inline WeakReference() SAL_THROW(())
00125         : WeakReferenceHelper()
00126         {}
00127 
00132     inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW(())
00133         : WeakReferenceHelper( rRef )
00134         {}
00135 
00144     WeakReference & SAL_CALL operator = (
00145             const ::com::sun::star::uno::Reference< interface_type > & xInt )
00146         SAL_THROW(())
00147         { WeakReferenceHelper::operator=(xInt); return *this; }
00148 
00153     inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
00154         { return Reference< interface_type >::query( get() ); }
00155 };
00156 
00157 }
00158 }
00159 }
00160 }
00161 
00162 #endif
00163 
00164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines