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 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 SAL_NO_VTABLE WeakComponentImplHelperBase 40 : public ::cppu::OWeakObject 41 , public ::com::sun::star::lang::XComponent 42 { 43 protected: 44 /** boradcast 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 throw (::com::sun::star::uno::RuntimeException); 75 virtual void SAL_CALL acquire() 76 throw (); 77 virtual void SAL_CALL release() 78 throw (); 79 virtual void SAL_CALL dispose() 80 throw (::com::sun::star::uno::RuntimeException); 81 virtual void SAL_CALL addEventListener( 82 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 83 throw (::com::sun::star::uno::RuntimeException); 84 virtual void SAL_CALL removeEventListener( 85 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 86 throw (::com::sun::star::uno::RuntimeException); 87 }; 88 89 /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and 90 ::com::sun::star::lang::XComponent. 91 @internal 92 */ 93 class SAL_NO_VTABLE WeakAggComponentImplHelperBase 94 : public ::cppu::OWeakAggObject 95 , public ::com::sun::star::lang::XComponent 96 { 97 protected: 98 ::cppu::OBroadcastHelper rBHelper; 99 100 /** Is called upon disposing the component. 101 */ 102 virtual void SAL_CALL disposing(); 103 104 WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); 105 public: 106 virtual ~WeakAggComponentImplHelperBase() SAL_THROW( () ); 107 108 // these are here to force memory de/allocation to sal lib. operator new(size_t nSize)109 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 110 { return ::rtl_allocateMemory( nSize ); } operator delete(void * pMem)111 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 112 { ::rtl_freeMemory( pMem ); } operator new(size_t,void * pMem)113 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) 114 { return pMem; } operator delete(void *,void *)115 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) 116 {} 117 118 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 119 ::com::sun::star::uno::Type const & rType ) 120 throw (::com::sun::star::uno::RuntimeException); 121 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( 122 ::com::sun::star::uno::Type const & rType ) 123 throw (::com::sun::star::uno::RuntimeException); 124 virtual void SAL_CALL acquire() 125 throw (); 126 virtual void SAL_CALL release() 127 throw (); 128 virtual void SAL_CALL dispose() 129 throw (::com::sun::star::uno::RuntimeException); 130 virtual void SAL_CALL addEventListener( 131 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 132 throw (::com::sun::star::uno::RuntimeException); 133 virtual void SAL_CALL removeEventListener( 134 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 135 throw (::com::sun::star::uno::RuntimeException); 136 }; 137 138 /** WeakComponentImplHelper 139 @internal 140 */ 141 ::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query( 142 ::com::sun::star::uno::Type const & rType, 143 class_data * cd, 144 void * that, 145 ::cppu::WeakComponentImplHelperBase * pBase ) 146 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 147 /** WeakComponentImplHelper 148 @internal 149 */ 150 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes( 151 class_data * cd ) 152 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 153 154 /** WeakAggComponentImplHelper 155 @internal 156 */ 157 ::com::sun::star::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg( 158 ::com::sun::star::uno::Type const & rType, 159 class_data * cd, 160 void * that, 161 ::cppu::WeakAggComponentImplHelperBase * pBase ) 162 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 163 /** WeakAggComponentImplHelper 164 @internal 165 */ 166 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes( 167 class_data * cd ) 168 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 169 170 } 171 172 #endif 173