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