bump product version to 6.3.0.0.beta1
[LibreOffice.git] / bridges / inc / bridge.hxx
blob9e33cb53bb91281610c703399e196732536b956a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BRIDGES_INC_BRIDGE_HXX
21 #define INCLUDED_BRIDGES_INC_BRIDGE_HXX
23 #include <sal/config.h>
25 #include <atomic>
26 #include <cstddef>
28 #include <sal/types.h>
29 #include <typelib/typedescription.h>
30 #include <uno/environment.h>
31 #include <uno/mapping.h>
33 namespace bridges { namespace cpp_uno { namespace shared {
35 // private:
36 extern "C" void freeMapping(uno_Mapping *);
38 // private:
39 extern "C" void acquireMapping(uno_Mapping *);
41 // private:
42 extern "C" void releaseMapping(uno_Mapping *);
44 // private:
45 extern "C" void cpp2unoMapping(
46 uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
48 // private:
49 extern "C" void uno2cppMapping(
50 uno_Mapping *, void **, void *, typelib_InterfaceTypeDescription *);
52 /**
53 * Holding environments and mappings.
55 class Bridge {
56 public:
57 // Interface for generic/component.cxx:
59 static uno_Mapping * createMapping(
60 uno_ExtEnvironment * pCppEnv, uno_ExtEnvironment * pUnoEnv,
61 bool bExportCpp2Uno);
63 // Interface for Cpp/UnoInterfaceProxy:
65 void acquire();
66 void release();
68 // Interface for individual CPP--UNO bridges:
70 uno_ExtEnvironment * getCppEnv() { return pCppEnv; }
71 uno_ExtEnvironment * getUnoEnv() { return pUnoEnv; }
73 uno_Mapping * getCpp2Uno() { return &aCpp2Uno; }
74 uno_Mapping * getUno2Cpp() { return &aUno2Cpp; }
76 private:
77 Bridge(Bridge const &) = delete;
78 Bridge& operator =(const Bridge&) = delete;
80 Bridge(
81 uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
82 bool bExportCpp2Uno_);
84 ~Bridge();
86 struct Mapping: public uno_Mapping {
87 Bridge * pBridge;
90 std::atomic<std::size_t> nRef;
92 uno_ExtEnvironment * pCppEnv;
93 uno_ExtEnvironment * pUnoEnv;
95 Mapping aCpp2Uno;
96 Mapping aUno2Cpp;
98 bool bExportCpp2Uno;
100 friend void freeMapping(uno_Mapping * pMapping);
102 friend void acquireMapping(uno_Mapping * pMapping);
104 friend void releaseMapping(uno_Mapping * pMapping);
106 friend void cpp2unoMapping(
107 uno_Mapping * pMapping, void ** ppUnoI, void * pCppI,
108 typelib_InterfaceTypeDescription * pTypeDescr);
110 friend void uno2cppMapping(
111 uno_Mapping * pMapping, void ** ppCppI, void * pUnoI,
112 typelib_InterfaceTypeDescription * pTypeDescr);
115 } } }
117 #endif
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */