diff --git a/database/db_init.h b/database/db_init.h new file mode 100644 index 0000000..c5cbd8c --- /dev/null +++ b/database/db_init.h @@ -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 \ No newline at end of file diff --git a/main.cpp b/main.cpp index b73a37b..c8c50b0 100644 --- a/main.cpp +++ b/main.cpp @@ -11,33 +11,12 @@ #include "core/database_manager.h" -#if MYSQL_PRESENT -#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 +#include "database/db_init.h" #define MAIN_CLASS RDNApplication int main(int argc, char **argv) { - -#if MYSQL_PRESENT - MysqlDatabase::_register(); -#endif - -#if PGSQL_PRESENT - PGSQLDatabase::_register(); -#endif - -#if SQLITE_PRESENT - SQLite3Database::_register(); -#endif + initialize_database_backends(); FileCache *file_cache = new FileCache(true); file_cache->wwwroot = "./www";