diff options
-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); |