summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parameter/SubsystemObject.cpp36
-rw-r--r--parameter/SubsystemObject.h4
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;