diff options
-rw-r--r-- | parameter/ParameterMgr.cpp | 35 | ||||
-rw-r--r-- | parameter/ParameterMgr.h | 23 | ||||
-rw-r--r-- | parameter/ParameterMgrPlatformConnector.cpp | 18 | ||||
-rw-r--r-- | parameter/include/ParameterMgrPlatformConnector.h | 18 |
4 files changed, 89 insertions, 5 deletions
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 927515c..59dc057 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -281,7 +281,8 @@ CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) : _uiMaxCommandUsageLength(0), _pLogger(NULL), _uiLogDepth(0), - _bFailOnMissingSubsystem(true) + _bFailOnMissingSubsystem(true), + _bFailOnFailedSettingsLoad(true) { // Tuning Mode Mutex bzero(&_blackboardMutex, sizeof(_blackboardMutex)); @@ -537,6 +538,27 @@ bool CParameterMgr::loadStructure(string& strError) bool CParameterMgr::loadSettings(string& strError) { + string strLoadError; + bool success = loadSettingsFromConfigFile(strLoadError); + + if (!success && !_bFailOnFailedSettingsLoad) { + // Load can not fail, ie continue but log the load errors + log_info(strLoadError); + log_info("Failed to load settings, continue without domains."); + success = true; + } + + if (!success) { + // Propagate the litteral error only if the function fails + strError = strLoadError; + return false; + } + + return true; +} + +bool CParameterMgr::loadSettingsFromConfigFile(string& strError) +{ CAutoLog autoLog(this, "Loading settings"); // Get settings configuration element @@ -567,7 +589,7 @@ bool CParameterMgr::loadSettings(string& strError) strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); return false; - } + } // Get destination root element CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); @@ -737,6 +759,15 @@ bool CParameterMgr::getFailureOnMissingSubsystem() const { return _bFailOnMissingSubsystem; } + +void CParameterMgr::setFailureOnFailedSettingsLoad(bool bFail) +{ + _bFailOnFailedSettingsLoad = bFail; +} +bool CParameterMgr::getFailureOnFailedSettingsLoad() +{ + return _bFailOnFailedSettingsLoad; +} /////////////////// Remote command parsers /// Version CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 9145c4e..1f738fe 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -138,10 +138,9 @@ public: CParameterHandle* createParameterHandle(const string& strPath, string& strError); /** Should start fail in case of missing subsystems. - * Will fail if called on started instance. * - * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems - * If set to false, missing subsystems will fallback on virtual subsystem + * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems. + * If set to false, missing subsystems will fallback on virtual subsystem. */ void setFailureOnMissingSubsystem(bool bFail); @@ -151,6 +150,18 @@ public: */ bool getFailureOnMissingSubsystem() const; + /** Should start fail in failed settings load. + * + * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load. + * If set to false, failed settings load will be ignored. + */ + void setFailureOnFailedSettingsLoad(bool bFail); + /** Would start fail in case of failed settings load. + * + * @return failure on failed settings load policy state. + */ + bool getFailureOnFailedSettingsLoad(); + //////////// Tuning ///////////// // Tuning mode bool setTuningMode(bool bOn, string& strError); @@ -395,6 +406,7 @@ private: // System class Structure loading bool loadSettings(string& strError); + bool loadSettingsFromConfigFile(string& strError); // Parse XML file into Root element bool xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, ElementLibrary eElementLibrary, const string& strNameAttrituteName = "Name"); @@ -483,5 +495,10 @@ private: * If set to false, missing subsystem will fallback on virtual subsystem. */ bool _bFailOnMissingSubsystem; + /** If set to true, unparsable or discording domains will abort parameterMgr start. + * If set to false, unparsable or discording domains + * will continue the parameterMgr start with no domains. + */ + bool _bFailOnFailedSettingsLoad; }; diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index d8b3936..aa1f8a1 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -103,6 +103,24 @@ bool CParameterMgrPlatformConnector::getFailureOnMissingSubsystem() return _pParameterMgr->getFailureOnMissingSubsystem(); } +bool CParameterMgrPlatformConnector::setFailureOnFailedSettingsLoad( + bool bFail, std::string& strError) +{ + if (_bStarted) { + + strError = "Can not set failure on failed settings load policy while running"; + return false; + } + + _pParameterMgr->setFailureOnFailedSettingsLoad(bFail); + return true; +} + +bool CParameterMgrPlatformConnector::getFailureOnFailedSettingsLoad() +{ + return _pParameterMgr->getFailureOnFailedSettingsLoad(); +} + // Start bool CParameterMgrPlatformConnector::start(string& strError) { diff --git a/parameter/include/ParameterMgrPlatformConnector.h b/parameter/include/ParameterMgrPlatformConnector.h index 50c1212..ee22b48 100644 --- a/parameter/include/ParameterMgrPlatformConnector.h +++ b/parameter/include/ParameterMgrPlatformConnector.h @@ -73,6 +73,7 @@ public: /** Should start fail in case of missing subsystems. * * Will fail if called on started instance. + * * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems * If set to false, missing subsystems will fallbacks on virtual subsystem * @param[out] strError a string describing the error if the function failed, @@ -88,6 +89,23 @@ public: */ bool getFailureOnMissingSubsystem(); + /** Should start fail in failed settings load. + * + * Will fail if called on started instance. + * + * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load. + * If set to false, failed settings load will be ignored. + * @param[out] strResult a string containing the result of the command. + * + * @return false if unable to set, true otherwise. + */ + bool setFailureOnFailedSettingsLoad(bool bFail, std::string& strError); + /** Would start fail in case of failed settings load. + * + * @return failure on failed settings load policy state. + */ + bool getFailureOnFailedSettingsLoad(); + private: CParameterMgrPlatformConnector(const CParameterMgrPlatformConnector&); CParameterMgrPlatformConnector& operator=(const CParameterMgrPlatformConnector&); |