LibreOffice Module bridges (master)  1
cppinterfaceproxy.hxx
Go to the documentation of this file.
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 
47 public:
48  // Interface for Bridge:
49 
50  static com::sun::star::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  Bridge * getBridge() { return pBridge; }
58  uno_Interface * getUnoI() { return pUnoI; }
59  typelib_InterfaceTypeDescription * getTypeDescr() { return pTypeDescr; }
60  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;
71 
73  Bridge * pBridge_, uno_Interface * pUnoI_,
74  typelib_InterfaceTypeDescription * pTypeDescr_,
75  OUString const & rOId_);
76 
78 
79  static com::sun::star::uno::XInterface * castProxyToInterface(
80  CppInterfaceProxy * pProxy);
81 
82  std::atomic<std::size_t> nRef;
84 
85  // mapping information
86  uno_Interface * pUnoI; // wrapped interface
87  typelib_InterfaceTypeDescription * pTypeDescr;
88  OUString oid;
89 
91 
92  friend void freeCppInterfaceProxy(
93  uno_ExtEnvironment * pEnv, void * pInterface);
94 };
95 
96 }
97 
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
friend void freeCppInterfaceProxy(uno_ExtEnvironment *pEnv, void *pInterface)
CppInterfaceProxy(CppInterfaceProxy const &)=delete
static com::sun::star::uno::XInterface * castProxyToInterface(CppInterfaceProxy *pProxy)
static com::sun::star::uno::XInterface * create(Bridge *pBridge, uno_Interface *pUnoI, typelib_InterfaceTypeDescription *pTypeDescr, OUString const &rOId)
CppInterfaceProxy & operator=(const CppInterfaceProxy &)=delete
typelib_InterfaceTypeDescription * getTypeDescr()
A cpp proxy wrapping a uno interface.
typelib_InterfaceTypeDescription * pTypeDescr
void freeCppInterfaceProxy(uno_ExtEnvironment *pEnv, void *pInterface)
Holding environments and mappings.
Definition: bridge.hxx:54
static CppInterfaceProxy * castInterfaceToProxy(void *pInterface)