LibreOffice Module connectivity (master) 1
HDriver.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <com/sun/star/sdbc/XDriver.hpp>
22#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
23#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
24#include <com/sun/star/embed/XTransactionListener.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/uno/XComponentContext.hpp>
30
31
33 {
34 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver
35 , css::sdbcx::XDataDefinitionSupplier
36 , css::lang::XServiceInfo
37 , css::sdbcx::XCreateCatalog
38 , css::embed::XTransactionListener
40
41 typedef std::pair< css::uno::WeakReferenceHelper,css::uno::WeakReferenceHelper> TWeakRefPair;
42 typedef std::pair< OUString ,TWeakRefPair > TWeakConnectionPair;
43
44 typedef std::pair< css::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
45 typedef std::vector< TWeakPair > TWeakPairVector;
46
47
53 {
54 TWeakPairVector m_aConnections; // vector containing a list
55 // of all the Connection objects
56 // for this Driver
57 css::uno::Reference< css::sdbc::XDriver > m_xDriver;
58 css::uno::Reference< css::uno::XComponentContext > m_xContext;
60
66 css::uno::Reference< css::sdbc::XDriver > const & loadDriver( );
67
72 void shutdownConnection(const TWeakPairVector::iterator& _aIter);
73
74 public:
77 ODriverDelegator(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
78
79 // XServiceInfo
81
82 // XDriver
83 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
84 virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override;
85 virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
86 virtual sal_Int32 SAL_CALL getMajorVersion( ) override;
87 virtual sal_Int32 SAL_CALL getMinorVersion( ) override;
88
89 // XDataDefinitionSupplier
90 virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const css::uno::Reference< css::sdbc::XConnection >& connection ) override;
91 virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
92
93 // XCreateCatalog
94 virtual void SAL_CALL createCatalog( const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
95
96 // XEventListener
97 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
98
99 // XTransactionListener
100 virtual void SAL_CALL preCommit( const css::lang::EventObject& aEvent ) override;
101 virtual void SAL_CALL commited( const css::lang::EventObject& aEvent ) override;
102 virtual void SAL_CALL preRevert( const css::lang::EventObject& aEvent ) override;
103 virtual void SAL_CALL reverted( const css::lang::EventObject& aEvent ) override;
104
105 void shutdownConnections();
106 void flushConnections();
107 private:
109 virtual ~ODriverDelegator() override;
110 // OComponentHelper
111 virtual void SAL_CALL disposing() override;
112
116 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
117 );
118 };
119
120
121} // namespace connectivity::hsqldb
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
delegates all calls to the original driver and extend the existing one with the SDBCX layer.
Definition: HDriver.hxx:53
virtual void SAL_CALL preRevert(const css::lang::EventObject &aEvent) override
Definition: HDriver.cxx:670
virtual void SAL_CALL reverted(const css::lang::EventObject &aEvent) override
Definition: HDriver.cxx:674
virtual void SAL_CALL disposing() override
Definition: HDriver.cxx:98
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
css::uno::Reference< css::sdbc::XDriver > m_xDriver
Definition: HDriver.hxx:57
virtual void SAL_CALL createCatalog(const css::uno::Sequence< css::beans::PropertyValue > &info) override
Definition: HDriver.cxx:519
virtual void SAL_CALL commited(const css::lang::EventObject &aEvent) override
Definition: HDriver.cxx:666
virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
virtual sal_Int32 SAL_CALL getMajorVersion() override
Definition: HDriver.cxx:454
virtual sal_Int32 SAL_CALL getMinorVersion() override
Definition: HDriver.cxx:460
css::uno::Reference< css::sdbc::XDriver > const & loadDriver()
load the driver we want to delegate.
Definition: HDriver.cxx:120
virtual void SAL_CALL preCommit(const css::lang::EventObject &aEvent) override
Definition: HDriver.cxx:623
ODriverDelegator(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
creates a new delegator for a HSQLDB driver
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: HDriver.hxx:58
virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
void onConnectedNewDatabase(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection)
called when we connected to a newly created embedded database
Definition: HDriver.cxx:859
virtual css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection(const css::uno::Reference< css::sdbc::XConnection > &connection) override
void shutdownConnection(const TWeakPairVector::iterator &_aIter)
shut down the connection and revoke the storage from the map
Definition: HDriver.cxx:524
virtual ~ODriverDelegator() override
dtor
Definition: HDriver.cxx:86
virtual sal_Bool SAL_CALL acceptsURL(const OUString &url) override
Definition: HDriver.cxx:401
std::pair< css::uno::WeakReferenceHelper, css::uno::WeakReferenceHelper > TWeakRefPair
Definition: HDriver.hxx:41
std::pair< css::uno::WeakReferenceHelper, TWeakConnectionPair > TWeakPair
Definition: HDriver.hxx:44
std::pair< OUString,TWeakRefPair > TWeakConnectionPair
Definition: HDriver.hxx:42
::cppu::WeakComponentImplHelper< css::sdbc::XDriver, css::sdbcx::XDataDefinitionSupplier, css::lang::XServiceInfo, css::sdbcx::XCreateCatalog, css::embed::XTransactionListener > ODriverDelegator_BASE
Definition: HDriver.hxx:39
std::vector< TWeakPair > TWeakPairVector
Definition: HDriver.hxx:45
unsigned char sal_Bool