summaryrefslogtreecommitdiffstats
path: root/parameter/SelectionCriterionType.cpp
diff options
context:
space:
mode:
authorFrancois Gaffie <francois.gaffie@intel.com>2013-10-15 11:01:23 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:04:14 +0100
commita0c3b8a42e473fa96ec469c2e691a919f31df26d (patch)
treea962dce8a7fad4e753b81cb5d5a378a541ae86fa /parameter/SelectionCriterionType.cpp
parentff574884b80ca5e96960565ada430d8207951b31 (diff)
downloadexternal_parameter-framework-a0c3b8a42e473fa96ec469c2e691a919f31df26d.zip
external_parameter-framework-a0c3b8a42e473fa96ec469c2e691a919f31df26d.tar.gz
external_parameter-framework-a0c3b8a42e473fa96ec469c2e691a919f31df26d.tar.bz2
Adds default value pair for inclusive criterion
BZ: 99956 Inclusive criterion type does not allow to check if the bitfield is empty, i.e., if zero is not available. This patch adds the default value pair "none, 0" to allow check either if the criterion "Is" 0, and establishes consistency with inclusion rule. It also allows to convert a concatenated chain of string value, where "|" is considered as AND rule into the corresponding numerical value. Change-Id: I4ee7c0f69228a727964ab80050ac12c6babd4f58 Signed-off-by: Francois Gaffie <francois.gaffie@intel.com> Signed-off-by: Jorge Quintero <jorge.quintero@intel.com> Reviewed-on: http://android.intel.com:8080/138518 Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com> Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Diffstat (limited to 'parameter/SelectionCriterionType.cpp')
-rw-r--r--parameter/SelectionCriterionType.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp
index 6e5a8cc..2f07ade 100644
--- a/parameter/SelectionCriterionType.cpp
+++ b/parameter/SelectionCriterionType.cpp
@@ -23,11 +23,19 @@
* UPDATED: 2011-07-27
*/
#include "SelectionCriterionType.h"
+#include "Tokenizer.h"
#define base CElement
+const string CSelectionCriterionType::_strDelimiter = "|";
+
CSelectionCriterionType::CSelectionCriterionType(bool bIsInclusive) : _bInclusive(bIsInclusive)
{
+ // For inclusive criterion type, appends the pair none,0 by default.
+ if (_bInclusive) {
+
+ _numToLitMap["none"] = 0;
+ }
}
string CSelectionCriterionType::getKind() const
@@ -60,6 +68,30 @@ bool CSelectionCriterionType::addValuePair(int iValue, const string& strValue)
bool CSelectionCriterionType::getNumericalValue(const string& strValue, int& iValue) const
{
+ if (_bInclusive) {
+
+ Tokenizer tok(strValue, _strDelimiter);
+ vector<string> astrValues = tok.split();
+ uint32_t uiNbValues = astrValues.size();
+ int iResult = 0;
+ uint32_t uiValueIndex;
+
+ // Looping on each string delimited by "|" token and adding the associated value
+ for (uiValueIndex = 0; uiValueIndex < uiNbValues; uiValueIndex++) {
+
+ if (!getAtomicNumericalValue(astrValues[uiValueIndex], iResult)) {
+
+ return false;
+ }
+ iValue |= iResult;
+ }
+ return true;
+ }
+ return getAtomicNumericalValue(strValue, iValue);
+}
+
+bool CSelectionCriterionType::getAtomicNumericalValue(const string& strValue, int& iValue) const
+{
NumToLitMapConstIt it = _numToLitMap.find(strValue);
if (it != _numToLitMap.end()) {