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