My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
weak.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_WEAK_HXX_
29 #define _CPPUHELPER_WEAK_HXX_
30 
31 #include <osl/interlck.h>
32 #include <rtl/alloc.h>
33 #include <cppuhelper/weakref.hxx>
35 #include <com/sun/star/uno/XWeak.hpp>
36 #include "cppuhelperdllapi.h"
37 
38 
39 namespace cppu
40 {
41 
42 class OWeakConnectionPoint;
43 
52 class CPPUHELPER_DLLPUBLIC OWeakObject : public ::com::sun::star::uno::XWeak
53 {
54  friend class OWeakConnectionPoint;
55 
56 protected:
63  virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
64 
69  void disposeWeakConnectionPoint();
70 
76  oslInterlockedCount m_refCount;
77 
79 
82  OWeakConnectionPoint * m_pWeakConnectionPoint;
83 
86  void * m_pReserved;
87 
89 
90 public:
92  // these are here to force memory de/allocation to sal lib.
93  inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
94  { return ::rtl_allocateMemory( nSize ); }
95  inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
96  { ::rtl_freeMemory( pMem ); }
97  inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
98  { return pMem; }
99  inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
100  {}
102 
103 #ifdef _MSC_VER
104 
107  OWeakObject() SAL_THROW(());
108 #else
109 
111  inline OWeakObject() SAL_THROW(())
112  : m_refCount( 0 )
113  , m_pWeakConnectionPoint( 0 )
114  {}
115 #endif
116 
120  inline OWeakObject( const OWeakObject & rObj ) SAL_THROW(())
121  : com::sun::star::uno::XWeak()
122  , m_refCount( 0 )
123  , m_pWeakConnectionPoint( 0 )
124  {
125  (void) rObj;
126  }
131  inline OWeakObject & SAL_CALL operator = ( const OWeakObject &)
132  SAL_THROW(())
133  { return *this; }
134 
141  virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
142  const ::com::sun::star::uno::Type & rType )
143  throw (::com::sun::star::uno::RuntimeException);
146  virtual void SAL_CALL acquire()
147  throw ();
150  virtual void SAL_CALL release()
151  throw ();
152 
157  virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter()
158  throw (::com::sun::star::uno::RuntimeException);
159 
164  inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () SAL_THROW(())
165  { return this; }
166 };
167 
168 }
169 
170 #endif
171 
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */