cid#1607171 Data race condition
[LibreOffice.git] / connectivity / source / inc / hsqldb / HConnection.hxx
blobf319287774efeeb0ed086ea679a3622a6fee76f8
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 .
20 #pragma once
22 #include <connectivity/ConnectionWrapper.hxx>
23 #include <com/sun/star/util/XFlushable.hpp>
24 #include <com/sun/star/sdbc/XDriver.hpp>
25 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
26 #include <cppuhelper/compbase.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <comphelper/uno3.hxx>
29 #include <comphelper/interfacecontainer2.hxx>
31 namespace connectivity::hsqldb
33 class SAL_NO_VTABLE IMethodGuardAccess
35 public:
36 virtual ::osl::Mutex& getMutex() const = 0;
37 virtual void checkDisposed() const = 0;
39 protected:
40 ~IMethodGuardAccess() {}
44 // OHsqlConnection - wraps all methods to the real connection from the driver
45 // but when disposed it doesn't dispose the real connection
47 typedef ::cppu::ImplInheritanceHelper< OConnectionWrapper
48 , css::util::XFlushable
49 , css::sdb::application::XTableUIProvider
50 > OHsqlConnection_BASE;
52 class OHsqlConnection :public OHsqlConnection_BASE
53 ,public IMethodGuardAccess
55 private:
56 ::comphelper::OInterfaceContainerHelper2 m_aFlushListeners;
57 css::uno::Reference< css::sdbc::XDriver > m_xDriver;
58 css::uno::Reference< css::uno::XComponentContext > m_xContext;
59 bool m_bIni;
60 bool m_bReadOnly;
62 protected:
63 virtual void SAL_CALL disposing() override;
64 virtual ~OHsqlConnection() override;
66 public:
67 OHsqlConnection(
68 const css::uno::Reference< css::sdbc::XDriver >& _rxDriver,
69 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
70 const css::uno::Reference< css::uno::XComponentContext>& _rxContext
73 // XServiceInfo
74 DECLARE_SERVICE_INFO();
76 // IMethodGuardAccess
77 virtual ::osl::Mutex& getMutex() const override;
78 virtual void checkDisposed() const override;
80 // XFlushable
81 virtual void SAL_CALL flush( ) override;
82 virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
83 virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
85 // XTableUIProvider
86 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) override;
87 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getTableEditor( const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) override;
89 private:
91 /** retrieves our table container
92 @return
93 our table container. Guaranteed to not be <NULL/>.
94 @throws css::lang::WrappedTargetException
95 if a non-RuntimeException is caught during obtaining the container.
96 @throws css::uno::RuntimeException
97 if a serious error occurs
98 @precond
99 We're not disposed.
101 css::uno::Reference< css::container::XNameAccess >
102 impl_getTableContainer_throw();
104 /** checks whether the given table name denotes an existing table
105 @param _rTableName
106 the fully name of the table to check for existence
107 @throws css::lang::IllegalArgumentException
108 if the name does not denote an existing table
109 @precond
110 We're not disposed.
112 void impl_checkExistingTable_throw( const OUString& _rTableName );
114 /** checks whether the given table name refers to a HSQL TEXT TABLE
116 bool impl_isTextTable_nothrow( const OUString& _rTableName );
118 /** retrieves the icon for HSQL TEXT TABLEs
120 css::uno::Reference< css::graphic::XGraphic >
121 impl_getTextTableIcon_nothrow();
125 // OHsqlConnection
127 class MethodGuard : public ::osl::MutexGuard
129 public:
130 MethodGuard( const IMethodGuardAccess& _rComponent )
131 : ::osl::MutexGuard( _rComponent.getMutex() )
133 _rComponent.checkDisposed();
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */