Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / connectivity / source / inc / hsqldb / HDriver.hxx
blob4df9a546dafed5d2af050eeab226a6757d70243f
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HDRIVER_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HDRIVER_HXX
22 #include <com/sun/star/sdbc/XDriver.hpp>
23 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
24 #include <com/sun/star/sdbcx/XCreateCatalog.hpp>
25 #include <com/sun/star/embed/XTransactionListener.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <cppuhelper/compbase.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <connectivity/CommonTools.hxx>
34 namespace connectivity
38 namespace hsqldb
40 /// @throws css::uno::Exception
41 css::uno::Reference< css::uno::XInterface > ODriverDelegator_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory);
43 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver
44 , css::sdbcx::XDataDefinitionSupplier
45 , css::lang::XServiceInfo
46 , css::sdbcx::XCreateCatalog
47 , css::embed::XTransactionListener
48 > ODriverDelegator_BASE;
50 typedef std::pair< css::uno::WeakReferenceHelper,css::uno::WeakReferenceHelper> TWeakRefPair;
51 typedef std::pair< OUString ,TWeakRefPair > TWeakConnectionPair;
53 typedef std::pair< css::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
54 typedef std::vector< TWeakPair > TWeakPairVector;
57 /** delegates all calls to the original driver and extend the existing one with the SDBCX layer.
60 class ODriverDelegator final : public ::cppu::BaseMutex
61 ,public ODriverDelegator_BASE
63 TWeakPairVector m_aConnections; // vector containing a list
64 // of all the Connection objects
65 // for this Driver
66 css::uno::Reference< css::sdbc::XDriver > m_xDriver;
67 css::uno::Reference< css::uno::XComponentContext > m_xContext;
68 bool m_bInShutDownConnections;
70 /** load the driver we want to delegate.
71 The <member>m_xDriver</member> may be <NULL/> if the driver could not be loaded.
72 @return
73 The driver which was currently selected.
75 css::uno::Reference< css::sdbc::XDriver > const & loadDriver( );
77 /** shut down the connection and revoke the storage from the map
78 @param _aIter
79 The connection to shut down and storage to revoke.
81 void shutdownConnection(const TWeakPairVector::iterator& _aIter);
83 public:
84 /** creates a new delegator for a HSQLDB driver
86 ODriverDelegator(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
88 // XServiceInfo
89 DECLARE_SERVICE_INFO();
90 /// @throws css::uno::RuntimeException
91 static OUString getImplementationName_Static( );
92 /// @throws css::uno::RuntimeException
93 static css::uno::Sequence< OUString > getSupportedServiceNames_Static( );
95 // XDriver
96 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
97 virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override;
98 virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
99 virtual sal_Int32 SAL_CALL getMajorVersion( ) override;
100 virtual sal_Int32 SAL_CALL getMinorVersion( ) override;
102 // XDataDefinitionSupplier
103 virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const css::uno::Reference< css::sdbc::XConnection >& connection ) override;
104 virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
106 // XCreateCatalog
107 virtual void SAL_CALL createCatalog( const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
109 // XEventListener
110 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
112 // XTransactionListener
113 virtual void SAL_CALL preCommit( const css::lang::EventObject& aEvent ) override;
114 virtual void SAL_CALL commited( const css::lang::EventObject& aEvent ) override;
115 virtual void SAL_CALL preRevert( const css::lang::EventObject& aEvent ) override;
116 virtual void SAL_CALL reverted( const css::lang::EventObject& aEvent ) override;
118 void shutdownConnections();
119 void flushConnections();
120 private:
121 /// dtor
122 virtual ~ODriverDelegator() override;
123 // OComponentHelper
124 virtual void SAL_CALL disposing() override;
126 /** called when we connected to a newly created embedded database
128 void onConnectedNewDatabase(
129 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
135 } // namespace connectivity
137 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HDRIVER_HXX
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */