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 .
21 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
24 #define INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
26 #include "cppuhelper/interfacecontainer.h"
27 #include "com/sun/star/lang/XComponent.hpp"
28 #include "cppuhelper/cppuhelperdllapi.h"
29 #include "cppuhelper/weak.hxx"
30 #include "cppuhelper/weakagg.hxx"
34 namespace osl
{ class Mutex
; }
35 namespace cppu
{ struct class_data
; }
40 /** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and
41 css::lang::XComponent.
43 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase
44 : public ::cppu::OWeakObject
45 , public css::lang::XComponent
48 /** broadcast helper for disposing events
50 ::cppu::OBroadcastHelper rBHelper
;
52 /** this function is called upon disposing the component
54 virtual void SAL_CALL
disposing();
56 /** This is the one and only constructor that is called from derived implementations.
58 @param rMutex mutex to sync upon disposing
60 WeakComponentImplHelperBase( ::osl::Mutex
& rMutex
);
64 virtual ~WeakComponentImplHelperBase() SAL_OVERRIDE
;
66 // these are here to force memory de/allocation to sal lib.
67 static void * SAL_CALL
operator new( size_t nSize
)
68 { return ::rtl_allocateMemory( nSize
); }
69 static void SAL_CALL
operator delete( void * pMem
)
70 { ::rtl_freeMemory( pMem
); }
71 static void * SAL_CALL
operator new( size_t, void * pMem
)
73 static void SAL_CALL
operator delete( void *, void * )
76 virtual css::uno::Any SAL_CALL
queryInterface(
77 css::uno::Type
const & rType
) SAL_OVERRIDE
;
78 virtual void SAL_CALL
acquire()
79 SAL_NOEXCEPT SAL_OVERRIDE
;
80 virtual void SAL_CALL
release()
81 SAL_NOEXCEPT SAL_OVERRIDE
;
82 virtual void SAL_CALL
dispose() SAL_OVERRIDE
;
83 virtual void SAL_CALL
addEventListener(
84 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
85 virtual void SAL_CALL
removeEventListener(
86 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
89 /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and
90 css::lang::XComponent.
92 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakAggComponentImplHelperBase
93 : public ::cppu::OWeakAggObject
94 , public css::lang::XComponent
97 ::cppu::OBroadcastHelper rBHelper
;
99 /** Is called upon disposing the component.
101 virtual void SAL_CALL
disposing();
103 WeakAggComponentImplHelperBase( ::osl::Mutex
& rMutex
);
105 virtual ~WeakAggComponentImplHelperBase() SAL_OVERRIDE
;
107 // these are here to force memory de/allocation to sal lib.
108 static void * SAL_CALL
operator new( size_t nSize
)
109 { return ::rtl_allocateMemory( nSize
); }
110 static void SAL_CALL
operator delete( void * pMem
)
111 { ::rtl_freeMemory( pMem
); }
112 static void * SAL_CALL
operator new( size_t, void * pMem
)
114 static void SAL_CALL
operator delete( void *, void * )
117 virtual css::uno::Any SAL_CALL
queryInterface(
118 css::uno::Type
const & rType
) SAL_OVERRIDE
;
119 virtual css::uno::Any SAL_CALL
queryAggregation(
120 css::uno::Type
const & rType
) SAL_OVERRIDE
;
121 virtual void SAL_CALL
acquire()
122 SAL_NOEXCEPT SAL_OVERRIDE
;
123 virtual void SAL_CALL
release()
124 SAL_NOEXCEPT SAL_OVERRIDE
;
125 virtual void SAL_CALL
dispose() SAL_OVERRIDE
;
126 virtual void SAL_CALL
addEventListener(
127 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
128 virtual void SAL_CALL
removeEventListener(
129 css::uno::Reference
< css::lang::XEventListener
> const & xListener
) SAL_OVERRIDE
;
132 /** WeakComponentImplHelper
134 CPPUHELPER_DLLPUBLIC
css::uno::Any SAL_CALL
WeakComponentImplHelper_query(
135 css::uno::Type
const & rType
,
138 ::cppu::WeakComponentImplHelperBase
* pBase
);
139 /** WeakComponentImplHelper
141 CPPUHELPER_DLLPUBLIC
css::uno::Sequence
< css::uno::Type
> SAL_CALL
WeakComponentImplHelper_getTypes(
144 /** WeakAggComponentImplHelper
146 CPPUHELPER_DLLPUBLIC
css::uno::Any SAL_CALL
WeakAggComponentImplHelper_queryAgg(
147 css::uno::Type
const & rType
,
150 ::cppu::WeakAggComponentImplHelperBase
* pBase
);
151 /** WeakAggComponentImplHelper
153 CPPUHELPER_DLLPUBLIC
css::uno::Sequence
< css::uno::Type
> SAL_CALL
WeakAggComponentImplHelper_getTypes(
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */