1*caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*caf5cd79SAndrew Rist * distributed with this work for additional information 6*caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9*caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10*caf5cd79SAndrew Rist * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*caf5cd79SAndrew Rist * 13*caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15*caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17*caf5cd79SAndrew Rist * specific language governing permissions and limitations 18*caf5cd79SAndrew Rist * under the License. 19*caf5cd79SAndrew Rist * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir #ifndef _CONNECTIVITY_OSUBCOMPONENT_HXX_ 24cdf0e10cSrcweir #define _CONNECTIVITY_OSUBCOMPONENT_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 27cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 28cdf0e10cSrcweir #include "connectivity/dbtoolsdllapi.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir namespace com 31cdf0e10cSrcweir { 32cdf0e10cSrcweir namespace sun 33cdf0e10cSrcweir { 34cdf0e10cSrcweir namespace star 35cdf0e10cSrcweir { 36cdf0e10cSrcweir namespace lang 37cdf0e10cSrcweir { 38cdf0e10cSrcweir class XComponent; 39cdf0e10cSrcweir } 40cdf0e10cSrcweir } 41cdf0e10cSrcweir } 42cdf0e10cSrcweir } 43cdf0e10cSrcweir namespace connectivity 44cdf0e10cSrcweir { 45cdf0e10cSrcweir OOO_DLLPUBLIC_DBTOOLS 46cdf0e10cSrcweir void release(oslInterlockedCount& _refCount, 47cdf0e10cSrcweir ::cppu::OBroadcastHelper& rBHelper, 48cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface, 49cdf0e10cSrcweir ::com::sun::star::lang::XComponent* _pObject); 50cdf0e10cSrcweir //************************************************************ 51cdf0e10cSrcweir // OSubComponent 52cdf0e10cSrcweir //************************************************************ 53cdf0e10cSrcweir template <class SELF, class WEAK> class OSubComponent 54cdf0e10cSrcweir { 55cdf0e10cSrcweir protected: 56cdf0e10cSrcweir // the parent must support the tunnel implementation 57cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; 58cdf0e10cSrcweir SELF* m_pDerivedImplementation; 59cdf0e10cSrcweir 60cdf0e10cSrcweir public: OSubComponent(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & _xParent,SELF * _pDerivedImplementation)61cdf0e10cSrcweir OSubComponent( 62cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent, 63cdf0e10cSrcweir SELF* _pDerivedImplementation) 64cdf0e10cSrcweir :m_xParent(_xParent) 65cdf0e10cSrcweir ,m_pDerivedImplementation(_pDerivedImplementation) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir protected: dispose_ChildImpl()70cdf0e10cSrcweir void dispose_ChildImpl() 71cdf0e10cSrcweir { 72cdf0e10cSrcweir // avoid ambiguity 73cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_pDerivedImplementation->WEAK::rBHelper.rMutex ); 74cdf0e10cSrcweir m_xParent.clear(); 75cdf0e10cSrcweir } relase_ChildImpl()76cdf0e10cSrcweir void relase_ChildImpl() 77cdf0e10cSrcweir { 78cdf0e10cSrcweir ::connectivity::release(m_pDerivedImplementation->m_refCount, 79cdf0e10cSrcweir m_pDerivedImplementation->WEAK::rBHelper, 80cdf0e10cSrcweir m_xParent, 81cdf0e10cSrcweir m_pDerivedImplementation); 82cdf0e10cSrcweir 83cdf0e10cSrcweir m_pDerivedImplementation->WEAK::release(); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir }; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir #endif // _CONNECTIVITY_OSUBCOMPONENT_HXX_ 88cdf0e10cSrcweir 89