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 _CONNECTIVITY_OSUBCOMPONENT_HXX_ 24 #define _CONNECTIVITY_OSUBCOMPONENT_HXX_ 25 26 #include <cppuhelper/weak.hxx> 27 #include <cppuhelper/interfacecontainer.h> 28 #include "connectivity/dbtoolsdllapi.hxx" 29 30 namespace com 31 { 32 namespace sun 33 { 34 namespace star 35 { 36 namespace lang 37 { 38 class XComponent; 39 } 40 } 41 } 42 } 43 namespace connectivity 44 { 45 OOO_DLLPUBLIC_DBTOOLS 46 void release(oslInterlockedCount& _refCount, 47 ::cppu::OBroadcastHelper& rBHelper, 48 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface, 49 ::com::sun::star::lang::XComponent* _pObject); 50 //************************************************************ 51 // OSubComponent 52 //************************************************************ 53 template <class SELF, class WEAK> class OSubComponent 54 { 55 protected: 56 // the parent must support the tunnel implementation 57 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; 58 SELF* m_pDerivedImplementation; 59 60 public: OSubComponent(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & _xParent,SELF * _pDerivedImplementation)61 OSubComponent( 62 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent, 63 SELF* _pDerivedImplementation) 64 :m_xParent(_xParent) 65 ,m_pDerivedImplementation(_pDerivedImplementation) 66 { 67 } 68 69 protected: dispose_ChildImpl()70 void dispose_ChildImpl() 71 { 72 // avoid ambiguity 73 ::osl::MutexGuard aGuard( m_pDerivedImplementation->WEAK::rBHelper.rMutex ); 74 m_xParent.clear(); 75 } relase_ChildImpl()76 void relase_ChildImpl() 77 { 78 ::connectivity::release(m_pDerivedImplementation->m_refCount, 79 m_pDerivedImplementation->WEAK::rBHelper, 80 m_xParent, 81 m_pDerivedImplementation); 82 83 m_pDerivedImplementation->WEAK::release(); 84 } 85 }; 86 } 87 #endif // _CONNECTIVITY_OSUBCOMPONENT_HXX_ 88 89