From 88c73791cfa55337a0e6565fc7e7009c8f0690ef Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Mon, 26 Jan 2009 18:40:37 -0500 Subject: [PATCH] Complete singleton pattern for the plugin manager --- src/plug-in/pluginmanager.cpp | 9 +++++++++ src/plug-in/pluginmanager.h | 10 +++++----- test/audiorecorderTest.cpp | 6 ++---- test/pluginmanagerTest.cpp | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/plug-in/pluginmanager.cpp b/src/plug-in/pluginmanager.cpp index 6012a59bde..df88799a80 100644 --- a/src/plug-in/pluginmanager.cpp +++ b/src/plug-in/pluginmanager.cpp @@ -13,6 +13,15 @@ _instance = 0; } +::sflphone::PluginManager* ::sflphone::PluginManager::instance() +{ + if(! _instance ){ + _instance = new PluginManager(); + } + return _instance; +} + + int ::sflphone::PluginManager::loadPlugins( const std::string &path ) { std::string pluginDir, current; diff --git a/src/plug-in/pluginmanager.h b/src/plug-in/pluginmanager.h index 651a0902f8..78d988cd0c 100644 --- a/src/plug-in/pluginmanager.h +++ b/src/plug-in/pluginmanager.h @@ -17,11 +17,6 @@ namespace sflphone { class PluginManager { public: - /** - * Default constructor - */ - PluginManager(); - /** * Destructor */ @@ -47,6 +42,11 @@ namespace sflphone { Plugin* isPluginLoaded( const std::string &name ); private: + /** + * Default constructor + */ + PluginManager(); + /** * Load a unix dynamic/shared library * @param filename The path to the dynamic/shared library diff --git a/test/audiorecorderTest.cpp b/test/audiorecorderTest.cpp index 8a9327cb5b..f766d4af1d 100644 --- a/test/audiorecorderTest.cpp +++ b/test/audiorecorderTest.cpp @@ -43,12 +43,10 @@ void AudioRecorderTest::testRecordData(){ for (SFLDataFormat i = -32768; i < 32767; i++ ){ buf[0] = i; buf[1] = i; - recAudio.recData(buf,2); + _ar->recData(buf,2); } - recAudio.closeFile(); - - + _ar->closeFile(); } void AudioRecorderTest::tearDown(){ diff --git a/test/pluginmanagerTest.cpp b/test/pluginmanagerTest.cpp index b9a3d413a4..e5dfff8e11 100644 --- a/test/pluginmanagerTest.cpp +++ b/test/pluginmanagerTest.cpp @@ -27,7 +27,7 @@ using std::endl; void PluginManagerTest::setUp(){ // Instanciate the plugin manager object - _pm = new ::sflphone::PluginManager(); + _pm = ::sflphone::PluginManager::instance(); } void PluginManagerTest::testLoadPluginDirectory(){ -- GitLab