Files
ForeverCore/src/server/shared/Database/Transaction.h
T

64 lines
1.8 KiB
C++
Raw Normal View History

2010-10-07 13:38:35 +02:00
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* 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;
public:
~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-08-21 03:19:25 +02:00
size_t GetSize() { return m_queries.size(); }
protected:
void Cleanup();
2010-09-19 12:16:29 +02:00
std::queue<SQLElementData> m_queries;
2010-08-21 03:19:25 +02:00
private:
bool m_actioned;
};
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-08-21 03:19:25 +02:00
friend class DatabaseWorker;
public:
TransactionTask(SQLTransaction trans) : m_trans(trans) {} ;
~TransactionTask(){};
protected:
bool Execute();
SQLTransaction m_trans;
};
#endif