File indexing completed on 2024-10-13 07:14:09

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003-2017 Jarosław Staniek <staniek@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KDB_TRANSACTIONDATA_H
0021 #define KDB_TRANSACTIONDATA_H
0022 
0023 #include "config-kdb.h"
0024 #include "kdb_export.h"
0025 
0026 #include <QtGlobal>
0027 
0028 class KDbConnection;
0029 
0030 /**
0031  * @brief Internal prototype for storing transaction handle for KDbTransaction object
0032  *
0033  * Only for driver developers. Teimplement this class for database driver that supports transactions.
0034  */
0035 class KDB_EXPORT KDbTransactionData
0036 {
0037 public:
0038     explicit KDbTransactionData(KDbConnection *connection);
0039 
0040     ~KDbTransactionData();
0041 
0042     //! Increments the value of reference counter for this data.
0043     void ref();
0044 
0045     //! Decrements the value of reference counter for this data.
0046     void deref();
0047 
0048     //! @return value of reference counter for this data.
0049     int refcount() const;
0050 
0051     //! @return "active" flag of this data
0052     bool isActive() const;
0053 
0054     //! Sets "active" flag of this data
0055     void setActive(bool set);
0056 
0057     //! @return connection for this data
0058     KDbConnection *connection();
0059 
0060     //! @overload
0061     //! @since 3.1
0062     const KDbConnection *connection() const;
0063 
0064 #ifdef KDB_TRANSACTIONS_DEBUG
0065     //! Helper for debugging, returns value of global transaction data reference counter
0066     static int globalCount();
0067 #endif
0068 
0069 private:
0070     Q_DISABLE_COPY(KDbTransactionData)
0071     class Private;
0072     Private * const d;
0073 };
0074 
0075 #endif