2010-10-07 15:54:07 +02:00
|
|
|
/*
|
2011-01-01 15:01:13 +01:00
|
|
|
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:54:07 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-08-21 03:19:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _TRANSACTION_H
|
|
|
|
|
#define _TRANSACTION_H
|
|
|
|
|
|
2010-09-02 17:47:50 +02:00
|
|
|
#include "SQLOperation.h"
|
|
|
|
|
|
2010-09-04 16:49:23 +02:00
|
|
|
//- Forward declare (don't include header to prevent circular includes)
|
|
|
|
|
class PreparedStatement;
|
|
|
|
|
|
2010-08-21 03:19:25 +02:00
|
|
|
/*! Transactions, high level class. */
|
|
|
|
|
class Transaction
|
|
|
|
|
{
|
|
|
|
|
friend class TransactionTask;
|
2011-01-13 20:07:09 +01:00
|
|
|
friend class MySQLConnection;
|
|
|
|
|
|
2010-08-21 03:19:25 +02:00
|
|
|
public:
|
2010-12-06 02:07:53 +01:00
|
|
|
Transaction() {}
|
2010-08-21 03:19:25 +02:00
|
|
|
~Transaction() { Cleanup(); }
|
|
|
|
|
|
2010-09-04 16:49:23 +02:00
|
|
|
void Append(PreparedStatement* statement);
|
2010-08-21 03:19:25 +02:00
|
|
|
void Append(const char* sql);
|
|
|
|
|
void PAppend(const char* sql, ...);
|
2010-09-12 01:40:27 +02:00
|
|
|
|
2010-12-23 16:05:43 +01:00
|
|
|
size_t GetSize() const { return m_queries.size(); }
|
2010-08-21 03:19:25 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void Cleanup();
|
2010-09-19 12:16:29 +02:00
|
|
|
std::queue<SQLElementData> m_queries;
|
2010-08-21 03:19:25 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
typedef ACE_Refcounted_Auto_Ptr<Transaction, ACE_Null_Mutex> SQLTransaction;
|
|
|
|
|
|
|
|
|
|
/*! Low level class*/
|
|
|
|
|
class TransactionTask : public SQLOperation
|
|
|
|
|
{
|
2010-09-02 17:47:50 +02:00
|
|
|
template <class T> friend class DatabaseWorkerPool;
|
2010-12-13 09:18:49 +01:00
|
|
|
friend class DatabaseWorker;
|
2011-01-26 00:41:55 +01:00
|
|
|
|
2010-08-21 03:19:25 +02:00
|
|
|
public:
|
|
|
|
|
TransactionTask(SQLTransaction trans) : m_trans(trans) {} ;
|
|
|
|
|
~TransactionTask(){};
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool Execute();
|
|
|
|
|
|
|
|
|
|
SQLTransaction m_trans;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|