LibreOffice Module bridges (master)  1
unointerfaceproxy.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 
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 
58 class UnoInterfaceProxy: public uno_Interface {
59 public:
60  // Interface for Bridge:
61 
62  static UnoInterfaceProxy * create(
63  Bridge * pBridge, com::sun::star::uno::XInterface * pCppI,
64  typelib_InterfaceTypeDescription * pTypeDescr,
65  OUString const & rOId);
66 
67  // Interface for individual CPP--UNO bridges:
68 
69  Bridge * getBridge() { return pBridge; }
70  com::sun::star::uno::XInterface * getCppI() { return pCppI; }
71 
72 private:
73  UnoInterfaceProxy(UnoInterfaceProxy const &) = delete;
75 
77  Bridge * pBridge_, com::sun::star::uno::XInterface * pCppI_,
78  typelib_InterfaceTypeDescription * pTypeDescr_,
79  OUString const & rOId_);
80 
82 
83  std::atomic<std::size_t> nRef;
85 
86  // mapping information
87  com::sun::star::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: */
com::sun::star::uno::XInterface * pCppI
friend void unoInterfaceProxyDispatch(uno_Interface *pUnoI, typelib_TypeDescription const *pMemberDescr, void *pReturn, void *pArgs[], uno_Any **ppException)
A uno proxy wrapping a cpp interface.
void freeUnoInterfaceProxy(uno_ExtEnvironment *pEnv, void *pProxy)
static UnoInterfaceProxy * create(Bridge *pBridge, com::sun::star::uno::XInterface *pCppI, typelib_InterfaceTypeDescription *pTypeDescr, OUString const &rOId)
void unoInterfaceProxyDispatch(uno_Interface *pUnoI, const typelib_TypeDescription *pMemberDescr, void *pReturn, void *pArgs[], uno_Any **ppException)
friend void freeUnoInterfaceProxy(uno_ExtEnvironment *pEnv, void *pProxy)
void releaseProxy(uno_Interface *pUnoI)
struct _uno_Any uno_Any
Definition: msvc/except.hxx:31
UnoInterfaceProxy & operator=(const UnoInterfaceProxy &)=delete
typelib_InterfaceTypeDescription * pTypeDescr
friend void releaseProxy(uno_Interface *pUnoI)
void acquireProxy(uno_Interface *pUnoI)
UnoInterfaceProxy(UnoInterfaceProxy const &)=delete
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:52
friend void acquireProxy(uno_Interface *pUnoI)
Holding environments and mappings.
Definition: bridge.hxx:54
com::sun::star::uno::XInterface * getCppI()