Added initialized signal and helper method to the DataBaseManager. It can be used to let automally allocated classes (singletons, main scene classes) in heavily database driven applications know when it's safe to use the db.

This commit is contained in:
Relintai 2022-12-24 11:45:13 +01:00
parent b83c4f7ff8
commit dacee1ae4f
2 changed files with 7 additions and 0 deletions

View File

@ -56,6 +56,10 @@ Vector<Variant> DatabaseManager::get_databases_bind() {
return r;
}
void DatabaseManager::initialized() {
emit_signal("initialized");
}
void DatabaseManager::load() {
//go thourgh settings, and create all the defined db backends
//add them to ProjectSettings
@ -78,6 +82,7 @@ DatabaseManager::~DatabaseManager() {
}
void DatabaseManager::_bind_methods() {
ADD_SIGNAL(MethodInfo("initialized"));
ADD_SIGNAL(MethodInfo("migration", PropertyInfo(Variant::BOOL, "clear"), PropertyInfo(Variant::BOOL, "should_seed"), PropertyInfo(Variant::INT, "pseed")));
ADD_SIGNAL(MethodInfo("default_database_changed", PropertyInfo(Variant::OBJECT, "db", PROPERTY_HINT_RESOURCE_TYPE, "Database")));
@ -95,6 +100,7 @@ void DatabaseManager::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_databases"), &DatabaseManager::get_databases_bind);
ClassDB::bind_method(D_METHOD("initialized"), &DatabaseManager::initialized);
ClassDB::bind_method(D_METHOD("load"), &DatabaseManager::load);
ClassDB::bind_method(D_METHOD("migrate", "clear", "should_seed", "pseed"), &DatabaseManager::migrate);

View File

@ -25,6 +25,7 @@ public:
Vector<Ref<Database>> get_databases();
Vector<Variant> get_databases_bind();
void initialized();
void load();
void migrate(const bool p_clear, const bool p_should_seed, const int p_seed);