diff options
author | Kevin Rocard <kevinx.rocard@intel.com> | 2013-07-11 12:42:23 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:04:06 +0100 |
commit | 6be8035935a21661833bddd3803e279652e81416 (patch) | |
tree | 9220d248ed548269fdb83b4307f1f71f533cf7fd /parameter | |
parent | ee7ceed5cca416718c70f3ca55fe41b8eb1e11a3 (diff) | |
download | external_parameter-framework-6be8035935a21661833bddd3803e279652e81416.zip external_parameter-framework-6be8035935a21661833bddd3803e279652e81416.tar.gz external_parameter-framework-6be8035935a21661833bddd3803e279652e81416.tar.bz2 |
Split subsystems loading
BZ: 122982
The CSystemClass::loadSubsystems was too long.
Create a subfunction to load subsystems defined in shared libraries.
Change-Id: I8f40ee271f25d0996e1976d8ee2ef6c12581d1d4
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/118192
Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
Diffstat (limited to 'parameter')
-rw-r--r-- | parameter/SystemClass.cpp | 68 | ||||
-rw-r--r-- | parameter/SystemClass.h | 12 |
2 files changed, 55 insertions, 25 deletions
diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index 8dd5f9c..5d435d7 100644 --- a/parameter/SystemClass.cpp +++ b/parameter/SystemClass.cpp @@ -75,10 +75,43 @@ string CSystemClass::getKind() const } bool CSystemClass::loadSubsystems(string& strError, - const CSubsystemPlugins* pSubsystemPlugins, bool bVirtualSubsystemFallback) + const CSubsystemPlugins* pSubsystemPlugins, + bool bVirtualSubsystemFallback) { CAutoLog autoLog_info(this, "Loading subsystem plugins"); + // Start clean + _pSubsystemLibrary->clean(); + + // Add virtual subsystem builder + _pSubsystemLibrary->addElementBuilder("Virtual", + new TNamedElementBuilderTemplate<CVirtualSubsystem>()); + // Set virtual subsytem as builder fallback if required + _pSubsystemLibrary->enableDefaultMechanism(bVirtualSubsystemFallback); + + // Add subsystem defined in shared libraries + list<string> lstrError; + bool bLoadPluginsSuccess = loadSubsystemsFromSharedLibraries(lstrError, pSubsystemPlugins); + + if (bLoadPluginsSuccess) { + log_info("All subsystem plugins successfully loaded"); + } else { + // Log plugin as warning if no fallback available + log_table(!bVirtualSubsystemFallback, lstrError); + } + + if (!bVirtualSubsystemFallback) { + // Any problem reported is an error as there is no fallback. + // Fill strError for caller. + CUtility::asString(lstrError, strError); + } + + return bLoadPluginsSuccess || bVirtualSubsystemFallback; +} + +bool CSystemClass::loadSubsystemsFromSharedLibraries(list<string>& lstrError, + const CSubsystemPlugins* pSubsystemPlugins) +{ // Plugin list list<string> lstrPluginFiles; @@ -103,13 +136,8 @@ bool CSystemClass::loadSubsystems(string& strError, } } - // Start clean - _pSubsystemLibrary->clean(); - list<string> lstrError; - - bool bLoadPluginsSuccess = true; // Actually load plugins - while (lstrPluginFiles.size()) { + while (!lstrPluginFiles.empty()) { // Because plugins might depend on one another, loading will be done // as an iteration process that finishes successfully when the remaining @@ -124,26 +152,16 @@ bool CSystemClass::loadSubsystems(string& strError, } } - if (lstrPluginFiles.empty()) { - log_info("All subsystem plugins successfully loaded"); - } else { - // Log plugin as warning if fallback available, error otherwise - log_table(bVirtualSubsystemFallback, lstrError); - } - if (!bVirtualSubsystemFallback) { - // Any problem reported is an error as there is no fallback. - // Fill strError for caller. - CUtility::asString(lstrError, strError); - } - - // Add virtual subsystem builder - _pSubsystemLibrary->addElementBuilder("Virtual", - new TNamedElementBuilderTemplate<CVirtualSubsystem>()); + if (!lstrPluginFiles.empty()) { + // Unable to load at least one plugin + string strPluginUnloaded; + CUtility::asString(lstrPluginFiles, strPluginUnloaded, ", "); - // Set virtual subsytem as builder fallback - _pSubsystemLibrary->enableDefaultMechanism(bVirtualSubsystemFallback); + lstrError.push_back("Unable to load the folowings plugings: " + strPluginUnloaded + "."); + return false; + } - return bLoadPluginsSuccess || bVirtualSubsystemFallback; + return true; } // Plugin symbol computation diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h index 3ff80e4..ee71e5f 100644 --- a/parameter/SystemClass.h +++ b/parameter/SystemClass.h @@ -78,6 +78,16 @@ private: // base virtual bool childrenAreDynamic() const; + /** Load shared libraries subsystem plugins. + * + * @param[out] lstrError is the list of error that occured during loadings. + * @param[in] pSubsystemPlugins The plugins to load. + * + * @return true if all plugins have been succesfully loaded, false otherwises. + */ + bool loadSubsystemsFromSharedLibraries(list<string>& lstrError, + const CSubsystemPlugins* pSubsystemPlugins); + // Plugin symbol computation static string getPluginSymbol(const string& strPluginPath); @@ -88,6 +98,8 @@ private: * @param[out] lstrError is the list of error that occured during loadings. * * @return true if at least one plugin has been succesfully loaded, false otherwise. + * When false is returned, some plugins MIHGT have been loaded + * but the lstrPluginFiles is accurate. */ bool loadPlugins(list<string>& lstrPluginFiles, list<string>& lstrError); |