LibreOffice: cppuhelper/weakref.hxx Source File

LibreOffice LibreOffice 5.2 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 <sal/config.h>
23
24 #include <cstddef>
25
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <cppuhelper/cppuhelperdllapi.h>
29
30
31 namespace com
32 {
33 namespace sun
34 {
35 namespace star
36 {
37 namespace uno
38 {
39
40 class OWeakRefListener;
41
51 class CPPUHELPER_DLLPUBLIC WeakReferenceHelper
52 {
53 public:
56 inline WeakReferenceHelper()
57 : m_pImpl( NULL )
58 {}
59
64 WeakReferenceHelper( const WeakReferenceHelper & rWeakRef );
65
71 WeakReferenceHelper( const css::uno::Reference< css::uno::XInterface > & xInt );
72
75 ~WeakReferenceHelper();
76
81 WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef );
82
89 WeakReferenceHelper & SAL_CALL operator = (
90 const css::uno::Reference< css::uno::XInterface > & xInt );
91
97 inline bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const
98 { return (get() == rObj.get()); }
99
104 css::uno::Reference< css::uno::XInterface > SAL_CALL get() const;
105
110 inline SAL_CALL operator Reference< XInterface > () const
111 { return get(); }
112
117 void SAL_CALL clear();
118
119 protected:
121 OWeakRefListener * m_pImpl;
123 };
124
136 template< class interface_type >
137 class SAL_WARN_UNUSED WeakReference : public WeakReferenceHelper
138 {
139 public:
142 inline WeakReference()
143 : WeakReferenceHelper()
144 {}
145
150 inline WeakReference( const Reference< interface_type > & rRef )
151 : WeakReferenceHelper( rRef )
152 {}
153
162 WeakReference & SAL_CALL operator = (
163 const css::uno::Reference< interface_type > & xInt )
164 { WeakReferenceHelper::operator=(xInt); return *this; }
165
170 inline SAL_CALL operator Reference< interface_type > () const
171 { return Reference< interface_type >::query( get() ); }
172 };
173
174 }
175 }
176 }
177 }
178
179 #endif
180
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
com::sun::star::uno::WeakReference::WeakReference
WeakReference(const Reference< interface_type > &rRef)
Copy ctor.
Definition: weakref.hxx:150
com::sun::star::uno::WeakReference
The WeakReference<> holds a weak reference to an object.
Definition: weakref.hxx:137
CPPUHELPER_DLLPUBLIC
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
com::sun::star::uno::WeakReference::WeakReference
WeakReference()
Default ctor.
Definition: weakref.hxx:142
com
Definition: types.h:391
com::sun::star::uno::WeakReferenceHelper::operator=
WeakReferenceHelper & operator=(const WeakReferenceHelper &rWeakRef)
Releases this reference and takes over rWeakRef.
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
Reference.hxx
com::sun::star::uno::Reference
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:39
com::sun::star::uno::Reference::query
static SAL_WARN_UNUSED_RESULT Reference< interface_type > query(const BaseReference &rRef)
Queries given interface reference for type interface_type.
Definition: Reference.hxx:367
com::sun::star::uno::operator==
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:562
config.h
cppuhelperdllapi.h
com::sun::star::uno::WeakReferenceHelper::WeakReferenceHelper
WeakReferenceHelper()
Default ctor.
Definition: weakref.hxx:56
com::sun::star::uno::WeakReferenceHelper
The WeakReferenceHelper holds a weak reference to an object.
Definition: weakref.hxx:51
com::sun::star::uno::WeakReferenceHelper::get
css::uno::Reference< css::uno::XInterface > get() const
Gets a hard reference to the object.