diff options
author | Guillaume Denneulin <guillaumex.denneulin@intel.com> | 2012-02-17 17:34:47 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:02:27 +0100 |
commit | 7fce1e3c41213f0c4ea971b0e87a7cc34b5b5181 (patch) | |
tree | dfebee9c9e68d912e0565506f796a181a3dea512 | |
parent | d1406495a57f856e086e3599161f4a44a2745449 (diff) | |
download | external_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>
-rw-r--r-- | parameter/SubsystemObject.cpp | 36 | ||||
-rw-r--r-- | parameter/SubsystemObject.h | 4 |
2 files changed, 40 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; +} diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index 711d9d1..d08f3c4 100644 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h @@ -34,6 +34,7 @@ #include <stdint.h> class CInstanceConfigurableElement; +class CMappingContext; class CSubsystemObject : public ISyncer { @@ -63,6 +64,9 @@ protected: void blackboardWrite(const void* pvData, uint32_t uiSize); // Logging void log(const string& strMessage, ...) const; + // Mapping formatting + static string formatMappingValue(const string& strMappingValue, uint32_t uiFirstAmendKey, uint32_t uiNbAmendKeys, const CMappingContext& context); + private: // Instance element to sync from/to CInstanceConfigurableElement* _pInstanceConfigurableElement; |