aboutsummaryrefslogtreecommitdiffstats
path: root/parameter/ConfigurableDomain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parameter/ConfigurableDomain.cpp')
-rw-r--r--parameter/ConfigurableDomain.cpp149
1 files changed, 100 insertions, 49 deletions
diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp
index 696bbd0..4c6541f 100644
--- a/parameter/ConfigurableDomain.cpp
+++ b/parameter/ConfigurableDomain.cpp
@@ -73,6 +73,24 @@ bool CConfigurableDomain::childrenAreDynamic() const
return true;
}
+// Content dumping
+void CConfigurableDomain::logValue(string& strValue, CErrorContext& errorContext) const
+{
+ (void)errorContext;
+
+ strValue = "{";
+
+ // Sequence awareness
+ strValue += "Sequence aware: ";
+ strValue += _bSequenceAware ? "yes" : "no";
+
+ // Last applied configuration
+ strValue += ", Last applied configuration: ";
+ strValue += _pLastAppliedConfiguration ? _pLastAppliedConfiguration->getName() : "<none>";
+
+ strValue += "}";
+}
+
// Sequence awareness
void CConfigurableDomain::setSequenceAwareness(bool bSequenceAware)
{
@@ -460,25 +478,6 @@ bool CConfigurableDomain::isApplicableConfigurationValid(const CConfigurableElem
return pApplicableDomainConfiguration && pApplicableDomainConfiguration->isValid(pConfigurableElement);
}
-// Presence of application condition on any configuration
-bool CConfigurableDomain::hasRules() const
-{
- // Delegate to configurations
- uint32_t uiNbConfigurations = getNbChildren();
- uint32_t uiChild;
-
- for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
-
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild));
-
- if (pDomainConfiguration->hasRule()) {
-
- return true;
- }
- }
- return false;
-}
-
// In case configurable element was removed
void CConfigurableDomain::computeSyncSet()
{
@@ -541,20 +540,10 @@ bool CConfigurableDomain::createConfiguration(const string& strName, const CPara
bool CConfigurableDomain::deleteConfiguration(const string& strName, string& strError)
{
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Configuration not found";
-
- return false;
- }
-
- // Check configuration has no rule (prevent accidental loss of data)
- if (pDomainConfiguration->hasRule()) {
-
- strError = "Deletion of configuration containing application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file.";
-
return false;
}
@@ -593,12 +582,10 @@ void CConfigurableDomain::listAssociatedToElements(string& strResult) const
bool CConfigurableDomain::renameConfiguration(const string& strName, const string& strNewName, string& strError)
{
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Configuration not found";
-
return false;
}
log("Renaming domain \"%s\"'s configuration \"%s\" to \"%s\"", getName().c_str(), strName.c_str(), strNewName.c_str());
@@ -607,15 +594,12 @@ bool CConfigurableDomain::renameConfiguration(const string& strName, const strin
return pDomainConfiguration->rename(strNewName, strError);
}
-bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError)
+bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) const
{
- // Find Domain configuration
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName));
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
log("Restoring domain \"%s\"'s configuration \"%s\" to parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
@@ -636,12 +620,10 @@ bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameter
bool CConfigurableDomain::saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError)
{
// Find Domain configuration
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
log("Saving domain \"%s\"'s configuration \"%s\" from parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
@@ -652,15 +634,13 @@ bool CConfigurableDomain::saveConfiguration(const string& strName, const CParame
return true;
}
-bool CConfigurableDomain::setElementSequence(const string& strName, const vector<string>& astrNewElementSequence, string& strError)
+bool CConfigurableDomain::setElementSequence(const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError)
{
// Find Domain configuration
- CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName));
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
if (!pDomainConfiguration) {
- strError = "Domain configuration " + strName + " not found";
-
return false;
}
@@ -668,15 +648,13 @@ bool CConfigurableDomain::setElementSequence(const string& strName, const vector
return pDomainConfiguration->setElementSequence(astrNewElementSequence, strError);
}
-bool CConfigurableDomain::getElementSequence(const string& strName, string& strResult) const
+bool CConfigurableDomain::getElementSequence(const string& strConfiguration, string& strResult) const
{
// Find Domain configuration
- const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName));
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
if (!pDomainConfiguration) {
- strResult = "Domain configuration " + strName + " not found";
-
return false;
}
@@ -686,6 +664,52 @@ bool CConfigurableDomain::getElementSequence(const string& strName, string& strR
return true;
}
+bool CConfigurableDomain::setApplicationRule(const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError)
+{
+ // Find Domain configuration
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ return pDomainConfiguration->setApplicationRule(strApplicationRule, pSelectionCriteriaDefinition, strError);
+}
+
+bool CConfigurableDomain::clearApplicationRule(const string& strConfiguration, string& strError)
+{
+ // Find Domain configuration
+ CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ pDomainConfiguration->clearApplicationRule();
+
+ return true;
+}
+
+bool CConfigurableDomain::getApplicationRule(const string& strConfiguration, string& strResult) const
+{
+ // Find Domain configuration
+ const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
+
+ if (!pDomainConfiguration) {
+
+ return false;
+ }
+
+ // Delegate to configuration
+ pDomainConfiguration->getApplicationRule(strResult);
+
+ return true;
+}
+
// Last applied configuration
string CConfigurableDomain::getLastAppliedConfigurationName() const
{
@@ -983,3 +1007,30 @@ CSyncerSet* CConfigurableDomain::getSyncerSet(const CConfigurableElement* pConfi
return mapIt->second;
}
+
+// Configuration retrieval
+CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError)
+{
+ CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strConfiguration));
+
+ if (!pDomainConfiguration) {
+
+ strError = "Domain configuration " + strConfiguration + " not found";
+
+ return NULL;
+ }
+ return pDomainConfiguration;
+}
+
+const CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError) const
+{
+ const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strConfiguration));
+
+ if (!pDomainConfiguration) {
+
+ strError = "Domain configuration " + strConfiguration + " not found";
+
+ return NULL;
+ }
+ return pDomainConfiguration;
+}