Renamed the database classes to be inline with the new naming scheme.

This commit is contained in:
Relintai 2020-12-01 14:56:05 +01:00
parent e3338f9d3b
commit 35bd94de7e
10 changed files with 24 additions and 24 deletions

View File

@ -1 +0,0 @@
#include "mysql_connection.h"

View File

@ -0,0 +1 @@
#include "mysql_database.h"

View File

@ -12,24 +12,24 @@
#include <mysql.h> #include <mysql.h>
class MysqlConnection : public Database { class MysqlDatabase : public Database {
public: public:
static Database *_creation_func() { static Database *_creation_func() {
return new MysqlConnection(); return new MysqlDatabase();
} }
static void _register() { static void _register() {
DatabaseManager::_register_db_creation_func("mysql", MysqlConnection::_creation_func); DatabaseManager::_register_db_creation_func("mysql", MysqlDatabase::_creation_func);
} }
static void _unregister() { static void _unregister() {
DatabaseManager::_unregister_db_creation_func("mysql"); DatabaseManager::_unregister_db_creation_func("mysql");
} }
MysqlConnection() : Database() { MysqlDatabase() : Database() {
mysql = new MYSQL(); mysql = new MYSQL();
} }
~MysqlConnection() { ~MysqlDatabase() {
delete mysql; delete mysql;
} }

View File

@ -1 +0,0 @@
#include "pgsql_connection.h"

View File

@ -0,0 +1 @@
#include "pgsql_database.h"

View File

@ -12,24 +12,24 @@
#include <libpq-fe.h> #include <libpq-fe.h>
class PGSQLConnection : public Database { class PGSQLDatabase : public Database {
public: public:
static Database *_creation_func() { static Database *_creation_func() {
return new PGSQLConnection(); return new PGSQLDatabase();
} }
static void _register() { static void _register() {
DatabaseManager::_register_db_creation_func("pgsql", PGSQLConnection::_creation_func); DatabaseManager::_register_db_creation_func("pgsql", PGSQLDatabase::_creation_func);
} }
static void _unregister() { static void _unregister() {
DatabaseManager::_unregister_db_creation_func("pgsql"); DatabaseManager::_unregister_db_creation_func("pgsql");
} }
PGSQLConnection() : Database() { PGSQLDatabase() : Database() {
conn = PQconnectStart(""); conn = PQconnectStart("");
} }
~PGSQLConnection() { ~PGSQLDatabase() {
PQfinish(conn); PQfinish(conn);
} }

View File

@ -1 +0,0 @@
#include "sqlite3_connection.h"

View File

@ -0,0 +1 @@
#include "sqlite3_database.h"

View File

@ -14,21 +14,21 @@
#include <sqlite3.h> #include <sqlite3.h>
class SQLite3Connection : public Database { class SQLite3Database : public Database {
public: public:
static Database *_creation_func() { static Database *_creation_func() {
return new SQLite3Connection(); return new SQLite3Database();
} }
static void _register() { static void _register() {
DatabaseManager::_register_db_creation_func("sqlite", SQLite3Connection::_creation_func); DatabaseManager::_register_db_creation_func("sqlite", SQLite3Database::_creation_func);
} }
static void _unregister() { static void _unregister() {
DatabaseManager::_unregister_db_creation_func("sqlite"); DatabaseManager::_unregister_db_creation_func("sqlite");
} }
SQLite3Connection() : SQLite3Database() :
Database() { Database() {
int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
@ -39,7 +39,7 @@ public:
ret = sqlite3_open("", &conn); ret = sqlite3_open("", &conn);
} }
~SQLite3Connection() { ~SQLite3Database() {
sqlite3_close(conn); sqlite3_close(conn);
} }

View File

@ -12,15 +12,15 @@
#include "core/database_manager.h" #include "core/database_manager.h"
#if MYSQL_PRESENT #if MYSQL_PRESENT
#include "database/mysql/mysql_connection.h" #include "database/mysql/mysql_database.h"
#endif #endif
#if PGSQL_PRESENT #if PGSQL_PRESENT
#include "database/postgres/pgsql_connection.h" #include "database/postgres/pgsql_database.h"
#endif #endif
#if SQLITE_PRESENT #if SQLITE_PRESENT
#include "database/sqlite/sqlite3_connection.h" #include "database/sqlite/sqlite3_database.h"
#endif #endif
#define MAIN_CLASS RDNApplication #define MAIN_CLASS RDNApplication
@ -29,17 +29,17 @@ int main(int argc, char **argv) {
#if MYSQL_PRESENT #if MYSQL_PRESENT
printf("mysql present\n"); printf("mysql present\n");
MysqlConnection::_register(); MysqlDatabase::_register();
#endif #endif
#if PGSQL_PRESENT #if PGSQL_PRESENT
printf("pgsql present\n"); printf("pgsql present\n");
PGSQLConnection::_register(); PGSQLDatabase::_register();
#endif #endif
#if SQLITE_PRESENT #if SQLITE_PRESENT
printf("sqlite present\n"); printf("sqlite present\n");
SQLite3Connection::_register(); SQLite3Database::_register();
#endif #endif
FileCache *file_cache = new FileCache(true); FileCache *file_cache = new FileCache(true);