summaryrefslogtreecommitdiffstats
path: root/parameter/MappingContext.cpp
diff options
context:
space:
mode:
authorRenaud de Chivre <renaud.de.chivre@intel.com>2013-09-02 10:48:36 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:04:10 +0100
commit46966e050fdd1ae48c7692ae9818762ba262e781 (patch)
treeecee4e54006b6141af35033a1db2371f405a2335 /parameter/MappingContext.cpp
parentd55f586c54d9a0c22b27f775ec906e5595bf56d4 (diff)
downloadexternal_parameter-framework-46966e050fdd1ae48c7692ae9818762ba262e781.zip
external_parameter-framework-46966e050fdd1ae48c7692ae9818762ba262e781.tar.gz
external_parameter-framework-46966e050fdd1ae48c7692ae9818762ba262e781.tar.bz2
Handle key names in mapping context
BZ: 126002 Mapping context only allows to retrieve a mapping value from its corresponding key ID. We also want to do the same using its key as a string. This patch adds key name handling in context mapping. It also adds an API to retieve a mapping value from its corresponding key name. Note: it also removes an unused argument from handleMappingContext function. Change-Id: I5a18ad624a69272ea2796090692f2bfa8b373a52 Signed-off-by: Renaud de Chivre <renaud.de.chivre@intel.com> Reviewed-on: http://android.intel.com:8080/131571 Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com> Reviewed-by: cactus <cactus@intel.com> Tested-by: cactus <cactus@intel.com>
Diffstat (limited to 'parameter/MappingContext.cpp')
-rw-r--r--parameter/MappingContext.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/parameter/MappingContext.cpp b/parameter/MappingContext.cpp
index dae71ee..727fadb 100644
--- a/parameter/MappingContext.cpp
+++ b/parameter/MappingContext.cpp
@@ -23,6 +23,7 @@
* UPDATED: 2011-07-27
*/
#include "MappingContext.h"
+#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -66,15 +67,27 @@ CMappingContext& CMappingContext::operator=(const CMappingContext& right)
}
// Item access
-bool CMappingContext::setItem(uint32_t uiItemType, const string* pStrItem)
+bool CMappingContext::setItem(uint32_t uiItemType, const string* pStrKey, const string* pStrItem)
{
+ uint32_t uiIndex;
+
// Do some checks
+ for (uiIndex = 0; uiIndex < _uiNbItemTypes; uiIndex++) {
+
+ // Does key already exist ?
+ assert(_pstItemArray[uiIndex].strKey != pStrKey);
+ }
+
if (_pstItemArray[uiItemType].bSet) {
// Already set!
return false;
}
- // Get item value
+
+ // Set item key
+ _pstItemArray[uiItemType].strKey = pStrKey;
+
+ // Set item value
_pstItemArray[uiItemType].strItem = pStrItem;
// Now is set
@@ -98,6 +111,22 @@ uint32_t CMappingContext::getItemAsInteger(uint32_t uiItemType) const
return strtoul(_pstItemArray[uiItemType].strItem->c_str(), NULL, 0);
}
+const string* CMappingContext::getItem(const string& strKey) const
+{
+ uint32_t uiItemType;
+
+ for (uiItemType = 0; uiItemType < _uiNbItemTypes; uiItemType++) {
+
+ if (_pstItemArray[uiItemType].strKey != NULL &&
+ strKey == *_pstItemArray[uiItemType].strKey) {
+
+ return _pstItemArray[uiItemType].strItem;
+ }
+ }
+
+ return NULL;
+}
+
bool CMappingContext::iSet(uint32_t uiItemType) const
{
return _pstItemArray[uiItemType].bSet;