feat(Cmake/Database): separate database lib from common (#5334)

* feat(Core/Database): separate databse lib from common

* 1
This commit is contained in:
Kargatum
2021-04-20 17:08:23 +07:00
committed by GitHub
parent 47378ad14d
commit a278fd7340
39 changed files with 82 additions and 8 deletions

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#ifndef _TRANSACTION_H
#define _TRANSACTION_H
#include <utility>
#include "SQLOperation.h"
//- Forward declare (don't include header to prevent circular includes)
class PreparedStatement;
/*! Transactions, high level class. */
class Transaction
{
friend class TransactionTask;
friend class MySQLConnection;
template <typename T>
friend class DatabaseWorkerPool;
public:
Transaction() { }
~Transaction() { Cleanup(); }
void Append(PreparedStatement* statement);
void Append(const char* sql);
void PAppend(const char* sql, ...);
[[nodiscard]] size_t GetSize() const { return m_queries.size(); }
protected:
void Cleanup();
std::list<SQLElementData> m_queries;
private:
bool _cleanedUp{false};
};
typedef std::shared_ptr<Transaction> SQLTransaction;
/*! Low level class*/
class TransactionTask : public SQLOperation
{
template <class T> friend class DatabaseWorkerPool;
friend class DatabaseWorker;
public:
TransactionTask(SQLTransaction trans) : m_trans(std::move(trans)) { } ;
~TransactionTask() override = default;
protected:
bool Execute() override;
SQLTransaction m_trans;
};
#endif