Line data Source code
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 : #ifndef INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_CPPINTERFACEPROXY_HXX
21 : #define INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_CPPINTERFACEPROXY_HXX
22 :
23 : #include "osl/interlck.h"
24 : #include "rtl/ustring.hxx"
25 : #include "sal/types.h"
26 : #include "typelib/typedescription.h"
27 : #include "uno/dispatcher.h"
28 : #include "uno/environment.h"
29 : #include "bridges/cpp_uno/shared/vtablefactory.hxx"
30 :
31 : namespace com { namespace sun { namespace star { namespace uno {
32 : class XInterface;
33 : } } } }
34 :
35 : namespace bridges { namespace cpp_uno { namespace shared {
36 :
37 : class Bridge;
38 :
39 : extern "C" typedef void SAL_CALL FreeCppInterfaceProxy(
40 : uno_ExtEnvironment * pEnv, void * pInterface);
41 : FreeCppInterfaceProxy freeCppInterfaceProxy;
42 :
43 : /**
44 : * A cpp proxy wrapping a uno interface.
45 : */
46 : class CppInterfaceProxy {
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 131585 : Bridge * getBridge() { return pBridge; }
58 142668 : uno_Interface * getUnoI() { return pUnoI; }
59 348236 : typelib_InterfaceTypeDescription * getTypeDescr() { return pTypeDescr; }
60 21586 : OUString getOid() { 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 &); // not implemented
70 : void operator =(const CppInterfaceProxy&); // not implemented
71 :
72 : CppInterfaceProxy(
73 : Bridge * pBridge_, uno_Interface * pUnoI_,
74 : typelib_InterfaceTypeDescription * pTypeDescr_,
75 : OUString const & rOId_);
76 :
77 : ~CppInterfaceProxy();
78 :
79 : static com::sun::star::uno::XInterface * castProxyToInterface(
80 : CppInterfaceProxy * pProxy);
81 :
82 : oslInterlockedCount 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 SAL_CALL freeCppInterfaceProxy(
93 : uno_ExtEnvironment * pEnv, void * pInterface);
94 : };
95 :
96 : } } }
97 :
98 : #endif
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|