LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
weakref.hxx
Go to the documentation of this file.
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 INCLUDED_CPPUHELPER_WEAKREF_HXX
20 #define INCLUDED_CPPUHELPER_WEAKREF_HXX
21 
22 #include <com/sun/star/uno/XInterface.hpp>
24 
25 
26 namespace com
27 {
28 namespace sun
29 {
30 namespace star
31 {
32 namespace uno
33 {
34 
35 class OWeakRefListener;
36 
41 {
42 public:
46  : m_pImpl( 0 )
47  {}
48 
53  WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
59  WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
60  SAL_THROW(());
64 
69  WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
70 
77  WeakReferenceHelper & SAL_CALL operator = (
78  const ::com::sun::star::uno::Reference<
79  ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
80 
86  inline bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
87  { return (get() == rObj.get()); }
88 
98  inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
99  { return get(); }
100 
105  void SAL_CALL clear() SAL_THROW(());
106 
107 protected:
109  OWeakRefListener * m_pImpl;
111 };
112 
118 template< class interface_type >
120 {
121 public:
125  : WeakReferenceHelper()
126  {}
127 
133  : WeakReferenceHelper( rRef )
134  {}
135 
144  WeakReference & SAL_CALL operator = (
145  const ::com::sun::star::uno::Reference< interface_type > & xInt )
146  SAL_THROW(())
147  { WeakReferenceHelper::operator=(xInt); return *this; }
148 
153  inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
154  { return Reference< interface_type >::query( get() ); }
155 };
156 
157 }
158 }
159 }
160 }
161 
162 #endif
163 
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef) SAL_THROW((RuntimeException))
Queries given interface reference for type interface_type.
Definition: Reference.hxx:343
The WeakReferenceHelper holds a weak reference to an object.
Definition: weakref.hxx:40
The WeakReference<> holds a weak reference to an object.
Definition: weakref.hxx:119
WeakReferenceHelper & operator=(const WeakReferenceHelper &rWeakRef) SAL_THROW(())
Releases this reference and takes over rWeakRef.
WeakReference() SAL_THROW(())
Default ctor.
Definition: weakref.hxx:124
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
WeakReference(const Reference< interface_type > &rRef) SAL_THROW(())
Copy ctor.
Definition: weakref.hxx:132
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
Definition: types.h:391
WeakReferenceHelper() SAL_THROW(())
Default ctor.
Definition: weakref.hxx:45