Branch data Line data Source code
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_COMPBASE_EX_HXX_
29 : : #define _CPPUHELPER_COMPBASE_EX_HXX_
30 : :
31 : : #include <osl/mutex.hxx>
32 : : #include <cppuhelper/implbase_ex.hxx>
33 : : #include <cppuhelper/interfacecontainer.hxx>
34 : : #include <com/sun/star/lang/XComponent.hpp>
35 : : #include "cppuhelperdllapi.h"
36 : :
37 : : /// @cond INTERNAL
38 : :
39 : : namespace cppu
40 : : {
41 : :
42 : : /** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and
43 : : ::com::sun::star::lang::XComponent.
44 : : */
45 : : class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase
46 : : : public ::cppu::OWeakObject
47 : : , public ::com::sun::star::lang::XComponent
48 : : {
49 : : protected:
50 : : /** broadcast helper for disposing events
51 : : */
52 : : ::cppu::OBroadcastHelper rBHelper;
53 : :
54 : : /** this function is called upon disposing the component
55 : : */
56 : : virtual void SAL_CALL disposing();
57 : :
58 : : /** This is the one and only constructor that is called from derived implementations.
59 : :
60 : : @param rMutex mutex to sync upon disposing
61 : : */
62 : : WeakComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW(());
63 : : public:
64 : : /** Destructor
65 : : */
66 : : virtual ~WeakComponentImplHelperBase() SAL_THROW(());
67 : :
68 : : // these are here to force memory de/allocation to sal lib.
69 : 839484 : inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
70 : 839484 : { return ::rtl_allocateMemory( nSize ); }
71 : 835154 : inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
72 : 835154 : { ::rtl_freeMemory( pMem ); }
73 : : inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
74 : : { return pMem; }
75 : : inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
76 : : {}
77 : :
78 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
79 : : ::com::sun::star::uno::Type const & rType )
80 : : throw (::com::sun::star::uno::RuntimeException);
81 : : virtual void SAL_CALL acquire()
82 : : throw ();
83 : : virtual void SAL_CALL release()
84 : : throw ();
85 : : virtual void SAL_CALL dispose()
86 : : throw (::com::sun::star::uno::RuntimeException);
87 : : virtual void SAL_CALL addEventListener(
88 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
89 : : throw (::com::sun::star::uno::RuntimeException);
90 : : virtual void SAL_CALL removeEventListener(
91 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
92 : : throw (::com::sun::star::uno::RuntimeException);
93 : : };
94 : :
95 : : /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and
96 : : ::com::sun::star::lang::XComponent.
97 : : */
98 : : class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakAggComponentImplHelperBase
99 : : : public ::cppu::OWeakAggObject
100 : : , public ::com::sun::star::lang::XComponent
101 : : {
102 : : protected:
103 : : ::cppu::OBroadcastHelper rBHelper;
104 : :
105 : : /** Is called upon disposing the component.
106 : : */
107 : : virtual void SAL_CALL disposing();
108 : :
109 : : WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW(());
110 : : public:
111 : : virtual ~WeakAggComponentImplHelperBase() SAL_THROW(());
112 : :
113 : : // these are here to force memory de/allocation to sal lib.
114 : 6447 : inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
115 : 6447 : { return ::rtl_allocateMemory( nSize ); }
116 : 6139 : inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
117 : 6139 : { ::rtl_freeMemory( pMem ); }
118 : : inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
119 : : { return pMem; }
120 : : inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
121 : : {}
122 : :
123 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
124 : : ::com::sun::star::uno::Type const & rType )
125 : : throw (::com::sun::star::uno::RuntimeException);
126 : : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
127 : : ::com::sun::star::uno::Type const & rType )
128 : : throw (::com::sun::star::uno::RuntimeException);
129 : : virtual void SAL_CALL acquire()
130 : : throw ();
131 : : virtual void SAL_CALL release()
132 : : throw ();
133 : : virtual void SAL_CALL dispose()
134 : : throw (::com::sun::star::uno::RuntimeException);
135 : : virtual void SAL_CALL addEventListener(
136 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
137 : : throw (::com::sun::star::uno::RuntimeException);
138 : : virtual void SAL_CALL removeEventListener(
139 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener )
140 : : throw (::com::sun::star::uno::RuntimeException);
141 : : };
142 : :
143 : : /** WeakComponentImplHelper
144 : : */
145 : : CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query(
146 : : ::com::sun::star::uno::Type const & rType,
147 : : class_data * cd,
148 : : void * that,
149 : : ::cppu::WeakComponentImplHelperBase * pBase )
150 : : SAL_THROW( (::com::sun::star::uno::RuntimeException) );
151 : : /** WeakComponentImplHelper
152 : : */
153 : : CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes(
154 : : class_data * cd )
155 : : SAL_THROW( (::com::sun::star::uno::RuntimeException) );
156 : :
157 : : /** WeakAggComponentImplHelper
158 : : */
159 : : CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg(
160 : : ::com::sun::star::uno::Type const & rType,
161 : : class_data * cd,
162 : : void * that,
163 : : ::cppu::WeakAggComponentImplHelperBase * pBase )
164 : : SAL_THROW( (::com::sun::star::uno::RuntimeException) );
165 : : /** WeakAggComponentImplHelper
166 : : */
167 : : CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes(
168 : : class_data * cd )
169 : : SAL_THROW( (::com::sun::star::uno::RuntimeException) );
170 : :
171 : : }
172 : :
173 : : /// @endcond
174 : :
175 : : #endif
176 : :
177 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|