diff options
Diffstat (limited to 'parameter/ConfigurableDomains.cpp')
-rw-r--r-- | parameter/ConfigurableDomains.cpp | 144 |
1 files changed, 87 insertions, 57 deletions
diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index d021d8c..28611d3 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -139,20 +139,10 @@ bool CConfigurableDomains::createDomain(const string& strName, string& strError) bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - - return false; - } - - // Check domain has no rule (prevent accidental loss of data) - if (pConfigurableDomain->hasRules()) { - - strError = "Deletion of domain containing configurations with application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file."; - return false; } @@ -169,12 +159,10 @@ bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) bool CConfigurableDomains::renameDomain(const string& strName, const string& strNewName, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strName, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -186,12 +174,10 @@ bool CConfigurableDomains::renameDomain(const string& strName, const string& str bool CConfigurableDomains::setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError) { - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -202,12 +188,10 @@ bool CConfigurableDomains::setSequenceAwareness(const string& strDomain, bool bS bool CConfigurableDomains::getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const { - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain not found"; - return false; } @@ -219,12 +203,10 @@ bool CConfigurableDomains::getSequenceAwareness(const string& strDomain, bool& b /// Configurations bool CConfigurableDomains::listConfigurations(const string& strDomain, string& strResult) const { - const CElement* pConfigurableDomain = findChild(strDomain); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain not found"; - return false; } // delegate @@ -236,12 +218,10 @@ bool CConfigurableDomains::listConfigurations(const string& strDomain, string& s bool CConfigurableDomains::createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -251,12 +231,10 @@ bool CConfigurableDomains::createConfiguration(const string& strDomain, const st bool CConfigurableDomains::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -266,12 +244,10 @@ bool CConfigurableDomains::deleteConfiguration(const string& strDomain, const st bool CConfigurableDomains::renameConfiguration(const string& strDomain, const string& strConfigurationName, const string& strNewConfigurationName, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -281,12 +257,10 @@ bool CConfigurableDomains::renameConfiguration(const string& strDomain, const st bool CConfigurableDomains::listDomainElements(const string& strDomain, string& strResult) const { // Find domain - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -298,12 +272,10 @@ bool CConfigurableDomains::listDomainElements(const string& strDomain, string& s bool CConfigurableDomains::split(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -403,15 +375,13 @@ void CConfigurableDomains::gatherAllOwnedConfigurableElements(set<const CConfigu } // Config restore -bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) +bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) const { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -422,12 +392,10 @@ bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const s bool CConfigurableDomains::saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -437,12 +405,10 @@ bool CConfigurableDomains::saveConfiguration(const string& strDomain, const stri bool CConfigurableDomains::setElementSequence(const string& strDomain, const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } @@ -453,18 +419,55 @@ bool CConfigurableDomains::setElementSequence(const string& strDomain, const str bool CConfigurableDomains::getElementSequence(const string& strDomain, const string& strConfiguration, string& strResult) const { // Find domain - const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); if (!pConfigurableDomain) { - strResult = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate to domain return pConfigurableDomain->getElementSequence(strConfiguration, strResult); } +bool CConfigurableDomains::setApplicationRule(const string& strDomain, const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->setApplicationRule(strConfiguration, strApplicationRule, pSelectionCriteriaDefinition, strError); +} + +bool CConfigurableDomains::clearApplicationRule(const string& strDomain, const string& strConfiguration, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->clearApplicationRule(strConfiguration, strError); +} + +bool CConfigurableDomains::getApplicationRule(const string& strDomain, const string& strConfiguration, string& strResult) const +{ + const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strResult); + + if (!pConfigurableDomain) { + + return false; + } + + // Delegate to domain + return pConfigurableDomain->getApplicationRule(strConfiguration, strResult); +} + // Last applied configurations void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) const { @@ -484,12 +487,10 @@ void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) cons bool CConfigurableDomains::addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -499,12 +500,10 @@ bool CConfigurableDomains::addConfigurableElementToDomain(const string& strDomai bool CConfigurableDomains::removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) { // Find domain - CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError); if (!pConfigurableDomain) { - strError = "Configurable domain " + strDomain + " not found"; - return false; } // Delegate @@ -533,3 +532,34 @@ bool CConfigurableDomains::serializeSettings(const string& strBinarySettingsFile return true; } + +// Domain retrieval +CConfigurableDomain* CConfigurableDomains::findConfigurableDomain(const string& strDomain, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return NULL; + } + + return pConfigurableDomain; +} + +const CConfigurableDomain* CConfigurableDomains::findConfigurableDomain(const string& strDomain, string& strError) const +{ + // Find domain + const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return NULL; + } + + return pConfigurableDomain; +} |