tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / cpool / ZPoolCollection.hxx
blob3fdade8a9db676291179382099b383b0eb5711d2
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 .
19 #pragma once
21 #include <sal/config.h>
23 #include <map>
25 #include <cppuhelper/implbase.hxx>
26 #include <cppuhelper/weakref.hxx>
27 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
28 #include <com/sun/star/sdbc/XDriver.hpp>
29 #include <com/sun/star/sdbc/XDriverManager2.hpp>
30 #include <com/sun/star/sdbc/XConnectionPool.hpp>
31 #include <com/sun/star/sdbc/XConnection.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/frame/XDesktop2.hpp>
36 #include <com/sun/star/frame/XTerminateListener.hpp>
37 #include <com/sun/star/reflection/XProxyFactory.hpp>
38 #include <osl/mutex.hxx>
39 #include <rtl/ref.hxx>
41 namespace connectivity
43 class OConnectionPool;
45 // OPoolCollection - the one-instance service for PooledConnections
46 // manages the active connections and the connections in the pool
48 typedef ::cppu::WeakImplHelper< css::sdbc::XConnectionPool,
49 css::lang::XServiceInfo,
50 css::frame::XTerminateListener,
51 css::beans::XPropertyChangeListener
52 > OPoolCollection_Base;
54 /// OPoolCollection: control the whole connection pooling for oo
55 class OPoolCollection : public OPoolCollection_Base
59 typedef std::map<OUString, rtl::Reference<OConnectionPool>> OConnectionPools;
61 typedef std::map<
62 css::uno::Reference< css::sdbc::XDriver >,
63 css::uno::WeakReference< css::sdbc::XDriver >>
64 MapDriver2DriverRef;
66 MapDriver2DriverRef m_aDriverProxies;
67 ::osl::Mutex m_aMutex;
68 OConnectionPools m_aPools; // the driver pools
69 css::uno::Reference< css::uno::XComponentContext > m_xContext;
70 css::uno::Reference< css::sdbc::XDriverManager2 > m_xManager;
71 css::uno::Reference< css::reflection::XProxyFactory > m_xProxyFactory;
72 css::uno::Reference< css::uno::XInterface > m_xConfigNode; // config node for general connection pooling
73 css::uno::Reference< css::frame::XDesktop2> m_xDesktop;
75 public:
76 OPoolCollection(const OPoolCollection&) = delete;
77 int operator= (const OPoolCollection&) = delete;
79 explicit OPoolCollection(
80 const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
82 private:
83 // some configuration helper methods
84 css::uno::Reference< css::uno::XInterface > const & getConfigPoolRoot();
85 static css::uno::Reference< css::uno::XInterface > createWithProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxConfProvider,
86 const OUString& _rPath);
87 static css::uno::Reference< css::uno::XInterface > openNode( const OUString& _rPath,
88 const css::uno::Reference< css::uno::XInterface >& _xTreeNode) noexcept;
89 bool isPoolingEnabled();
90 bool isDriverPoolingEnabled(std::u16string_view _sDriverImplName,
91 css::uno::Reference< css::uno::XInterface >& _rxDriverNode);
92 bool isPoolingEnabledByUrl( const OUString& _sUrl,
93 css::uno::Reference< css::sdbc::XDriver >& _rxDriver,
94 OUString& _rsImplName,
95 css::uno::Reference< css::uno::XInterface >& _rxDriverNode);
97 OConnectionPool* getConnectionPool( const OUString& _sImplName,
98 const css::uno::Reference< css::sdbc::XDriver >& _xDriver,
99 const css::uno::Reference< css::uno::XInterface >& _rxDriverNode);
100 void clearConnectionPools(bool _bDispose);
101 void clearDesktop();
102 protected:
103 virtual ~OPoolCollection() override;
104 public:
106 static css::uno::Any getNodeValue( const OUString& _rPath,
107 const css::uno::Reference< css::uno::XInterface>& _xTreeNode)noexcept;
109 // XDriverManager
110 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) override;
111 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
112 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) override;
113 virtual sal_Int32 SAL_CALL getLoginTimeout( ) override;
115 //XDriverAccess
116 virtual css::uno::Reference< css::sdbc::XDriver > SAL_CALL getDriverByURL( const OUString& url ) override;
117 // XServiceInfo
118 virtual OUString SAL_CALL getImplementationName( ) override;
119 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
120 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
122 // XEventListener
123 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
124 // XPropertyChangeListener
125 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
127 // XTerminateListener
128 virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override;
129 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */