LibreOffice Module connectivity (master) 1
ZConnectionWrapper.cxx
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
21
22using namespace connectivity;
23
24using namespace com::sun::star::uno;
25using namespace com::sun::star::lang;
26using namespace com::sun::star::beans;
27using namespace com::sun::star::sdbc;
28
29OConnectionWeakWrapper::OConnectionWeakWrapper(Reference< XAggregation >& _xConnection)
31{
32 setDelegation(_xConnection,m_refCount);
33 OSL_ENSURE(m_xConnection.is(),"OConnectionWeakWrapper: Connection must be valid!");
34}
35
37{
38 if ( !OConnectionWeakWrapper_BASE::rBHelper.bDisposed )
39 {
40 osl_atomic_increment( &m_refCount );
41 dispose();
42 }
43}
44// XServiceInfo
45
46IMPLEMENT_SERVICE_INFO(OConnectionWeakWrapper, "com.sun.star.sdbc.drivers.OConnectionWeakWrapper", "com.sun.star.sdbc.Connection")
47
48
49Reference< XStatement > SAL_CALL OConnectionWeakWrapper::createStatement( )
50{
51 ::osl::MutexGuard aGuard( m_aMutex );
52 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
53
54
55 return m_xConnection->createStatement();
56}
57
59{
60 ::osl::MutexGuard aGuard( m_aMutex );
61 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
62
63
64 return m_xConnection->prepareStatement(sql);
65}
66
68{
69 ::osl::MutexGuard aGuard( m_aMutex );
70 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
71
72
73 return m_xConnection->prepareCall(sql);
74}
75
76OUString SAL_CALL OConnectionWeakWrapper::nativeSQL( const OUString& sql )
77{
78 ::osl::MutexGuard aGuard( m_aMutex );
79 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
80
81
82 return m_xConnection->nativeSQL(sql);
83}
84
86{
87 ::osl::MutexGuard aGuard( m_aMutex );
88 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
89
90 m_xConnection->setAutoCommit(autoCommit);
91}
92
94{
95 ::osl::MutexGuard aGuard( m_aMutex );
96 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
97
98
99 return m_xConnection->getAutoCommit();
100}
101
103{
104 ::osl::MutexGuard aGuard( m_aMutex );
105 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
106
107
108 m_xConnection->commit();
109}
110
112{
113 ::osl::MutexGuard aGuard( m_aMutex );
114 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
115
116
117 m_xConnection->rollback();
118}
119
121{
122 ::osl::MutexGuard aGuard( m_aMutex );
123
124 return m_xConnection->isClosed();
125}
126
128{
129 ::osl::MutexGuard aGuard( m_aMutex );
130 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
131
132
133 return m_xConnection->getMetaData();
134}
135
137{
138 ::osl::MutexGuard aGuard( m_aMutex );
139 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
140
141
142 m_xConnection->setReadOnly(readOnly);
143}
144
146{
147 ::osl::MutexGuard aGuard( m_aMutex );
148 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
149
150
151 return m_xConnection->isReadOnly();
152}
153
154void SAL_CALL OConnectionWeakWrapper::setCatalog( const OUString& catalog )
155{
156 ::osl::MutexGuard aGuard( m_aMutex );
157 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
158
159
160 m_xConnection->setCatalog(catalog);
161}
162
164{
165 ::osl::MutexGuard aGuard( m_aMutex );
166 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
167
168
169 return m_xConnection->getCatalog();
170}
171
173{
174 ::osl::MutexGuard aGuard( m_aMutex );
175 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
176
177
178 m_xConnection->setTransactionIsolation(level);
179}
180
182{
183 ::osl::MutexGuard aGuard( m_aMutex );
184 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
185
186
187 return m_xConnection->getTransactionIsolation();
188}
189
191{
192 ::osl::MutexGuard aGuard( m_aMutex );
193 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
194
195
196 return m_xConnection->getTypeMap();
197}
198
200{
201 ::osl::MutexGuard aGuard( m_aMutex );
202 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
203
204
205 m_xConnection->setTypeMap(typeMap);
206}
207
208// XCloseable
210{
211 {
212 ::osl::MutexGuard aGuard( m_aMutex );
213 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
214
215 }
216 dispose();
217}
218
220{
221 ::osl::MutexGuard aGuard(m_aMutex);
222
223 OConnectionWeakWrapper_BASE::disposing();
225}
226
227// css::lang::XUnoTunnel
229
230css::uno::Any SAL_CALL OConnectionWeakWrapper::queryInterface( const css::uno::Type& _rType )
231{
232 css::uno::Any aReturn = OConnectionWeakWrapper_BASE::queryInterface( _rType );
233 if ( !aReturn.hasValue() )
234 aReturn = OConnectionWrapper::queryInterface( _rType );
235 return aReturn;
236}
237
239
240
241/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname)
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL setAutoCommit(sal_Bool autoCommit) override
virtual void SAL_CALL setCatalog(const OUString &catalog) override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString &sql) override
virtual void SAL_CALL close() override
virtual sal_Bool SAL_CALL isReadOnly() override
virtual sal_Bool SAL_CALL isClosed() override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setTypeMap(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual sal_Int32 SAL_CALL getTransactionIsolation() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString &sql) override
virtual void SAL_CALL setReadOnly(sal_Bool readOnly) override
virtual void SAL_CALL setTransactionIsolation(sal_Int32 level) override
virtual void SAL_CALL commit() override
virtual OUString SAL_CALL nativeSQL(const OUString &sql) override
virtual void SAL_CALL rollback() override
virtual OUString SAL_CALL getCatalog() override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap() override
virtual sal_Bool SAL_CALL getAutoCommit() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
void setDelegation(css::uno::Reference< css::uno::XAggregation > &_rxProxyConnection, oslInterlockedCount &_rRefCount)
css::uno::Reference< css::sdbc::XConnection > m_xConnection
mutable::osl::Mutex m_aMutex
ULONG m_refCount
std::mutex m_aMutex
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OHsqlConnection, OHsqlConnection_BASE, OConnectionWrapper)
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
::cppu::WeakComponentImplHelper< css::sdbc::XConnection > OConnectionWeakWrapper_BASE
void dispose()
Reference< XConnection > m_xConnection
unsigned char sal_Bool
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)