summaryrefslogtreecommitdiffstats
path: root/parameter/SelectionCriterionType.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/SelectionCriterionType.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/SelectionCriterionType.cpp')
-rw-r--r--parameter/SelectionCriterionType.cpp91
1 files changed, 86 insertions, 5 deletions
diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp
index 2e562da..478fb43 100644
--- a/parameter/SelectionCriterionType.cpp
+++ b/parameter/SelectionCriterionType.cpp
@@ -42,15 +42,21 @@ string CSelectionCriterionType::getKind() const
}
// From ISelectionCriterionTypeInterface
-std::string CSelectionCriterionType::getCriterionTypeName()
-{
- return getName();
-}
-
bool CSelectionCriterionType::addValuePair(int iValue, const string& strValue)
{
+ // Check 1 bit set only for inclusive types
+ if (_bInclusive && (!iValue || (iValue & (iValue - 1)))) {
+
+ log("Rejecting value pair association: 0x%X - %s for Selection Criterion Type %s", iValue, strValue.c_str(), getName().c_str());
+
+ return false;
+ }
+
+ // Check already inserted
if (_numToLitMap.find(strValue) != _numToLitMap.end()) {
+ log("Rejecting value pair association (literal already present): 0x%X - %s for Selection Criterion Type %s", iValue, strValue.c_str(), getName().c_str());
+
return false;
}
_numToLitMap[strValue] = iValue;
@@ -91,3 +97,78 @@ bool CSelectionCriterionType::isTypeInclusive() const
{
return _bInclusive;
}
+
+// Value list
+string CSelectionCriterionType::listPossibleValues() const
+{
+ string strValueList = "{";
+
+ // Get comma seprated list of values
+ NumToLitMapConstIt it;
+ bool bFirst = true;
+
+ for (it = _numToLitMap.begin(); it != _numToLitMap.end(); ++it) {
+
+ if (bFirst) {
+
+ bFirst = false;
+ } else {
+ strValueList += ", ";
+ }
+ strValueList += it->first;
+ }
+
+ strValueList += "}";
+
+ return strValueList;
+}
+
+// Formatted state
+string CSelectionCriterionType::getFormattedState(int iValue) const
+{
+ string strFormattedState;
+
+ if (_bInclusive) {
+
+ // Need to go through all set bit
+ uint32_t uiBit;
+ bool bFirst = true;
+
+ for (uiBit = 0; uiBit < sizeof(iValue) << 3; uiBit++) {
+
+ int iSingleBitValue = iValue & (1 << uiBit);
+
+ // Check if current bit is set
+ if (!iSingleBitValue) {
+
+ continue;
+ }
+
+ // Simple translation
+ string strSingleValue;
+
+ getLiteralValue(iSingleBitValue, strSingleValue);
+
+ if (bFirst) {
+
+ bFirst = false;
+ } else {
+ strFormattedState += "|";
+ }
+
+ strFormattedState += strSingleValue;
+ }
+
+ } else {
+ // Simple translation
+ getLiteralValue(iValue, strFormattedState);
+ }
+
+ // Sometimes nothing is set
+ if (strFormattedState.empty()) {
+
+ strFormattedState = "<none>";
+ }
+
+ return strFormattedState;
+}