bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / inc / hsqldb / HDriver.hxx
blobe7921a484b7f7c5dbb8f80a71b9e2cf03adf73d4
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/compbase5.hxx>
30 #include <comphelper/uno3.hxx>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <connectivity/CommonTools.hxx>
35 namespace connectivity
39 namespace hsqldb
41 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
43 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XDriver
44 ,::com::sun::star::sdbcx::XDataDefinitionSupplier
45 , ::com::sun::star::lang::XServiceInfo
46 , ::com::sun::star::sdbcx::XCreateCatalog
47 , ::com::sun::star::embed::XTransactionListener
48 > ODriverDelegator_BASE;
50 typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,::com::sun::star::uno::WeakReferenceHelper> TWeakRefPair;
51 typedef ::std::pair< OUString ,TWeakRefPair > TWeakConnectionPair;
53 typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
54 typedef ::std::vector< TWeakPair > TWeakPairVector;
57 /** delegates all calls to the orignal driver and extend the existing one with the SDBCX layer.
60 class ODriverDelegator : public ::comphelper::OBaseMutex
61 ,public ODriverDelegator_BASE
63 TWeakPairVector m_aConnections; // vector containing a list
64 // of all the Connection objects
65 // for this Driver
66 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver;
67 ::com::sun::star::uno::Reference< ::com::sun::star::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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > 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 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
88 // XServiceInfo
89 DECLARE_SERVICE_INFO();
90 static OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
91 static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
93 // XDriver
94 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 virtual sal_Int32 SAL_CALL getMajorVersion( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual sal_Int32 SAL_CALL getMinorVersion( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 // XDataDefinitionSupplier
101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 // XCreateCatalog
105 virtual void SAL_CALL createCatalog( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 // XEventListener
108 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 // XTransactionListener
111 virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 void shutdownConnections();
117 void flushConnections();
118 protected:
119 /// dtor
120 virtual ~ODriverDelegator();
121 // OComponentHelper
122 virtual void SAL_CALL disposing() SAL_OVERRIDE;
124 /** called when we connected to a newly created embedded database
126 void onConnectedNewDatabase(
127 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
133 } // namespace connectivity
135 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HDRIVER_HXX
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */