LibreOffice
LibreOffice 25.2 SDK C/C++ API Reference
 
Loading...
Searching...
No Matches
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
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
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
82
83#if defined LIBO_INTERNAL_ONLY
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 = (
115
116#if defined LIBO_INTERNAL_ONLY
123 WeakReferenceHelper & operator = (
125#endif
126
132 bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const
133 { return (get() == rObj.get()); }
134
140
145 SAL_CALL operator Reference< XInterface > () const
146 { return get(); }
147
152 void SAL_CALL clear();
153
154protected:
156 OWeakRefListener * m_pImpl;
158};
159
171template< class interface_type >
173{
174public:
180
188
197 WeakReference & SAL_CALL operator = (
199 { WeakReferenceHelper::operator=(xInt); return *this; }
200
201#if defined LIBO_INTERNAL_ONLY
208 WeakReference & operator = (
210 { WeakReferenceHelper::operator=(xWeak); return *this; }
211#endif
212
217 SAL_CALL operator Reference< interface_type > () const
219};
220
221}
222}
223}
224}
225
226#endif
227
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
#define CPPUHELPER_DLLPUBLIC
Definition cppuhelperdllapi.h:32
Definition types.h:377
Definition types.h:377
Definition types.h:377
Definition typedescription.hxx:43
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition Reference.hxx:376
WeakReferenceHelper(const css::uno::Reference< css::uno::XInterface > &xInt)
Initialize this reference with the hard interface reference xInt.
css::uno::Reference< css::uno::XInterface > get() const
Gets a hard reference to the object.
WeakReferenceHelper(const WeakReferenceHelper &rWeakRef)
Copy ctor.
~WeakReferenceHelper()
Releases this reference.
WeakReferenceHelper & operator=(const WeakReferenceHelper &rWeakRef)
Releases this reference and takes over rWeakRef.
WeakReferenceHelper()
Default ctor.
Definition weakref.hxx:61
void clear()
Releases this reference.
The WeakReference<> holds a weak reference to an object.
Definition weakref.hxx:173
WeakReference()
Default ctor.
Definition weakref.hxx:177
WeakReference(const Reference< interface_type > &rRef)
Copy ctor.
Definition weakref.hxx:185