mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Database: Converted the database library to a shared library.
* There is still the possibility to static link against database.
(cherry picked from commit 6cfea2d8f7)
This commit is contained in:
@@ -47,6 +47,8 @@ target_include_directories(database
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_definitions(-DTRINITY_API_EXPORT_DATABASE)
|
||||
|
||||
target_link_libraries(database
|
||||
PUBLIC
|
||||
common
|
||||
@@ -58,6 +60,18 @@ set_target_properties(database
|
||||
FOLDER
|
||||
"server")
|
||||
|
||||
if( BUILD_SHARED_LIBS )
|
||||
if( UNIX )
|
||||
install(TARGETS database
|
||||
LIBRARY
|
||||
DESTINATION lib)
|
||||
elseif( WIN32 )
|
||||
install(TARGETS database
|
||||
RUNTIME
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Generate precompiled header
|
||||
if (USE_COREPCH)
|
||||
add_cxx_pch(database ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef std::future<QueryResult> QueryResultFuture;
|
||||
typedef std::promise<QueryResult> QueryResultPromise;
|
||||
|
||||
/*! Raw, ad-hoc query. */
|
||||
class BasicStatementTask : public SQLOperation
|
||||
class TC_DATABASE_API BasicStatementTask : public SQLOperation
|
||||
{
|
||||
public:
|
||||
BasicStatementTask(const char* sql, bool async = false);
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
#include "Implementation/WorldDatabase.h"
|
||||
|
||||
/// Accessor to the world database
|
||||
extern WorldDatabaseWorkerPool WorldDatabase;
|
||||
TC_DATABASE_API extern WorldDatabaseWorkerPool WorldDatabase;
|
||||
/// Accessor to the character database
|
||||
extern CharacterDatabaseWorkerPool CharacterDatabase;
|
||||
TC_DATABASE_API extern CharacterDatabaseWorkerPool CharacterDatabase;
|
||||
/// Accessor to the realm/login database
|
||||
extern LoginDatabaseWorkerPool LoginDatabase;
|
||||
TC_DATABASE_API extern LoginDatabaseWorkerPool LoginDatabase;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -177,9 +177,9 @@ bool DatabaseLoader::Process(std::queue<Predicate>& queue)
|
||||
return true;
|
||||
}
|
||||
|
||||
template
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<LoginDatabaseConnection>(DatabaseWorkerPool<LoginDatabaseConnection>& pool, std::string const& name);
|
||||
template
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<WorldDatabaseConnection>(DatabaseWorkerPool<WorldDatabaseConnection>& pool, std::string const& name);
|
||||
template
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<CharacterDatabaseConnection>(DatabaseWorkerPool<CharacterDatabaseConnection>& pool, std::string const& name);
|
||||
template TC_DATABASE_API
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<LoginDatabaseConnection>(LoginDatabaseWorkerPool&, std::string const&);
|
||||
template TC_DATABASE_API
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<CharacterDatabaseConnection>(CharacterDatabaseWorkerPool&, std::string const&);
|
||||
template TC_DATABASE_API
|
||||
DatabaseLoader& DatabaseLoader::AddDatabase<WorldDatabaseConnection>(WorldDatabaseWorkerPool&, std::string const&);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
// A helper class to initiate all database worker pools,
|
||||
// handles updating, delays preparing of statements and cleans up on failure.
|
||||
class DatabaseLoader
|
||||
class TC_DATABASE_API DatabaseLoader
|
||||
{
|
||||
public:
|
||||
DatabaseLoader(std::string const& logger, uint32 const defaultUpdateMask);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
class MySQLConnection;
|
||||
class SQLOperation;
|
||||
|
||||
class DatabaseWorker
|
||||
class TC_DATABASE_API DatabaseWorker
|
||||
{
|
||||
public:
|
||||
DatabaseWorker(ProducerConsumerQueue<SQLOperation*>* newQueue, MySQLConnection* connection);
|
||||
|
||||
@@ -317,6 +317,6 @@ T* DatabaseWorkerPool<T>::GetFreeConnection()
|
||||
return connection;
|
||||
}
|
||||
|
||||
template class DatabaseWorkerPool<LoginDatabaseConnection>;
|
||||
template class DatabaseWorkerPool<WorldDatabaseConnection>;
|
||||
template class DatabaseWorkerPool<CharacterDatabaseConnection>;
|
||||
template class TC_DATABASE_API DatabaseWorkerPool<LoginDatabaseConnection>;
|
||||
template class TC_DATABASE_API DatabaseWorkerPool<WorldDatabaseConnection>;
|
||||
template class TC_DATABASE_API DatabaseWorkerPool<CharacterDatabaseConnection>;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
| SUM, AVG | DECIMAL |
|
||||
| COUNT | BIGINT |
|
||||
*/
|
||||
class Field
|
||||
class TC_DATABASE_API Field
|
||||
{
|
||||
friend class ResultSet;
|
||||
friend class PreparedResultSet;
|
||||
|
||||
@@ -537,7 +537,7 @@ enum CharacterDatabaseStatements
|
||||
MAX_CHARACTERDATABASE_STATEMENTS
|
||||
};
|
||||
|
||||
class CharacterDatabaseConnection : public MySQLConnection
|
||||
class TC_DATABASE_API CharacterDatabaseConnection : public MySQLConnection
|
||||
{
|
||||
public:
|
||||
typedef CharacterDatabaseStatements Statements;
|
||||
|
||||
@@ -116,7 +116,7 @@ enum LoginDatabaseStatements
|
||||
MAX_LOGINDATABASE_STATEMENTS
|
||||
};
|
||||
|
||||
class LoginDatabaseConnection : public MySQLConnection
|
||||
class TC_DATABASE_API LoginDatabaseConnection : public MySQLConnection
|
||||
{
|
||||
public:
|
||||
typedef LoginDatabaseStatements Statements;
|
||||
|
||||
@@ -103,7 +103,7 @@ enum WorldDatabaseStatements
|
||||
MAX_WORLDDATABASE_STATEMENTS
|
||||
};
|
||||
|
||||
class WorldDatabaseConnection : public MySQLConnection
|
||||
class TC_DATABASE_API WorldDatabaseConnection : public MySQLConnection
|
||||
{
|
||||
public:
|
||||
typedef WorldDatabaseStatements Statements;
|
||||
|
||||
@@ -35,7 +35,7 @@ enum ConnectionFlags
|
||||
CONNECTION_BOTH = CONNECTION_ASYNC | CONNECTION_SYNCH
|
||||
};
|
||||
|
||||
struct MySQLConnectionInfo
|
||||
struct TC_DATABASE_API MySQLConnectionInfo
|
||||
{
|
||||
explicit MySQLConnectionInfo(std::string const& infoString)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ struct MySQLConnectionInfo
|
||||
|
||||
typedef std::map<uint32 /*index*/, std::pair<std::string /*query*/, ConnectionFlags /*sync/async*/> > PreparedStatementMap;
|
||||
|
||||
class MySQLConnection
|
||||
class TC_DATABASE_API MySQLConnection
|
||||
{
|
||||
template <class T> friend class DatabaseWorkerPool;
|
||||
friend class PingOperation;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
class MySQL
|
||||
class TC_DATABASE_API MySQL
|
||||
{
|
||||
public:
|
||||
static void Library_Init()
|
||||
|
||||
@@ -70,7 +70,7 @@ struct PreparedStatementData
|
||||
class MySQLPreparedStatement;
|
||||
|
||||
//- Upper-level class that is used in code
|
||||
class PreparedStatement
|
||||
class TC_DATABASE_API PreparedStatement
|
||||
{
|
||||
friend class PreparedStatementTask;
|
||||
friend class MySQLPreparedStatement;
|
||||
@@ -109,7 +109,7 @@ class PreparedStatement
|
||||
//- Class of which the instances are unique per MySQLConnection
|
||||
//- access to these class objects is only done when a prepared statement task
|
||||
//- is executed.
|
||||
class MySQLPreparedStatement
|
||||
class TC_DATABASE_API MySQLPreparedStatement
|
||||
{
|
||||
friend class MySQLConnection;
|
||||
friend class PreparedStatement;
|
||||
@@ -157,7 +157,7 @@ typedef std::future<PreparedQueryResult> PreparedQueryResultFuture;
|
||||
typedef std::promise<PreparedQueryResult> PreparedQueryResultPromise;
|
||||
|
||||
//- Lower-level class, enqueuable operation
|
||||
class PreparedStatementTask : public SQLOperation
|
||||
class TC_DATABASE_API PreparedStatementTask : public SQLOperation
|
||||
{
|
||||
public:
|
||||
PreparedStatementTask(PreparedStatement* stmt, bool async = false);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
class SQLQueryHolder
|
||||
class TC_DATABASE_API SQLQueryHolder
|
||||
{
|
||||
friend class SQLQueryHolderTask;
|
||||
private:
|
||||
@@ -46,7 +46,7 @@ class SQLQueryHolder
|
||||
typedef std::future<SQLQueryHolder*> QueryResultHolderFuture;
|
||||
typedef std::promise<SQLQueryHolder*> QueryResultHolderPromise;
|
||||
|
||||
class SQLQueryHolderTask : public SQLOperation
|
||||
class TC_DATABASE_API SQLQueryHolderTask : public SQLOperation
|
||||
{
|
||||
private:
|
||||
SQLQueryHolder* m_holder;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#endif
|
||||
#include <mysql.h>
|
||||
|
||||
class ResultSet
|
||||
class TC_DATABASE_API ResultSet
|
||||
{
|
||||
public:
|
||||
ResultSet(MYSQL_RES* result, MYSQL_FIELD* fields, uint64 rowCount, uint32 fieldCount);
|
||||
@@ -60,7 +60,7 @@ class ResultSet
|
||||
|
||||
typedef std::shared_ptr<ResultSet> QueryResult;
|
||||
|
||||
class PreparedResultSet
|
||||
class TC_DATABASE_API PreparedResultSet
|
||||
{
|
||||
public:
|
||||
PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES* result, uint64 rowCount, uint32 fieldCount);
|
||||
|
||||
@@ -53,7 +53,7 @@ union SQLResultSetUnion
|
||||
|
||||
class MySQLConnection;
|
||||
|
||||
class SQLOperation
|
||||
class TC_DATABASE_API SQLOperation
|
||||
{
|
||||
public:
|
||||
SQLOperation(): m_conn(NULL) { }
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
class PreparedStatement;
|
||||
|
||||
/*! Transactions, high level class. */
|
||||
class Transaction
|
||||
class TC_DATABASE_API Transaction
|
||||
{
|
||||
friend class TransactionTask;
|
||||
friend class MySQLConnection;
|
||||
@@ -58,7 +58,7 @@ class Transaction
|
||||
typedef std::shared_ptr<Transaction> SQLTransaction;
|
||||
|
||||
/*! Low level class*/
|
||||
class TransactionTask : public SQLOperation
|
||||
class TC_DATABASE_API TransactionTask : public SQLOperation
|
||||
{
|
||||
template <class T> friend class DatabaseWorkerPool;
|
||||
friend class DatabaseWorker;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "Appender.h"
|
||||
|
||||
class AppenderDB: public Appender
|
||||
class TC_DATABASE_API AppenderDB: public Appender
|
||||
{
|
||||
public:
|
||||
typedef std::integral_constant<AppenderType, APPENDER_DB>::type TypeIndex;
|
||||
|
||||
@@ -436,6 +436,6 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
||||
}
|
||||
}
|
||||
|
||||
template class DBUpdater<LoginDatabaseConnection>;
|
||||
template class DBUpdater<WorldDatabaseConnection>;
|
||||
template class DBUpdater<CharacterDatabaseConnection>;
|
||||
template class TC_DATABASE_API DBUpdater<LoginDatabaseConnection>;
|
||||
template class TC_DATABASE_API DBUpdater<WorldDatabaseConnection>;
|
||||
template class TC_DATABASE_API DBUpdater<CharacterDatabaseConnection>;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
class UpdateException : public std::exception
|
||||
class TC_DATABASE_API UpdateException : public std::exception
|
||||
{
|
||||
public:
|
||||
UpdateException(std::string const& msg) : _msg(msg) { }
|
||||
@@ -41,7 +41,7 @@ enum BaseLocation
|
||||
LOCATION_DOWNLOAD
|
||||
};
|
||||
|
||||
struct UpdateResult
|
||||
struct TC_DATABASE_API UpdateResult
|
||||
{
|
||||
UpdateResult()
|
||||
: updated(0), recent(0), archived(0) { }
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class DBUpdater
|
||||
class TC_DATABASE_API DBUpdater
|
||||
{
|
||||
public:
|
||||
using Path = boost::filesystem::path;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class UpdateFetcher
|
||||
class TC_DATABASE_API UpdateFetcher
|
||||
{
|
||||
typedef boost::filesystem::path Path;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user