LibreOffice Module cppuhelper (master) 1
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23#ifndef INCLUDED_CPPUHELPER_WEAKREF_HXX
24#define INCLUDED_CPPUHELPER_WEAKREF_HXX
25
26#include "sal/config.h"
27
28#include <cstddef>
29
30#include "com/sun/star/uno/Reference.hxx"
31#include "com/sun/star/uno/XInterface.hpp"
33
34
35namespace com
36{
37namespace sun
38{
39namespace star
40{
41namespace uno
42{
43
44class OWeakRefListener;
45class XWeak;
46
57{
58public:
62 : m_pImpl( NULL )
63 {}
64
69 WeakReferenceHelper( const WeakReferenceHelper & rWeakRef );
70
71#if defined LIBO_INTERNAL_ONLY
72 WeakReferenceHelper(WeakReferenceHelper && other) noexcept : m_pImpl(other.m_pImpl)
73 { other.m_pImpl = nullptr; }
74#endif
75
81 WeakReferenceHelper( const css::uno::Reference< css::uno::XInterface > & xInt );
82
83#if defined LIBO_INTERNAL_ONLY
90 WeakReferenceHelper( const css::uno::Reference< css::uno::XWeak > & xWeak );
91#endif
92
96
101 WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef );
102
103#if defined LIBO_INTERNAL_ONLY
104 WeakReferenceHelper & operator =(WeakReferenceHelper && other);
105#endif
106
113 WeakReferenceHelper & SAL_CALL operator = (
114 const css::uno::Reference< css::uno::XInterface > & xInt );
115
116#if defined LIBO_INTERNAL_ONLY
123 WeakReferenceHelper & operator = (
124 const css::uno::Reference< css::uno::XWeak > & xWeak );
125#endif
126
132 bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const
133 { return (get() == rObj.get()); }
134
139 css::uno::Reference< css::uno::XInterface > SAL_CALL get() const;
140
145 SAL_CALL operator Reference< XInterface > () const
146 { return get(); }
147
152 void SAL_CALL clear();
153
154protected:
158};
159
171template< class interface_type >
172class SAL_WARN_UNUSED WeakReference : public WeakReferenceHelper
173{
174public:
177 WeakReference()
178 : WeakReferenceHelper()
179 {}
180
185 WeakReference( const Reference< interface_type > & rRef )
186 : WeakReferenceHelper( rRef )
187 {}
188
197 WeakReference & SAL_CALL operator = (
198 const css::uno::Reference< interface_type > & xInt )
199 { WeakReferenceHelper::operator=(xInt); return *this; }
200
201#if defined LIBO_INTERNAL_ONLY
208 WeakReference & operator = (
209 const css::uno::Reference< css::uno::XWeak > & xWeak )
210 { WeakReferenceHelper::operator=(xWeak); return *this; }
211#endif
212
217 SAL_CALL operator Reference< interface_type > () const
218 { return Reference< interface_type >::query( get() ); }
219};
220
221}
222}
223}
224}
225
226#endif
227
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
The WeakReferenceHelper holds a weak reference to an object.
Definition: weakref.hxx:57
WeakReferenceHelper(const css::uno::Reference< css::uno::XInterface > &xInt)
Initialize this reference with the hard interface reference xInt.
WeakReferenceHelper &SAL_CALL operator=(const WeakReferenceHelper &rWeakRef)
Releases this reference and takes over rWeakRef.
Definition: weak.cxx:485
css::uno::Reference< css::uno::XInterface > SAL_CALL get() const
Gets a hard reference to the object.
Definition: weak.cxx:536
#define CPPUHELPER_DLLPUBLIC
return NULL
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define SAL_WARN_UNUSED