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 24 #ifndef INCLUDED_BRIDGES_CPP_UNO_SHARED_UNOINTERFACEPROXY_HXX 25 #define INCLUDED_BRIDGES_CPP_UNO_SHARED_UNOINTERFACEPROXY_HXX 26 27 #include "osl/interlck.h" 28 #include "rtl/ustring.hxx" 29 #include "sal/types.h" 30 #include "typelib/typedescription.h" 31 #include "uno/dispatcher.h" 32 #include "uno/environment.h" 33 34 namespace com { namespace sun { namespace star { namespace uno { 35 class XInterface; 36 } } } } 37 38 namespace bridges { namespace cpp_uno { namespace shared { 39 40 class Bridge; 41 42 extern "C" typedef void SAL_CALL FreeUnoInterfaceProxy( 43 uno_ExtEnvironment * pEnv, void * pProxy); 44 FreeUnoInterfaceProxy freeUnoInterfaceProxy; 45 46 // private: 47 extern "C" typedef void SAL_CALL UnoInterfaceProxyDispatch( 48 uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr, 49 void * pReturn, void * pArgs[], uno_Any ** ppException); 50 UnoInterfaceProxyDispatch unoInterfaceProxyDispatch; 51 // this function is not defined in the generic part, but instead has to be 52 // defined individually for each CPP--UNO bridge 53 54 // private: 55 extern "C" typedef void SAL_CALL AcquireProxy(uno_Interface *); 56 AcquireProxy acquireProxy; 57 58 // private: 59 extern "C" typedef void SAL_CALL ReleaseProxy(uno_Interface *); 60 ReleaseProxy releaseProxy; 61 62 /** 63 * A uno proxy wrapping a cpp interface. 64 */ 65 class UnoInterfaceProxy: public uno_Interface { 66 public: 67 // Interface for Bridge: 68 69 static UnoInterfaceProxy * create( 70 Bridge * pBridge, com::sun::star::uno::XInterface * pCppI, 71 typelib_InterfaceTypeDescription * pTypeDescr, 72 rtl::OUString const & rOId) SAL_THROW(()); 73 74 // Interface for individual CPP--UNO bridges: 75 getBridge()76 Bridge * getBridge() { return pBridge; } getCppI()77 com::sun::star::uno::XInterface * getCppI() { return pCppI; } 78 79 private: 80 UnoInterfaceProxy(UnoInterfaceProxy &); // not implemented 81 void operator =(UnoInterfaceProxy); // not implemented 82 83 UnoInterfaceProxy( 84 Bridge * pBridge_, com::sun::star::uno::XInterface * pCppI_, 85 typelib_InterfaceTypeDescription * pTypeDescr_, 86 rtl::OUString const & rOId_) SAL_THROW(()); 87 88 ~UnoInterfaceProxy(); 89 90 oslInterlockedCount nRef; 91 Bridge * pBridge; 92 93 // mapping information 94 com::sun::star::uno::XInterface * pCppI; // wrapped interface 95 typelib_InterfaceTypeDescription * pTypeDescr; 96 rtl::OUString oid; 97 98 friend void SAL_CALL freeUnoInterfaceProxy( 99 uno_ExtEnvironment * pEnv, void * pProxy); 100 101 friend void SAL_CALL unoInterfaceProxyDispatch( 102 uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr, 103 void * pReturn, void * pArgs[], uno_Any ** ppException); 104 105 friend void SAL_CALL acquireProxy(uno_Interface * pUnoI); 106 107 friend void SAL_CALL releaseProxy(uno_Interface * pUnoI); 108 }; 109 110 } } } 111 112 #endif 113