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_COMPONENT_HXX_ 24 #define _CPPUHELPER_COMPONENT_HXX_ 25 26 #include <osl/mutex.hxx> 27 #include <cppuhelper/weakagg.hxx> 28 #include <cppuhelper/interfacecontainer.hxx> 29 30 #ifndef _CPPUHELPER_IMPLBASE1_HXX 31 #include <cppuhelper/implbase1.hxx> 32 #endif 33 34 #include <com/sun/star/lang/XComponent.hpp> 35 #include <com/sun/star/lang/XEventListener.hpp> 36 37 #include "cppuhelper/cppuhelperdllapi.h" 38 39 namespace cppu 40 { 41 42 /** Deprecated. Helper for implementing ::com::sun::star::lang::XComponent. 43 Upon disposing objects of this class, sub-classes receive a disposing() call. Objects of 44 this class can be held weakly, i.e. by a ::com::sun::star::uno::WeakReference. Object of 45 this class can be aggregated, i.e. incoming queryInterface() calls are delegated. 46 47 @attention 48 The life-cycle of the passed mutex reference has to be longer than objects of this class. 49 @deprecated 50 */ 51 class CPPUHELPER_DLLPUBLIC OComponentHelper 52 : public ::cppu::OWeakAggObject 53 , public ::com::sun::star::lang::XTypeProvider 54 , public ::com::sun::star::lang::XComponent 55 { 56 public: 57 /** Constructor. 58 59 @param rMutex 60 the mutex used to protect multi-threaded access; 61 lifetime must be longer than the lifetime of this object. 62 */ 63 OComponentHelper( ::osl::Mutex & rMutex ) SAL_THROW( () ); 64 /** Dewstructor. If this object was not disposed previously, object will be disposed manually. 65 */ 66 virtual ~OComponentHelper(); 67 68 // XAggregation 69 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 70 ::com::sun::star::uno::Type const & rType ); 71 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( 72 ::com::sun::star::uno::Type const & rType ); 73 virtual void SAL_CALL acquire() 74 throw (); 75 virtual void SAL_CALL release() 76 throw (); 77 78 /** @attention 79 XTypeProvider::getImplementationId() has to be implemented separately! 80 */ 81 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() = 0; 82 /** @attention 83 XTypeProvider::getTypes() has to be re-implemented! 84 */ 85 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(); 86 87 // XComponent 88 virtual void SAL_CALL dispose(); 89 virtual void SAL_CALL addEventListener( 90 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ); 91 virtual void SAL_CALL removeEventListener( 92 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ); 93 94 protected: 95 /** Called in dispose method after the listeners were notified. 96 */ 97 virtual void SAL_CALL disposing(); 98 99 /** @internal */ 100 OBroadcastHelper rBHelper; 101 private: 102 /** @internal */ 103 inline OComponentHelper( const OComponentHelper & ) SAL_THROW( () ); 104 /** @internal */ 105 inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW( () ); 106 }; 107 108 } 109 110 #endif 111