summaryrefslogtreecommitdiffstats
path: root/parameter/SystemClass.cpp
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2013-07-11 12:42:23 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:04:06 +0100
commit6be8035935a21661833bddd3803e279652e81416 (patch)
tree9220d248ed548269fdb83b4307f1f71f533cf7fd /parameter/SystemClass.cpp
parentee7ceed5cca416718c70f3ca55fe41b8eb1e11a3 (diff)
downloadexternal_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/SystemClass.cpp')
-rw-r--r--parameter/SystemClass.cpp68
1 files changed, 43 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