diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-03-15 14:47:29 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-03-15 14:47:29 +0000 |
commit | 3c0774aba77edb5903b1c489a8b6e02a67ff667e (patch) | |
tree | fc343816045279fb695d62d188c7c67a57bf81bc /cppuhelper/inc/cppuhelper/compbase2.hxx | |
parent | 0528321f6afab45ca32154c7049dc4392d025c6a (diff) |
impl helper macros expanded and checked in
Diffstat (limited to 'cppuhelper/inc/cppuhelper/compbase2.hxx')
-rw-r--r-- | cppuhelper/inc/cppuhelper/compbase2.hxx | 148 |
1 files changed, 146 insertions, 2 deletions
diff --git a/cppuhelper/inc/cppuhelper/compbase2.hxx b/cppuhelper/inc/cppuhelper/compbase2.hxx index ff5d0d7af786..bd3f22dd8f09 100644 --- a/cppuhelper/inc/cppuhelper/compbase2.hxx +++ b/cppuhelper/inc/cppuhelper/compbase2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: compbase2.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $ + * last change: $Author: dbo $ $Date: 2001-03-15 15:47:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,150 @@ #include <cppuhelper/compbase.hxx> #endif +/* __DEF_COMPIMPLHELPER( 2 ) +*/ + + +namespace cppu +{ + template< class Ifc1, class Ifc2 > + class WeakComponentImplHelper2 + : public ::cppu::OWeakObject + , public ::com::sun::star::lang::XComponent + , public ImplHelperBase2< Ifc1, Ifc2 > + { + static ClassData2 s_aCD; + protected: + ::cppu::OBroadcastHelper rBHelper; + virtual void SAL_CALL disposing() + {} + public: + WeakComponentImplHelper2( ::osl::Mutex & rMutex ) SAL_THROW( () ) + : rBHelper( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase2< Ifc1, Ifc2 > *)this ) ); + if (aRet.hasValue()) + return aRet; + if (rType == ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > *)0 )) + { + void * p = static_cast< ::com::sun::star::lang::XComponent * >( this ); + return ::com::sun::star::uno::Any( &p, rType ); + } + return OWeakObject::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { + if (1 == m_refCount && !rBHelper.bDisposed) + { + dispose(); + } + OWeakObject::release(); + } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return getClassData( s_aCD ).getTypes(); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return getClassData( s_aCD ).getImplementationId(); } + virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (!rBHelper.bDisposed && !rBHelper.bInDispose) + { + rBHelper.bInDispose = sal_True; + aGuard.clear(); + ::com::sun::star::lang::EventObject aEvt( static_cast< ::cppu::OWeakObject * >( this ) ); + rBHelper.aLC.disposeAndClear( aEvt ); + disposing(); + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + } + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException) + { + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); + } + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException) + { + rBHelper.removeListener( ::getCppuType( &xListener ), xListener ); + } + }; + template< class Ifc1, class Ifc2 > + class WeakAggComponentImplHelper2 + : public ::cppu::OWeakAggObject + , public ::com::sun::star::lang::XComponent + , public ImplHelperBase2< Ifc1, Ifc2 > + { + static ClassData2 s_aCD; + protected: + ::cppu::OBroadcastHelper rBHelper; + virtual void SAL_CALL disposing() + {} + public: + WeakAggComponentImplHelper2( ::osl::Mutex & rMutex ) SAL_THROW( () ) + : rBHelper( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase2< Ifc1, Ifc2 > *)this ) ); + if (aRet.hasValue()) + return aRet; + if (rType == ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > *)0 )) + { + void * p = static_cast< ::com::sun::star::lang::XComponent * >( this ); + return ::com::sun::star::uno::Any( &p, rType ); + } + return OWeakAggObject::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > x( xDelegator ); + if (!x.is() && 1 == m_refCount && !rBHelper.bDisposed) + dispose(); + OWeakAggObject::release(); + } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return getClassData( s_aCD ).getTypes(); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return getClassData( s_aCD ).getImplementationId(); } + virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (!rBHelper.bDisposed && !rBHelper.bInDispose) + { + rBHelper.bInDispose = sal_True; + aGuard.clear(); + ::com::sun::star::lang::EventObject aEvt( static_cast< ::cppu::OWeakObject * >( this ) ); + rBHelper.aLC.disposeAndClear( aEvt ); + disposing(); + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + } + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException) + { + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); + } + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException) + { + rBHelper.removeListener( ::getCppuType( &xListener ), xListener ); + } + }; + +#ifndef MACOSX + template< class Ifc1, class Ifc2 > + ClassData2 WeakComponentImplHelper2< Ifc1, Ifc2 >::s_aCD = ClassData2( 4 ); + template< class Ifc1, class Ifc2 > + ClassData2 WeakAggComponentImplHelper2< Ifc1, Ifc2 >::s_aCD = ClassData2( 3 ); +#endif + +} #endif |