BACKENDS: Remove platform-specific defines and enforce factory design pattern for creating DLC store

This commit is contained in:
Ankush Dutt 2023-07-02 02:07:49 +05:30 committed by Eugene Sandulenko
parent 99af2be9c0
commit 045a99e50c
4 changed files with 33 additions and 4 deletions

View File

@ -22,6 +22,7 @@
#include "backends/dlc/android/playstore.h"
#include "backends/dlc/dlcmanager.h"
#include "common/system.h"
namespace Common {
@ -32,10 +33,7 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
DLCManager::DLCManager() {
// TODO: Implement Factory Design Pattern
#if defined(__ANDROID__)
_store = new DLC::PlayStore::PlayStore();
#endif
_store = g_system->getDLCStore();
}
void DLCManager::init() {

View File

@ -76,6 +76,8 @@
#include "backends/keymapper/keymapper-defaults.h"
#include "backends/keymapper/standard-actions.h"
#include "backends/dlc/android/playstore.h"
#include "common/util.h"
#include "common/textconsole.h"
#include "common/rect.h"
@ -221,6 +223,10 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
fsFactory.initSAF();
}
_fsFactory = &fsFactory;
// TODO: Create a new factory for Android, to assign it according to the Android's distribution store
// E.g. to handle the cases for: playstore, no store (apk on ScummVM website), amazon app store, etc.
_dlcStore = new DLC::PlayStore::PlayStore();
}
OSystem_Android::~OSystem_Android() {
@ -255,6 +261,9 @@ OSystem_Android::~OSystem_Android() {
delete _logger;
_logger = nullptr;
delete _dlcStore;
_dlcStore = nullptr;
}
void *OSystem_Android::timerThreadFunc(void *arg) {

View File

@ -56,6 +56,7 @@ OSystem::OSystem() {
_dialogManager = nullptr;
#endif
_fsFactory = nullptr;
_dlcStore = nullptr;
_backendInitialized = false;
}
@ -92,6 +93,9 @@ OSystem::~OSystem() {
delete _fsFactory;
_fsFactory = nullptr;
delete _dlcStore;
_dlcStore = nullptr;
}
void OSystem::initBackend() {

View File

@ -46,6 +46,10 @@ class GuiObject;
class OptionsContainerWidget;
}
namespace DLC {
class Store;
}
namespace Common {
class EventManager;
class MutexInternal;
@ -263,6 +267,11 @@ protected:
*/
FilesystemFactory *_fsFactory;
/**
* Used by the DLC Manager implementation
*/
DLC::Store *_dlcStore;
/**
* Used by the default clipboard implementation, for backends that don't
* implement clipboard support.
@ -1730,6 +1739,15 @@ public:
}
#endif
/**
* Return the DLC Store, used to implement DLC manager functions.
*
* @return The Store for the current distribution platform.
*/
virtual DLC::Store *getDLCStore() {
return _dlcStore;
}
/**
* Return the FilesystemFactory object, depending on the current architecture.
*