1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
20 #define INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
22 #include "cppuhelper/interfacecontainer.h"
23 #include "com/sun/star/lang/XComponent.hpp"
24 #include "cppuhelper/cppuhelperdllapi.h"
25 #include "cppuhelper/weak.hxx"
26 #include "cppuhelper/weakagg.hxx"
30 namespace osl
{ class Mutex
; }
31 namespace cppu
{ struct class_data
; }
36 /** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and
37 css::lang::XComponent.
39 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase
40 : public ::cppu::OWeakObject
41 , public css::lang::XComponent
44 /** broadcast helper for disposing events
46 ::cppu::OBroadcastHelper rBHelper
;
48 /** this function is called upon disposing the component
50 virtual void SAL_CALL
disposing();
52 /** This is the one and only constructor that is called from derived implementations.
54 @param rMutex mutex to sync upon disposing
56 WeakComponentImplHelperBase( ::osl::Mutex
& rMutex
);
60 virtual ~WeakComponentImplHelperBase() SAL_OVERRIDE
;
62 // these are here to force memory de/allocation to sal lib.
63 static void * SAL_CALL
operator new( size_t nSize
)
64 { return ::rtl_allocateMemory( nSize
); }
65 static void SAL_CALL
operator delete( void * pMem
)
66 { ::rtl_freeMemory( pMem
); }
67 static void * SAL_CALL
operator new( size_t, void * pMem
)
69 static void SAL_CALL
operator delete( void *, void * )
72 virtual css::uno::Any SAL_CALL
queryInterface(
73 css::uno::Type
const & rType
) SAL_OVERRIDE
;
74 virtual void SAL_CALL
acquire()
75 throw () SAL_OVERRIDE
;
76 virtual void SAL_CALL
release()
77 throw () SAL_OVERRIDE
;
78 virtual void SAL_CALL
dispose() SAL_OVERRIDE
;
79 virtual void SAL_CALL
addEventListener(
80 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
81 virtual void SAL_CALL
removeEventListener(
82 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
85 /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and
86 css::lang::XComponent.
88 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakAggComponentImplHelperBase
89 : public ::cppu::OWeakAggObject
90 , public css::lang::XComponent
93 ::cppu::OBroadcastHelper rBHelper
;
95 /** Is called upon disposing the component.
97 virtual void SAL_CALL
disposing();
99 WeakAggComponentImplHelperBase( ::osl::Mutex
& rMutex
);
101 virtual ~WeakAggComponentImplHelperBase() SAL_OVERRIDE
;
103 // these are here to force memory de/allocation to sal lib.
104 static void * SAL_CALL
operator new( size_t nSize
)
105 { return ::rtl_allocateMemory( nSize
); }
106 static void SAL_CALL
operator delete( void * pMem
)
107 { ::rtl_freeMemory( pMem
); }
108 static void * SAL_CALL
operator new( size_t, void * pMem
)
110 static void SAL_CALL
operator delete( void *, void * )
113 virtual css::uno::Any SAL_CALL
queryInterface(
114 css::uno::Type
const & rType
) SAL_OVERRIDE
;
115 virtual css::uno::Any SAL_CALL
queryAggregation(
116 css::uno::Type
const & rType
) SAL_OVERRIDE
;
117 virtual void SAL_CALL
acquire()
118 throw () SAL_OVERRIDE
;
119 virtual void SAL_CALL
release()
120 throw () SAL_OVERRIDE
;
121 virtual void SAL_CALL
dispose() SAL_OVERRIDE
;
122 virtual void SAL_CALL
addEventListener(
123 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
124 virtual void SAL_CALL
removeEventListener(
125 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
128 /** WeakComponentImplHelper
130 CPPUHELPER_DLLPUBLIC
css::uno::Any SAL_CALL
WeakComponentImplHelper_query(
131 css::uno::Type
const & rType
,
134 ::cppu::WeakComponentImplHelperBase
* pBase
);
135 /** WeakComponentImplHelper
137 CPPUHELPER_DLLPUBLIC
css::uno::Sequence
< css::uno::Type
> SAL_CALL
WeakComponentImplHelper_getTypes(
140 /** WeakAggComponentImplHelper
142 CPPUHELPER_DLLPUBLIC
css::uno::Any SAL_CALL
WeakAggComponentImplHelper_queryAgg(
143 css::uno::Type
const & rType
,
146 ::cppu::WeakAggComponentImplHelperBase
* pBase
);
147 /** WeakAggComponentImplHelper
149 CPPUHELPER_DLLPUBLIC
css::uno::Sequence
< css::uno::Type
> SAL_CALL
WeakAggComponentImplHelper_getTypes(
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */