Cockatrice/cockatrice/src
BruebachL 5f4ad87a47
Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159)
* Refactor CardDatabase *db global variable to singleton CardDatabaseManager.

This commit refactors the global variable CardDatabase *db into a singleton encapsulated by the DatabaseManager class, accessible via DatabaseManager::getInstance(). This change centralizes access to the database instance, improving code modularity and encapsulation, resolving dependencies on main.h for code that requires access to the database instance.

- Added DatabaseManager class with getInstance() method returning a pointer to the singleton CardDatabase.
- Removed global db variable and updated references across the codebase.
 - Thread-safe static initialization for the singleton.

Impact: This refactor should have no functional impact on the application, as it maintains the same interface for accessing the CardDatabase instance. However, the codebase now benefits from improved encapsulation, lifetime management, and thread-safety.

* Refactor CardDatabase *db global variable to singleton CardDatabaseManager.

This commit refactors the global variable CardDatabase *db into a singleton encapsulated by the DatabaseManager class, accessible via DatabaseManager::getInstance(). This change centralizes access to the database instance, improving code modularity and encapsulation, resolving dependencies on main.h for code that requires access to the database instance.

- Added DatabaseManager class with getInstance() method returning a pointer to the singleton CardDatabase.
- Removed global db variable and updated references across the codebase.
 - Thread-safe static initialization for the singleton.

Impact: This refactor should have no functional impact on the application, as it maintains the same interface for accessing the CardDatabase instance. However, the codebase now benefits from improved encapsulation, lifetime management, and thread-safety.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2024-11-05 19:32:59 +01:00
..
client Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159) 2024-11-05 19:32:59 +01:00
deck Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159) 2024-11-05 19:32:59 +01:00
dialogs Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159) 2024-11-05 19:32:59 +01:00
game Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159) 2024-11-05 19:32:59 +01:00
server fix row colors swapping when using back button in replays (#5148) 2024-10-26 21:02:51 +00:00
settings Add keyboard shortcuts for skipping forward/backward in replays (#5140) 2024-10-23 14:00:23 +02:00
utility Add backwards support Qt6.7's checkStateChanged on QCheckBoxes (#5137) 2024-10-20 23:35:34 -04:00
main.cpp Refactor CardDatabase *db global variable to singleton CardDatabaseManager. (#5159) 2024-11-05 19:32:59 +01:00
main.h Add backwards support Qt6.7's checkStateChanged on QCheckBoxes (#5137) 2024-10-20 23:35:34 -04:00