Moved the db initialization code to a new header.

This commit is contained in:
Relintai 2020-12-01 15:01:02 +01:00
parent be8aac25aa
commit d713aeab8e
2 changed files with 32 additions and 23 deletions

30
database/db_init.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef DB_INIT_H
#define DB_INIT_H
#if MYSQL_PRESENT
#include "mysql/mysql_database.h"
#endif
#if PGSQL_PRESENT
#include "postgres/pgsql_database.h"
#endif
#if SQLITE_PRESENT
#include "sqlite/sqlite3_database.h"
#endif
void initialize_database_backends() {
#if MYSQL_PRESENT
MysqlDatabase::_register();
#endif
#if PGSQL_PRESENT
PGSQLDatabase::_register();
#endif
#if SQLITE_PRESENT
SQLite3Database::_register();
#endif
}
#endif

View File

@ -11,33 +11,12 @@
#include "core/database_manager.h" #include "core/database_manager.h"
#if MYSQL_PRESENT #include "database/db_init.h"
#include "database/mysql/mysql_database.h"
#endif
#if PGSQL_PRESENT
#include "database/postgres/pgsql_database.h"
#endif
#if SQLITE_PRESENT
#include "database/sqlite/sqlite3_database.h"
#endif
#define MAIN_CLASS RDNApplication #define MAIN_CLASS RDNApplication
int main(int argc, char **argv) { int main(int argc, char **argv) {
initialize_database_backends();
#if MYSQL_PRESENT
MysqlDatabase::_register();
#endif
#if PGSQL_PRESENT
PGSQLDatabase::_register();
#endif
#if SQLITE_PRESENT
SQLite3Database::_register();
#endif
FileCache *file_cache = new FileCache(true); FileCache *file_cache = new FileCache(true);
file_cache->wwwroot = "./www"; file_cache->wwwroot = "./www";