2022-07-22 10:16:49 +02:00
|
|
|
#ifndef USER_MANAGER_DB_H
|
|
|
|
#define USER_MANAGER_DB_H
|
|
|
|
|
|
|
|
#include "core/os/rw_lock.h"
|
2022-08-17 13:45:14 +02:00
|
|
|
#include "core/object/reference.h"
|
2022-08-17 14:19:55 +02:00
|
|
|
#include "core/string/ustring.h"
|
2022-08-17 12:53:49 +02:00
|
|
|
#include "core/containers/vector.h"
|
2022-07-22 10:16:49 +02:00
|
|
|
|
|
|
|
#include "user_manager.h"
|
|
|
|
|
|
|
|
class User;
|
2022-07-24 16:26:23 +02:00
|
|
|
class Database;
|
|
|
|
class TableBuilder;
|
|
|
|
class QueryBuilder;
|
|
|
|
class DatabaseConnection;
|
2022-07-22 10:16:49 +02:00
|
|
|
|
|
|
|
class UserManagerDB : public UserManager {
|
|
|
|
GDCLASS(UserManagerDB, UserManager);
|
|
|
|
|
|
|
|
public:
|
2022-07-24 16:26:23 +02:00
|
|
|
String get_database_table_name();
|
|
|
|
void set_database_table_name(const String &val);
|
|
|
|
|
|
|
|
Ref<Database> get_database();
|
|
|
|
void set_database(const Ref<Database> &db);
|
|
|
|
|
|
|
|
Ref<DatabaseConnection> get_database_connection();
|
|
|
|
Ref<TableBuilder> get_table_builder();
|
|
|
|
Ref<QueryBuilder> get_query_builder();
|
|
|
|
|
2022-07-22 10:16:49 +02:00
|
|
|
Ref<User> _get_user(const int id);
|
|
|
|
Ref<User> _get_user_name(const String &user);
|
|
|
|
void _save_user(Ref<User> user);
|
|
|
|
|
|
|
|
Ref<User> _create_user();
|
|
|
|
|
|
|
|
bool _is_username_taken(const String &user_name);
|
|
|
|
bool _is_email_taken(const String &email);
|
|
|
|
|
|
|
|
Vector<Ref<User>> get_all();
|
|
|
|
|
2022-07-24 16:26:23 +02:00
|
|
|
void create_table();
|
|
|
|
void drop_table();
|
2023-09-22 16:21:37 +02:00
|
|
|
void update_table(const int p_current_table_version);
|
2022-07-24 16:26:23 +02:00
|
|
|
void create_default_entries(const int p_seed);
|
|
|
|
|
|
|
|
virtual void _create_table();
|
|
|
|
virtual void _drop_table();
|
2023-09-22 16:21:37 +02:00
|
|
|
virtual void _update_table(const int p_current_table_version);
|
2022-07-24 16:26:23 +02:00
|
|
|
virtual void _create_default_entries(const int p_seed);
|
|
|
|
|
|
|
|
void migrate(const bool p_clear, const bool p_should_seed, const int p_seed);
|
|
|
|
virtual void _migrate(const bool p_clear, const bool p_should_seed, const int p_seed);
|
2022-07-22 10:16:49 +02:00
|
|
|
|
|
|
|
UserManagerDB();
|
|
|
|
~UserManagerDB();
|
|
|
|
|
|
|
|
protected:
|
2022-07-24 16:26:23 +02:00
|
|
|
void _notification(const int what);
|
|
|
|
|
2022-07-22 10:16:49 +02:00
|
|
|
static void _bind_methods();
|
2022-07-24 16:26:23 +02:00
|
|
|
|
|
|
|
String _database_table_name;
|
|
|
|
Ref<Database> _database;
|
2022-07-22 10:16:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|