summaryrefslogtreecommitdiffstats
path: root/parameter/SelectionCriterionRule.cpp
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2011-08-31 11:23:24 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:13:21 +0100
commit6ba361d96bc2581667b3400f87ff89fae6449e1f (patch)
treee72e959d7d4c3b0f0b6dc20ec4f07d957eae1a50 /parameter/SelectionCriterionRule.cpp
parent68a912857707864bbaaff9808717813105072a6e (diff)
downloadexternal_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.zip
external_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.tar.gz
external_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.tar.bz2
parameter-framework: improvements and corrections
BZ: 6721 - Bug correction concerning selection criteria display (inclusive type) - Adapted XML format to allow for only on parameter to be associated to a domain - Removed unused files in parameter project Change-Id: I9f42d08ff8cb60354714fe3d6b0f0b321ad0a7bf Orig-Change-Id: I837e553070f5acf2d275082c986ba29433493e31 Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com> Reviewed-on: http://android.intel.com:8080/16878 Reviewed-by: Mahe, Erwan <erwan.mahe@intel.com> Tested-by: Barthes, FabienX <fabienx.barthes@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter/SelectionCriterionRule.cpp')
-rw-r--r--parameter/SelectionCriterionRule.cpp48
1 files changed, 37 insertions, 11 deletions
diff --git a/parameter/SelectionCriterionRule.cpp b/parameter/SelectionCriterionRule.cpp
index 4b5956c..e43c9e8 100644
--- a/parameter/SelectionCriterionRule.cpp
+++ b/parameter/SelectionCriterionRule.cpp
@@ -32,13 +32,16 @@
#include "SelectionCriterion.h"
#include "XmlDomainSerializingContext.h"
#include "SelectionCriteriaDefinition.h"
+#include "SelectionCriterionTypeInterface.h"
#include <assert.h>
#define base CRule
-const char* CSelectionCriterionRule::_apcMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = {
- "Is",
- "Contains"
+CSelectionCriterionRule::SMatchingRuleDescription CSelectionCriterionRule::_astMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = {
+ { "Is", false },
+ { "IsNot", false },
+ { "Includes", true },
+ { "Excludes", true }
};
CSelectionCriterionRule::CSelectionCriterionRule() : _pSelectionCriterion(NULL), _eMatchesWhen(CSelectionCriterionRule::EIs), _iMatchValue(0)
@@ -58,9 +61,13 @@ bool CSelectionCriterionRule::matches() const
switch(_eMatchesWhen) {
case EIs:
- return _pSelectionCriterion->equals(_iMatchValue);
- case EContains:
- return _pSelectionCriterion->contains(_iMatchValue);
+ return _pSelectionCriterion->is(_iMatchValue);
+ case EIsNot:
+ return _pSelectionCriterion->isNot(_iMatchValue);
+ case EIncludes:
+ return _pSelectionCriterion->includes(_iMatchValue);
+ case EExcludes:
+ return _pSelectionCriterion->excludes(_iMatchValue);
default:
assert(0);
return false;
@@ -88,10 +95,11 @@ bool CSelectionCriterionRule::fromXml(const CXmlElement& xmlElement, CXmlSeriali
// Get MatchesWhen
string strMatchesWhen = xmlElement.getAttributeString("MatchesWhen");
+ string strError;
- if (!setMatchesWhen(strMatchesWhen)) {
+ if (!setMatchesWhen(strMatchesWhen, strError)) {
- xmlDomainSerializingContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath());
+ xmlDomainSerializingContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath() + ": " + strError);
return false;
}
@@ -121,7 +129,7 @@ void CSelectionCriterionRule::toXml(CXmlElement& xmlElement, CXmlSerializingCont
xmlElement.setAttributeString("SelectionCriterion", _pSelectionCriterion->getName());
// Set MatchesWhen
- xmlElement.setAttributeString("MatchesWhen", _apcMatchesWhen[_eMatchesWhen]);
+ xmlElement.setAttributeString("MatchesWhen", _astMatchesWhen[_eMatchesWhen].pcMatchesWhen);
// Set Value
string strValue;
@@ -132,19 +140,37 @@ void CSelectionCriterionRule::toXml(CXmlElement& xmlElement, CXmlSerializingCont
}
// XML MatchesWhen attribute parsing
-bool CSelectionCriterionRule::setMatchesWhen(const string& strMatchesWhen)
+bool CSelectionCriterionRule::setMatchesWhen(const string& strMatchesWhen, string& strError)
{
uint32_t uiMatchesWhen;
for (uiMatchesWhen = 0; uiMatchesWhen < ENbMatchesWhen; uiMatchesWhen++) {
- if (strMatchesWhen == _apcMatchesWhen[uiMatchesWhen]) {
+ const SMatchingRuleDescription* pstMatchingRuleDescription = &_astMatchesWhen[uiMatchesWhen];
+
+ if (strMatchesWhen == pstMatchingRuleDescription->pcMatchesWhen) {
// Found it!
+
+ // Get Type
+ const ISelectionCriterionTypeInterface* pSelectionCriterionType = _pSelectionCriterion->getCriterionType();
+
+ // Check compatibility if relevant
+ if (pSelectionCriterionType->isTypeInclusive() && !pstMatchingRuleDescription->bInclusiveTypeCompatible) {
+
+ strError = "Value incompatible with inclusive kind of type";
+
+ return false;
+ }
+
+ // Store
_eMatchesWhen = (MatchesWhen)uiMatchesWhen;
return true;
}
}
+
+ strError = "Value not found";
+
return false;
}