/src/libreoffice/bridges/inc/unointerfaceproxy.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <atomic> |
25 | | #include <cstddef> |
26 | | |
27 | | #include <rtl/ustring.hxx> |
28 | | #include <sal/types.h> |
29 | | #include <typelib/typedescription.h> |
30 | | #include <uno/dispatcher.h> |
31 | | #include <uno/environment.h> |
32 | | |
33 | | namespace com::sun::star::uno { class XInterface; } |
34 | | |
35 | | namespace bridges::cpp_uno::shared { |
36 | | |
37 | | class Bridge; |
38 | | |
39 | | extern "C" void freeUnoInterfaceProxy( |
40 | | uno_ExtEnvironment * pEnv, void * pProxy); |
41 | | |
42 | | // private: |
43 | | extern "C" void unoInterfaceProxyDispatch( |
44 | | uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr, |
45 | | void * pReturn, void * pArgs[], uno_Any ** ppException); |
46 | | // this function is not defined in the generic part, but instead has to be |
47 | | // defined individually for each CPP--UNO bridge |
48 | | |
49 | | // private: |
50 | | extern "C" void acquireProxy(uno_Interface *); |
51 | | |
52 | | // private: |
53 | | extern "C" void releaseProxy(uno_Interface *); |
54 | | |
55 | | /** |
56 | | * A uno proxy wrapping a cpp interface. |
57 | | */ |
58 | | class UnoInterfaceProxy: public uno_Interface { |
59 | | public: |
60 | | // Interface for Bridge: |
61 | | |
62 | | static UnoInterfaceProxy * create( |
63 | | Bridge * pBridge, css::uno::XInterface * pCppI, |
64 | | typelib_InterfaceTypeDescription * pTypeDescr, |
65 | | OUString const & rOId); |
66 | | |
67 | | // Interface for individual CPP--UNO bridges: |
68 | | |
69 | 140k | Bridge * getBridge() { return pBridge; } |
70 | 99.1k | css::uno::XInterface * getCppI() { return pCppI; } |
71 | | |
72 | | private: |
73 | | UnoInterfaceProxy(UnoInterfaceProxy const &) = delete; |
74 | | UnoInterfaceProxy& operator =(const UnoInterfaceProxy&) = delete; |
75 | | |
76 | | UnoInterfaceProxy( |
77 | | Bridge * pBridge_, css::uno::XInterface * pCppI_, |
78 | | typelib_InterfaceTypeDescription * pTypeDescr_, |
79 | | OUString aOId_); |
80 | | |
81 | | ~UnoInterfaceProxy(); |
82 | | |
83 | | std::atomic<std::size_t> nRef; |
84 | | Bridge * pBridge; |
85 | | |
86 | | // mapping information |
87 | | css::uno::XInterface * pCppI; // wrapped interface |
88 | | typelib_InterfaceTypeDescription * pTypeDescr; |
89 | | OUString oid; |
90 | | |
91 | | friend void freeUnoInterfaceProxy( |
92 | | uno_ExtEnvironment * pEnv, void * pProxy); |
93 | | |
94 | | friend void unoInterfaceProxyDispatch( |
95 | | uno_Interface * pUnoI, typelib_TypeDescription const * pMemberDescr, |
96 | | void * pReturn, void * pArgs[], uno_Any ** ppException); |
97 | | |
98 | | friend void acquireProxy(uno_Interface * pUnoI); |
99 | | |
100 | | friend void releaseProxy(uno_Interface * pUnoI); |
101 | | }; |
102 | | |
103 | | } |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |