Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_UNOINTERFACEPROXY_HXX
21 : #define INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_UNOINTERFACEPROXY_HXX
22 :
23 : #include "osl/interlck.h"
24 : #include "rtl/ustring.hxx"
25 : #include "sal/types.h"
26 : #include "typelib/typedescription.h"
27 : #include "uno/dispatcher.h"
28 : #include "uno/environment.h"
29 :
30 : namespace com { namespace sun { namespace star { namespace uno {
31 : class XInterface;
32 : } } } }
33 :
34 : namespace bridges { namespace cpp_uno { namespace shared {
35 :
36 : class Bridge;
37 :
38 : extern "C" typedef void SAL_CALL FreeUnoInterfaceProxy(
39 : uno_ExtEnvironment * pEnv, void * pProxy);
40 : FreeUnoInterfaceProxy freeUnoInterfaceProxy;
41 :
42 : // private:
43 : extern "C" typedef void SAL_CALL UnoInterfaceProxyDispatch(
44 : uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr,
45 : void * pReturn, void * pArgs[], uno_Any ** ppException);
46 : UnoInterfaceProxyDispatch unoInterfaceProxyDispatch;
47 : // this function is not defined in the generic part, but instead has to be
48 : // defined individually for each CPP--UNO bridge
49 :
50 : // private:
51 : extern "C" typedef void SAL_CALL AcquireProxy(uno_Interface *);
52 : AcquireProxy acquireProxy;
53 :
54 : // private:
55 : extern "C" typedef void SAL_CALL ReleaseProxy(uno_Interface *);
56 : ReleaseProxy releaseProxy;
57 :
58 : /**
59 : * A uno proxy wrapping a cpp interface.
60 : */
61 : class UnoInterfaceProxy: public uno_Interface {
62 : public:
63 : // Interface for Bridge:
64 :
65 : static UnoInterfaceProxy * create(
66 : Bridge * pBridge, com::sun::star::uno::XInterface * pCppI,
67 : typelib_InterfaceTypeDescription * pTypeDescr,
68 : OUString const & rOId);
69 :
70 : // Interface for individual CPP--UNO bridges:
71 :
72 666935 : Bridge * getBridge() { return pBridge; }
73 561275 : com::sun::star::uno::XInterface * getCppI() { return pCppI; }
74 :
75 : private:
76 : UnoInterfaceProxy(UnoInterfaceProxy &) SAL_DELETED_FUNCTION;
77 : void operator =(const UnoInterfaceProxy&) SAL_DELETED_FUNCTION;
78 :
79 : UnoInterfaceProxy(
80 : Bridge * pBridge_, com::sun::star::uno::XInterface * pCppI_,
81 : typelib_InterfaceTypeDescription * pTypeDescr_,
82 : OUString const & rOId_);
83 :
84 : ~UnoInterfaceProxy();
85 :
86 : oslInterlockedCount nRef;
87 : Bridge * pBridge;
88 :
89 : // mapping information
90 : com::sun::star::uno::XInterface * pCppI; // wrapped interface
91 : typelib_InterfaceTypeDescription * pTypeDescr;
92 : OUString oid;
93 :
94 : friend void SAL_CALL freeUnoInterfaceProxy(
95 : uno_ExtEnvironment * pEnv, void * pProxy);
96 :
97 : friend void SAL_CALL unoInterfaceProxyDispatch(
98 : uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr,
99 : void * pReturn, void * pArgs[], uno_Any ** ppException);
100 :
101 : friend void SAL_CALL acquireProxy(uno_Interface * pUnoI);
102 :
103 : friend void SAL_CALL releaseProxy(uno_Interface * pUnoI);
104 : };
105 :
106 : } } }
107 :
108 : #endif
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|