AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #ifndef INCLUDED_CPPUHELPER_WEAKREF_HXX
4 #define INCLUDED_CPPUHELPER_WEAKREF_HXX
5 
6 #include "sal/config.h"
7 
8 #include <cstddef>
9 
11 #include "com/sun/star/uno/XInterface.hpp"
13 
14 
15 namespace com
16 {
17 namespace sun
18 {
19 namespace star
20 {
21 namespace uno
22 {
23 
24 class OWeakRefListener;
25 class XWeak;
26 
37 {
38 public:
42  : m_pImpl( NULL )
43  {}
44 
49  WeakReferenceHelper( const WeakReferenceHelper & rWeakRef );
50 
51 #if defined LIBO_INTERNAL_ONLY
52  WeakReferenceHelper(WeakReferenceHelper && other) noexcept : m_pImpl(other.m_pImpl)
53  { other.m_pImpl = nullptr; }
54 #endif
55 
61  WeakReferenceHelper( const css::uno::Reference< css::uno::XInterface > & xInt );
62 
63 #if defined LIBO_INTERNAL_ONLY
64 
70  WeakReferenceHelper( const css::uno::Reference< css::uno::XWeak > & xWeak );
71 #endif
72 
75  ~WeakReferenceHelper();
76 
81  WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef );
82 
83 #if defined LIBO_INTERNAL_ONLY
84  WeakReferenceHelper & operator =(WeakReferenceHelper && other);
85 #endif
86 
93  WeakReferenceHelper & SAL_CALL operator = (
94  const css::uno::Reference< css::uno::XInterface > & xInt );
95 
96 #if defined LIBO_INTERNAL_ONLY
97 
103  WeakReferenceHelper & operator = (
104  const css::uno::Reference< css::uno::XWeak > & xWeak );
105 #endif
106 
112  bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const
113  { return (get() == rObj.get()); }
114 
119  css::uno::Reference< css::uno::XInterface > SAL_CALL get() const;
120 
125  SAL_CALL operator Reference< XInterface > () const
126  { return get(); }
127 
132  void SAL_CALL clear();
133 
134 protected:
136  OWeakRefListener * m_pImpl;
138 };
139 
151 template< class interface_type >
153 {
154 public:
159  {}
160 
166  : WeakReferenceHelper( rRef )
167  {}
168 
177  WeakReference & SAL_CALL operator = (
178  const css::uno::Reference< interface_type > & xInt )
179  { WeakReferenceHelper::operator=(xInt); return *this; }
180 
181 #if defined LIBO_INTERNAL_ONLY
182 
188  WeakReference & operator = (
189  const css::uno::Reference< css::uno::XWeak > & xWeak )
190  { WeakReferenceHelper::operator=(xWeak); return *this; }
191 #endif
192 
197  SAL_CALL operator Reference< interface_type > () const
198  { return Reference< interface_type >::query( get() ); }
199 };
200 
201 }
202 }
203 }
204 }
205 
206 #endif
207 
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The WeakReferenceHelper holds a weak reference to an object.
Definition: weakref.hxx:36
WeakReference(const Reference< interface_type > &rRef)
Copy ctor.
Definition: weakref.hxx:165
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:353
WeakReferenceHelper & operator=(const WeakReferenceHelper &rWeakRef)
Releases this reference and takes over rWeakRef.
The WeakReference&lt;&gt; holds a weak reference to an object.
Definition: weakref.hxx:152
WeakReference()
Default ctor.
Definition: weakref.hxx:157
bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:642
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:12
css::uno::Reference< css::uno::XInterface > get() const
Gets a hard reference to the object.
WeakReferenceHelper()
Default ctor.
Definition: weakref.hxx:41
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:23