/src/libreoffice/bridges/inc/cppinterfaceproxy.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 | | #include "vtablefactory.hxx" |
33 | | |
34 | | namespace com::sun::star::uno { class XInterface; } |
35 | | |
36 | | namespace bridges::cpp_uno::shared { |
37 | | |
38 | | class Bridge; |
39 | | |
40 | | extern "C" void freeCppInterfaceProxy( |
41 | | uno_ExtEnvironment * pEnv, void * pInterface); |
42 | | |
43 | | /** |
44 | | * A cpp proxy wrapping a uno interface. |
45 | | */ |
46 | | class CppInterfaceProxy { |
47 | | public: |
48 | | // Interface for Bridge: |
49 | | |
50 | | static css::uno::XInterface * create( |
51 | | Bridge * pBridge, uno_Interface * pUnoI, |
52 | | typelib_InterfaceTypeDescription * pTypeDescr, |
53 | | OUString const & rOId); |
54 | | |
55 | | // Interface for individual CPP--UNO bridges: |
56 | | |
57 | 0 | Bridge * getBridge() { return pBridge; } |
58 | 0 | uno_Interface * getUnoI() { return pUnoI; } |
59 | 0 | typelib_InterfaceTypeDescription * getTypeDescr() { return pTypeDescr; } |
60 | 0 | const OUString& getOid() const { return oid; } |
61 | | |
62 | | // non virtual methods called on incoming vtable calls #1, #2 |
63 | | void acquireProxy(); |
64 | | void releaseProxy(); |
65 | | |
66 | | static CppInterfaceProxy * castInterfaceToProxy(void * pInterface); |
67 | | |
68 | | private: |
69 | | CppInterfaceProxy(CppInterfaceProxy const &) = delete; |
70 | | CppInterfaceProxy& operator =(const CppInterfaceProxy&) = delete; |
71 | | |
72 | | CppInterfaceProxy( |
73 | | Bridge * pBridge_, uno_Interface * pUnoI_, |
74 | | typelib_InterfaceTypeDescription * pTypeDescr_, |
75 | | OUString aOId_); |
76 | | |
77 | | ~CppInterfaceProxy(); |
78 | | |
79 | | static css::uno::XInterface * castProxyToInterface( |
80 | | CppInterfaceProxy * pProxy); |
81 | | |
82 | | std::atomic<std::size_t> nRef; |
83 | | Bridge * pBridge; |
84 | | |
85 | | // mapping information |
86 | | uno_Interface * pUnoI; // wrapped interface |
87 | | typelib_InterfaceTypeDescription * pTypeDescr; |
88 | | OUString oid; |
89 | | |
90 | | VtableFactory::Slot * vtables[1] = {}; |
91 | | |
92 | | friend void freeCppInterfaceProxy( |
93 | | uno_ExtEnvironment * pEnv, void * pInterface); |
94 | | }; |
95 | | |
96 | | } |
97 | | |
98 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |