summaryrefslogtreecommitdiffstats
path: root/parameter/SubsystemObject.cpp
diff options
context:
space:
mode:
authorGuillaume Denneulin <guillaumex.denneulin@intel.com>2012-02-17 17:34:47 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:02:27 +0100
commit7fce1e3c41213f0c4ea971b0e87a7cc34b5b5181 (patch)
treedfebee9c9e68d912e0565506f796a181a3dea512 /parameter/SubsystemObject.cpp
parentd1406495a57f856e086e3599161f4a44a2745449 (diff)
downloadexternal_parameter-framework-7fce1e3c41213f0c4ea971b0e87a7cc34b5b5181.zip
external_parameter-framework-7fce1e3c41213f0c4ea971b0e87a7cc34b5b5181.tar.gz
external_parameter-framework-7fce1e3c41213f0c4ea971b0e87a7cc34b5b5181.tar.bz2
Handle amend of mapping values at PFW level
BZ: 24271 Amend mechanism can be used by various plugins, right now it is implemented in alsa one. Move this implementation in the PFW for all plugin to benefit from this mechanism. Change-Id: I3f193a732b00586c52303390f353fea00f4ce8ec Signed-off-by: Guillaume Denneulin <guillaumex.denneulin@intel.com> Reviewed-on: http://android.intel.com:8080/35905 Reviewed-by: Barthes, FabienX <fabienx.barthes@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/SubsystemObject.cpp')
-rw-r--r--parameter/SubsystemObject.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp
index ce6275b..5d92127 100644
--- a/parameter/SubsystemObject.cpp
+++ b/parameter/SubsystemObject.cpp
@@ -31,6 +31,7 @@
#include "SubsystemObject.h"
#include "InstanceConfigurableElement.h"
#include "ParameterBlackboard.h"
+#include "MappingContext.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -176,3 +177,38 @@ void CSubsystemObject::log(const string& strMessage, ...) const
_pInstanceConfigurableElement->log(acBuffer);
}
+
+// Amendment
+string CSubsystemObject::formatMappingValue(const string& strMappingValue, uint32_t uiFirstAmendKey, uint32_t uiNbAmendKeys, const CMappingContext& context)
+{
+ string strFormattedValue = strMappingValue;
+ // Search for amendment (only one supported for now)
+ size_t uiPercentPos = strFormattedValue.find('%', 0);
+
+ // Amendment limited to one digit (values from 1 to 9)
+ assert((uiNbAmendKeys > 0) && (uiNbAmendKeys <= 9));
+
+ // Check we found one and that there's room for value
+ if (uiPercentPos != string::npos && uiPercentPos < strFormattedValue.size() - 1) {
+
+ // Get Amend number
+ uint32_t uiAmendNumber = strFormattedValue[uiPercentPos + 1] - '0';
+
+ // Valid?
+ if (uiAmendNumber && uiAmendNumber <= uiNbAmendKeys) {
+
+ uint32_t uiAmendType = uiFirstAmendKey + uiAmendNumber - 1;
+
+ // Set?
+ if (context.iSet(uiAmendType)) {
+
+ // Get Amend value
+ string strAmendValue = context.getItem(uiAmendType);
+
+ // Make the amendment
+ strFormattedValue = strFormattedValue.substr(0, uiPercentPos) + strAmendValue + strFormattedValue.substr(uiPercentPos + 2, strFormattedValue.size() - uiPercentPos - 2);
+ }
+ }
+ }
+ return strFormattedValue;
+}