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_BRIDGE_HXX 25 #define INCLUDED_BRIDGES_CPP_UNO_SHARED_BRIDGE_HXX 26 27 #include "osl/interlck.h" 28 #include "sal/types.h" 29 #include "typelib/typedescription.h" 30 #include "uno/environment.h" 31 #include "uno/mapping.h" 32 33 namespace bridges { namespace cpp_uno { namespace shared { 34 35 // private: 36 extern "C" typedef void SAL_CALL FreeMapping(uno_Mapping *); 37 FreeMapping freeMapping; 38 39 // private: 40 extern "C" 41 typedef void SAL_CALL AcquireMapping(uno_Mapping *); 42 AcquireMapping acquireMapping; 43 44 // private: 45 extern "C" 46 typedef void SAL_CALL ReleaseMapping(uno_Mapping *); 47 ReleaseMapping releaseMapping; 48 49 // private: 50 extern "C" typedef void SAL_CALL Cpp2unoMapping( 51 uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *); 52 Cpp2unoMapping cpp2unoMapping; 53 54 // private: 55 extern "C" typedef void SAL_CALL Uno2cppMapping( 56 uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *); 57 Uno2cppMapping uno2cppMapping; 58 59 /** 60 * Holding environments and mappings. 61 */ 62 class Bridge { 63 public: 64 // Interface for generic/component.cxx: 65 66 static uno_Mapping * createMapping( 67 uno_ExtEnvironment * pCppEnv, uno_ExtEnvironment * pUnoEnv, 68 bool bExportCpp2Uno) SAL_THROW(()); 69 70 // Interface for Cpp/UnoInterfaceProxy: 71 72 void acquire() SAL_THROW(()); 73 void release() SAL_THROW(()); 74 75 // Interface for individual CPP--UNO bridges: 76 getCppEnv()77 uno_ExtEnvironment * getCppEnv() { return pCppEnv; } getUnoEnv()78 uno_ExtEnvironment * getUnoEnv() { return pUnoEnv; } 79 getCpp2Uno()80 uno_Mapping * getCpp2Uno() { return &aCpp2Uno; } getUno2Cpp()81 uno_Mapping * getUno2Cpp() { return &aUno2Cpp; } 82 83 private: 84 Bridge(Bridge &); // not implemented 85 void operator =(Bridge); // not implemented 86 87 Bridge( 88 uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_, 89 bool bExportCpp2Uno_) SAL_THROW(()); 90 91 ~Bridge() SAL_THROW(()); 92 93 struct Mapping: public uno_Mapping { 94 Bridge * pBridge; 95 }; 96 97 oslInterlockedCount nRef; 98 99 uno_ExtEnvironment * pCppEnv; 100 uno_ExtEnvironment * pUnoEnv; 101 102 Mapping aCpp2Uno; 103 Mapping aUno2Cpp; 104 105 bool bExportCpp2Uno; 106 107 friend void SAL_CALL freeMapping(uno_Mapping * pMapping); 108 109 friend void SAL_CALL acquireMapping(uno_Mapping * pMapping); 110 111 friend void SAL_CALL releaseMapping(uno_Mapping * pMapping); 112 113 friend void SAL_CALL cpp2unoMapping( 114 uno_Mapping * pMapping, void ** ppUnoI, void * pCppI, 115 typelib_InterfaceTypeDescription * pTypeDescr); 116 117 friend void SAL_CALL uno2cppMapping( 118 uno_Mapping * pMapping, void ** ppCppI, void * pUnoI, 119 typelib_InterfaceTypeDescription * pTypeDescr); 120 }; 121 122 } } } 123 124 #endif 125