1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CPPUHELPER_COMPBASE_EX_HXX_ 24 #define _CPPUHELPER_COMPBASE_EX_HXX_ 25 26 #include <osl/mutex.hxx> 27 #include <cppuhelper/implbase_ex.hxx> 28 #include <cppuhelper/interfacecontainer.hxx> 29 #include <com/sun/star/lang/XComponent.hpp> 30 #include "cppuhelper/cppuhelperdllapi.h" 31 32 namespace cppu 33 { 34 35 /** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and 36 ::com::sun::star::lang::XComponent. 37 @internal 38 */ 39 class CPPUHELPER_DLLPUBLIC SAL_NO_VTABLE WeakComponentImplHelperBase 40 : public ::cppu::OWeakObject 41 , public ::com::sun::star::lang::XComponent 42 { 43 protected: 44 /** broadcast helper for disposing events 45 */ 46 ::cppu::OBroadcastHelper rBHelper; 47 48 /** this function is called upon disposing the component 49 */ 50 virtual void SAL_CALL disposing(); 51 52 /** This is the one and only constructor that is called from derived implementations. 53 54 @param rMutex mutex to sync upon disposing 55 */ 56 WeakComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); 57 public: 58 /** Destructor 59 */ 60 virtual ~WeakComponentImplHelperBase() SAL_THROW( () ); 61 62 // these are here to force memory de/allocation to sal lib. operator new(size_t nSize)63 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 64 { return ::rtl_allocateMemory( nSize ); } operator delete(void * pMem)65 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 66 { ::rtl_freeMemory( pMem ); } operator new(size_t,void * pMem)67 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) 68 { return pMem; } operator delete(void *,void *)69 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) 70 {} 71 72 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 73 ::com::sun::star::uno::Type const & rType ); 74 virtual void SAL_CALL acquire() 75 throw (); 76 virtual void SAL_CALL release() 77 throw (); 78 virtual void SAL_CALL dispose(); 79 virtual void SAL_CALL addEventListener( 80 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ); 81 virtual void SAL_CALL removeEventListener( 82 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ); 83 }; 84 85 /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and 86 ::com::sun::star::lang::XComponent. 87 @internal 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 ) SAL_THROW( () ); 101 public: 102 virtual ~WeakAggComponentImplHelperBase() SAL_THROW( () ); 103 104 // these are here to force memory de/allocation to sal lib. operator new(size_t nSize)105 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 106 { return ::rtl_allocateMemory( nSize ); } operator delete(void * pMem)107 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 108 { ::rtl_freeMemory( pMem ); } operator new(size_t,void * pMem)109 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) 110 { return pMem; } operator delete(void *,void *)111 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) 112 {} 113 114 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 115 ::com::sun::star::uno::Type const & rType ); 116 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( 117 ::com::sun::star::uno::Type const & rType ); 118 virtual void SAL_CALL acquire() 119 throw (); 120 virtual void SAL_CALL release() 121 throw (); 122 virtual void SAL_CALL dispose(); 123 virtual void SAL_CALL addEventListener( 124 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ); 125 virtual void SAL_CALL removeEventListener( 126 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ); 127 }; 128 129 /** WeakComponentImplHelper 130 @internal 131 */ 132 CPPUHELPER_DLLPUBLIC 133 ::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query( 134 ::com::sun::star::uno::Type const & rType, 135 class_data * cd, 136 void * that, 137 ::cppu::WeakComponentImplHelperBase * pBase ); 138 /** WeakComponentImplHelper 139 @internal 140 */ 141 CPPUHELPER_DLLPUBLIC 142 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes( 143 class_data * cd ); 144 145 /** WeakAggComponentImplHelper 146 @internal 147 */ 148 CPPUHELPER_DLLPUBLIC 149 ::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 @internal 156 */ 157 CPPUHELPER_DLLPUBLIC 158 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes( 159 class_data * cd ); 160 161 } 162 163 #endif 164