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