LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
compbase_ex.hxx
Go to the documentation of this file.
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 
20 /*
21  * This file is part of LibreOffice published API.
22  */
23 #ifndef INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
24 #define INCLUDED_CPPUHELPER_COMPBASE_EX_HXX
25 
27 #include "com/sun/star/lang/XComponent.hpp"
29 #include "cppuhelper/weak.hxx"
30 #include "cppuhelper/weakagg.hxx"
31 
33 
34 namespace osl { class Mutex; }
35 namespace cppu { struct class_data; }
36 
37 namespace cppu
38 {
39 
43 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase
44  : public ::cppu::OWeakObject
45  , public css::lang::XComponent
46 {
47 protected:
50  ::cppu::OBroadcastHelper rBHelper;
51 
54  virtual void SAL_CALL disposing();
55 
60  WeakComponentImplHelperBase( ::osl::Mutex & rMutex );
61 public:
64  virtual ~WeakComponentImplHelperBase() SAL_OVERRIDE;
65 
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 )
72  { return pMem; }
73  static void SAL_CALL operator delete( void *, void * )
74  {}
75 
76  virtual css::uno::Any SAL_CALL queryInterface(
77  css::uno::Type const & rType ) SAL_OVERRIDE;
78  virtual void SAL_CALL acquire()
80  virtual void SAL_CALL release()
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;
87 };
88 
92 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakAggComponentImplHelperBase
93  : public ::cppu::OWeakAggObject
94  , public css::lang::XComponent
95 {
96 protected:
97  ::cppu::OBroadcastHelper rBHelper;
98 
101  virtual void SAL_CALL disposing();
102 
103  WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex );
104 public:
105  virtual ~WeakAggComponentImplHelperBase() SAL_OVERRIDE;
106 
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 )
113  { return pMem; }
114  static void SAL_CALL operator delete( void *, void * )
115  {}
116 
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()
123  virtual void SAL_CALL release()
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;
130 };
131 
134 CPPUHELPER_DLLPUBLIC css::uno::Any SAL_CALL WeakComponentImplHelper_query(
135  css::uno::Type const & rType,
136  class_data * cd,
137  void * that,
138  ::cppu::WeakComponentImplHelperBase * pBase );
141 CPPUHELPER_DLLPUBLIC css::uno::Sequence< css::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes(
142  class_data * cd );
143 
146 CPPUHELPER_DLLPUBLIC css::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg(
147  css::uno::Type const & rType,
148  class_data * cd,
149  void * that,
150  ::cppu::WeakAggComponentImplHelperBase * pBase );
153 CPPUHELPER_DLLPUBLIC css::uno::Sequence< css::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes(
154  class_data * cd );
155 
156 }
157 
159 
160 #endif
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Any queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:43
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:391
#define SAL_NO_VTABLE
Use this for pure virtual classes, e.g.
Definition: types.h:294
Definition: condition.hxx:31
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
A mutual exclusion synchronization object.
Definition: mutex.hxx:35
#define SAL_NOEXCEPT
Macro for C++11 "noexcept" vs.
Definition: types.h:416
Definition: Enterable.hxx:30
Base class to implement a UNO object supporting weak references, i.e.
Definition: weak.hxx:47
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:32
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Definition: types.h:359
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:439