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() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
67 
68 	// XAggregation
69     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
70         ::com::sun::star::uno::Type const & rType )
71         throw (::com::sun::star::uno::RuntimeException);
72 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
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 
80 	/** @attention
81         XTypeProvider::getImplementationId() has to be implemented separately!
82     */
83 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
84         throw(::com::sun::star::uno::RuntimeException) = 0;
85 	/** @attention
86         XTypeProvider::getTypes() has to be re-implemented!
87     */
88 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
89         throw (::com::sun::star::uno::RuntimeException);
90 
91 	// XComponent
92 	virtual void SAL_CALL dispose()
93 		throw(::com::sun::star::uno::RuntimeException);
94 	virtual void SAL_CALL addEventListener(
95 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
96 		throw(::com::sun::star::uno::RuntimeException);
97 	virtual void SAL_CALL removeEventListener(
98 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
99 		throw(::com::sun::star::uno::RuntimeException);
100 
101 protected:
102 	/** Called in dispose method after the listeners were notified.
103     */
104 	virtual void SAL_CALL disposing();
105 
106 	/** @internal */
107 	OBroadcastHelper	rBHelper;
108 private:
109 	/** @internal */
110     inline OComponentHelper( const OComponentHelper & ) SAL_THROW( () );
111 	/** @internal */
112 	inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW( () );
113 };
114 
115 }
116 
117 #endif
118