My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _CPPUHELPER_WEAKREF_HXX_
29 #define _CPPUHELPER_WEAKREF_HXX_
30 
31 #include <com/sun/star/uno/XInterface.hpp>
32 #include "cppuhelperdllapi.h"
33 
34 
35 namespace com
36 {
37 namespace sun
38 {
39 namespace star
40 {
41 namespace uno
42 {
43 
44 class OWeakRefListener;
45 
50 {
51 public:
55  : m_pImpl( 0 )
56  {}
57 
62  WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
68  WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
69  SAL_THROW(());
73 
78  WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW(());
79 
86  WeakReferenceHelper & SAL_CALL operator = (
87  const ::com::sun::star::uno::Reference<
88  ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW(());
89 
95  inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW(())
96  { return (get() == rObj.get()); }
97 
107  inline SAL_CALL operator Reference< XInterface > () const SAL_THROW(())
108  { return get(); }
109 
114  void SAL_CALL clear() SAL_THROW(());
115 
116 protected:
118  OWeakRefListener * m_pImpl;
120 };
121 
127 template< class interface_type >
129 {
130 public:
134  : WeakReferenceHelper()
135  {}
136 
142  : WeakReferenceHelper( rRef )
143  {}
144 
153  WeakReference & SAL_CALL operator = (
154  const ::com::sun::star::uno::Reference< interface_type > & xInt )
155  SAL_THROW(())
156  { WeakReferenceHelper::operator=(xInt); return *this; }
157 
162  inline SAL_CALL operator Reference< interface_type > () const SAL_THROW(())
163  { return Reference< interface_type >::query( get() ); }
164 };
165 
166 }
167 }
168 }
169 }
170 
171 #endif
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */