LibreOffice Module bridges (master)  1
bridge.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 <sal/types.h>
28 #include <typelib/typedescription.h>
29 #include <uno/environment.h>
30 #include <uno/mapping.h>
31 
32 namespace bridges::cpp_uno::shared {
33 
34 // private:
35 extern "C" void freeMapping(uno_Mapping *);
36 
37 // private:
38 extern "C" void acquireMapping(uno_Mapping *);
39 
40 // private:
41 extern "C" void releaseMapping(uno_Mapping *);
42 
43 // private:
44 extern "C" void cpp2unoMapping(
45  uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
46 
47 // private:
48 extern "C" void uno2cppMapping(
49  uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
50 
54 class Bridge {
55 public:
56  // Interface for generic/component.cxx:
57 
58  static uno_Mapping * createMapping(
59  uno_ExtEnvironment * pCppEnv, uno_ExtEnvironment * pUnoEnv,
60  bool bExportCpp2Uno);
61 
62  // Interface for Cpp/UnoInterfaceProxy:
63 
64  void acquire();
65  void release();
66 
67  // Interface for individual CPP--UNO bridges:
68 
69  uno_ExtEnvironment * getCppEnv() { return pCppEnv; }
70  uno_ExtEnvironment * getUnoEnv() { return pUnoEnv; }
71 
72  uno_Mapping * getCpp2Uno() { return &aCpp2Uno; }
73  uno_Mapping * getUno2Cpp() { return &aUno2Cpp; }
74 
75 private:
76  Bridge(Bridge const &) = delete;
77  Bridge& operator =(const Bridge&) = delete;
78 
79  Bridge(
80  uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
81  bool bExportCpp2Uno_);
82 
83  ~Bridge();
84 
85  struct Mapping: public uno_Mapping {
87  };
88 
89  std::atomic<std::size_t> nRef;
90 
91  uno_ExtEnvironment * pCppEnv;
92  uno_ExtEnvironment * pUnoEnv;
93 
96 
98 
99  friend void freeMapping(uno_Mapping * pMapping);
100 
101  friend void acquireMapping(uno_Mapping * pMapping);
102 
103  friend void releaseMapping(uno_Mapping * pMapping);
104 
105  friend void cpp2unoMapping(
106  uno_Mapping * pMapping, void ** ppUnoI, void * pCppI,
107  typelib_InterfaceTypeDescription * pTypeDescr);
108 
109  friend void uno2cppMapping(
110  uno_Mapping * pMapping, void ** ppCppI, void * pUnoI,
111  typelib_InterfaceTypeDescription * pTypeDescr);
112 };
113 
114 }
115 
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
friend void releaseMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:46
Bridge(Bridge const &)=delete
struct _uno_Mapping uno_Mapping
Definition: msvc/except.hxx:32
uno_ExtEnvironment * pUnoEnv
Definition: bridge.hxx:92
void acquireMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:41
void uno2cppMapping(uno_Mapping *pMapping, void **ppCppI, void *pUnoI, typelib_InterfaceTypeDescription *pTypeDescr)
Definition: bridge.cxx:97
std::atomic< std::size_t > nRef
Definition: bridge.hxx:89
uno_ExtEnvironment * getUnoEnv()
Definition: bridge.hxx:70
uno_Mapping * getUno2Cpp()
Definition: bridge.hxx:73
static uno_Mapping * createMapping(uno_ExtEnvironment *pCppEnv, uno_ExtEnvironment *pUnoEnv, bool bExportCpp2Uno)
Definition: bridge.cxx:142
uno_ExtEnvironment * getCppEnv()
Definition: bridge.hxx:69
uno_ExtEnvironment * pCppEnv
Definition: bridge.hxx:91
friend void uno2cppMapping(uno_Mapping *pMapping, void **ppCppI, void *pUnoI, typelib_InterfaceTypeDescription *pTypeDescr)
Definition: bridge.cxx:97
friend void freeMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:36
uno_Mapping * getCpp2Uno()
Definition: bridge.hxx:72
void releaseMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:46
friend void cpp2unoMapping(uno_Mapping *pMapping, void **ppUnoI, void *pCppI, typelib_InterfaceTypeDescription *pTypeDescr)
Definition: bridge.cxx:51
Bridge & operator=(const Bridge &)=delete
Holding environments and mappings.
Definition: bridge.hxx:54
void cpp2unoMapping(uno_Mapping *pMapping, void **ppUnoI, void *pCppI, typelib_InterfaceTypeDescription *pTypeDescr)
Definition: bridge.cxx:51
void freeMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:36
friend void acquireMapping(uno_Mapping *pMapping)
Definition: bridge.cxx:41