From aff61f16b0ba6b08078410d6ea11629bb9848d7e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 28 Feb 2009 15:55:22 +0100 Subject: [PATCH] Replaced global ResourcesDB with a global UnifiedResourcesProvider which allows to add several resource directories or online resources. --- include/engine.h | 48 ++++++++++++++++++++++----------------------- src/core/engine.cpp | 32 +++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/include/engine.h b/include/engine.h index 0dc077463..bf083b4a6 100644 --- a/include/engine.h +++ b/include/engine.h @@ -1,7 +1,7 @@ /* * engine.h - engine-system of LMMS * - * Copyright (c) 2006-2008 Tobias Doerffel + * Copyright (c) 2006-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -44,7 +44,7 @@ class mainWindow; class mixer; class pianoRoll; class projectNotes; -class ResourcesDB; +class UnifiedResourcesProvider; class song; class songEditor; class ladspa2LMMS; @@ -59,7 +59,7 @@ public: static bool hasGUI( void ) { - return( s_hasGUI ); + return s_hasGUI; } static void setSuppressMessages( bool _on ) @@ -75,94 +75,94 @@ public: // core static mixer * getMixer( void ) { - return( s_mixer ); + return s_mixer; } static fxMixer * getFxMixer( void ) { - return( s_fxMixer ); + return s_fxMixer; } static song * getSong( void ) { - return( s_song ); + return s_song; } static bbTrackContainer * getBBTrackContainer( void ) { - return( s_bbTrackContainer ); + return s_bbTrackContainer; } static projectJournal * getProjectJournal( void ) { - return( s_projectJournal ); + return s_projectJournal; } - static ResourcesDB * getResourcesDB( void ) + static UnifiedResourcesProvider * getResourcesProvider( void ) { - return( s_resourcesDB ); + return s_resourcesProvider; } // GUI static mainWindow * getMainWindow( void ) { - return( s_mainWindow ); + return s_mainWindow; } static fxMixerView * getFxMixerView( void ) { - return( s_fxMixerView ); + return s_fxMixerView; } static songEditor * getSongEditor( void ) { - return( s_songEditor ); + return s_songEditor; } static bbEditor * getBBEditor( void ) { - return( s_bbEditor ); + return s_bbEditor; } static pianoRoll * getPianoRoll( void ) { - return( s_pianoRoll ); + return s_pianoRoll; } static projectNotes * getProjectNotes( void ) { - return( s_projectNotes ); + return s_projectNotes; } static automationEditor * getAutomationEditor( void ) { - return( s_automationEditor ); + return s_automationEditor; } static ladspa2LMMS * getLADSPAManager( void ) { - return( s_ladspaManager ); + return s_ladspaManager; } static dummyTrackContainer * getDummyTrackContainer( void ) { - return( s_dummyTC ); + return s_dummyTC; } static controllerRackView * getControllerRackView( void ) { - return( s_controllerRackView ); + return s_controllerRackView; } static float framesPerTick( void ) { - return( s_framesPerTick ); + return s_framesPerTick; } static void updateFramesPerTick( void ); static const QMap & pluginFileHandling( void ) { - return( s_pluginFileHandling ); + return s_pluginFileHandling; } static void setLmmsStyle( LmmsStyle * _style ) @@ -184,7 +184,7 @@ private: static mixer * s_mixer; static fxMixer * s_fxMixer; static song * s_song; - static ResourcesDB * s_resourcesDB; + static UnifiedResourcesProvider * s_resourcesProvider; static bbTrackContainer * s_bbTrackContainer; static projectJournal * s_projectJournal; static dummyTrackContainer * s_dummyTC; @@ -200,7 +200,7 @@ private: static projectNotes * s_projectNotes; static ladspa2LMMS * s_ladspaManager; - static LmmsStyle * s_lmmsStyle; + static LmmsStyle * s_lmmsStyle; static QMap s_pluginFileHandling; diff --git a/src/core/engine.cpp b/src/core/engine.cpp index cfeaf9273..ec750e7b8 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -3,7 +3,7 @@ /* * engine.cpp - implementation of LMMS' engine-system * - * Copyright (c) 2006-2008 Tobias Doerffel + * Copyright (c) 2006-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -35,7 +35,6 @@ #include "fx_mixer.h" #include "fx_mixer_view.h" #include "ladspa_2_lmms.h" -#include "local_resources_provider.h" #include "main_window.h" #include "mixer.h" #include "pattern.h" @@ -43,10 +42,13 @@ #include "preset_preview_play_handle.h" #include "project_journal.h" #include "project_notes.h" -#include "resources_db.h" #include "song_editor.h" #include "song.h" +#include "resources_db.h" +#include "local_resources_provider.h" +#include "unified_resources_provider.h" + bool engine::s_hasGUI = true; bool engine::s_suppressMessages = false; @@ -57,7 +59,7 @@ fxMixerView * engine::s_fxMixerView = NULL; mainWindow * engine::s_mainWindow = NULL; bbTrackContainer * engine::s_bbTrackContainer = NULL; song * engine::s_song = NULL; -ResourcesDB * engine::s_resourcesDB = NULL; +UnifiedResourcesProvider * engine::s_resourcesProvider = NULL; songEditor * engine::s_songEditor = NULL; automationEditor * engine::s_automationEditor = NULL; bbEditor * engine::s_bbEditor = NULL; @@ -83,9 +85,21 @@ void engine::init( const bool _has_gui ) s_mixer = new mixer; s_song = new song; - LocalResourcesProvider * resProv = - new LocalResourcesProvider( ResourcesItem::BaseWorkingDir, QString() ); - s_resourcesDB = resProv->database(); + + // init resources framework + LocalResourcesProvider * workingDirResources = + new LocalResourcesProvider( ResourcesItem::BaseWorkingDir, + QString() ); + LocalResourcesProvider * shippedResources = + new LocalResourcesProvider( ResourcesItem::BaseDataDir, + QString() ); + UnifiedResourcesProvider * unifiedResources = + new UnifiedResourcesProvider; + unifiedResources->addDatabase( workingDirResources->database() ); + unifiedResources->addDatabase( shippedResources->database() ); + + s_resourcesProvider = unifiedResources; + s_fxMixer = new fxMixer; s_bbTrackContainer = new bbTrackContainer; @@ -161,8 +175,8 @@ void engine::destroy( void ) delete s_song; s_song = NULL; - delete s_resourcesDB; - s_resourcesDB = NULL; + delete s_resourcesProvider; + s_resourcesProvider = NULL; delete configManager::inst(); }