diff options
-rwxr-xr-x[-rw-r--r--] | parameter/IntegerParameterType.cpp | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/IntegerParameterType.h | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/ParameterType.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/ParameterType.h | 19 | ||||
-rwxr-xr-x | parameter/SubsystemObject.cpp | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/SubsystemObject.h | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/TypeElement.cpp | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/TypeElement.h | 9 |
8 files changed, 73 insertions, 5 deletions
diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp index 3c3a626..b07194b 100644..100755 --- a/parameter/IntegerParameterType.cpp +++ b/parameter/IntegerParameterType.cpp @@ -343,6 +343,16 @@ uint32_t CIntegerParameterType::getDefaultValue() const return _uiMin; } +int CIntegerParameterType::toPlainInteger(int iSizeOptimizedData) const +{ + if (_bSigned) { + + signExtend(iSizeOptimizedData); + } + + return base::toPlainInteger(iSizeOptimizedData); +} + // Convert value provided by the user as a string into an int64 bool CIntegerParameterType::convertValueFromString(const string& strValue, int64_t& iData, CParameterAccessContext& parameterAccessContext) const { diff --git a/parameter/IntegerParameterType.h b/parameter/IntegerParameterType.h index 9fb0dfd..29d28b7 100644..100755 --- a/parameter/IntegerParameterType.h +++ b/parameter/IntegerParameterType.h @@ -59,8 +59,12 @@ public: // Element properties virtual void showProperties(string& strResult) const; + // Integer conversion + virtual int toPlainInteger(int iSizeOptimizedData) const; + // CElement virtual string getKind() const; + private: // Returns true if children dynamic creation is to be dealt with virtual bool childrenAreDynamic() const; diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp index f7dda74..27df1dc 100644..100755 --- a/parameter/ParameterType.cpp +++ b/parameter/ParameterType.cpp @@ -112,13 +112,11 @@ CInstanceConfigurableElement* CParameterType::doInstantiate() const } } -// Sign extension (32 bits) void CParameterType::signExtend(int32_t& iData) const { doSignExtend(iData); } -// Sign extension (64 bits) void CParameterType::signExtend(int64_t& iData) const { doSignExtend(iData); diff --git a/parameter/ParameterType.h b/parameter/ParameterType.h index ed30ac3..2fcd9e5 100644..100755 --- a/parameter/ParameterType.h +++ b/parameter/ParameterType.h @@ -73,14 +73,27 @@ public: // Default value handling (simulation only) virtual uint32_t getDefaultValue() const; + + /** + * Sign extension (32 bits) + * + * @param[in:out] iData the data which will be sign extended + */ + void signExtend(int32_t& iData) const; + + /** + * Sign extension (64 bits) + * + * @param[in:out] iData the data which will be sign extended + */ + void signExtend(int64_t& iData) const; + protected: // Object creation virtual void populate(CElement* pElement) const; // Size void setSize(uint32_t uiSize); - // Sign extension - void signExtend(int32_t& iData) const; - void signExtend(int64_t& iData) const; + // Check data has no bit set outside available range (based on byte size) and // check data is consistent with available range, with respect to its sign bool isEncodable(uint32_t uiData, bool bIsSigned) const; diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index eaf87aa..c8d4c1b 100755 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -28,6 +28,7 @@ #include "ParameterBlackboard.h" #include "ParameterAccessContext.h" #include "MappingContext.h" +#include "ParameterType.h" #include <assert.h> #include <stdlib.h> #include <string.h> @@ -82,6 +83,23 @@ string CSubsystemObject::asString(uint32_t uiValue) return ostr.str(); } +int CSubsystemObject::toPlainInteger( + const CInstanceConfigurableElement *instanceConfigurableElement, + int sizeOptimizedData) +{ + if (instanceConfigurableElement) { + + // Get actual element type + const CTypeElement *typeElement = + static_cast<const CParameterType *>(instanceConfigurableElement->getTypeElement()); + + // Do the extension + return typeElement->toPlainInteger(sizeOptimizedData); + } + + return sizeOptimizedData; +} + // Default back synchronization void CSubsystemObject::setDefaultValues(CParameterBlackboard& parameterBlackboard) const { diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index ca52df8..1c6690d 100644..100755 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h @@ -56,6 +56,17 @@ protected: static uint32_t asInteger(const string& strValue); static string asString(uint32_t uiValue); + /** + * Conversion of int8, int16, int32 to int (taking care of sign extension) + * + * @param[in] instanceConfigurableElement pointer to configurable element instance + * @param[in] sizeOptimizedData data to convert + * + * @return the data converted to int + */ + int toPlainInteger(const CInstanceConfigurableElement *instanceConfigurableElement, + int sizeOptimizedData); + // Sync to/from HW virtual bool sendToHW(string& strError); virtual bool receiveFromHW(string& strError); diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp index 5bfc2d7..59d4412 100644..100755 --- a/parameter/TypeElement.cpp +++ b/parameter/TypeElement.cpp @@ -49,6 +49,11 @@ uint32_t CTypeElement::getArrayLength() const return _uiArrayLength; } +int CTypeElement::toPlainInteger(int iSizeOptimizedData) const +{ + return iSizeOptimizedData; +} + bool CTypeElement::getMappingData(const string& strKey, const string*& pStrValue) const { if (_pMappingData) { diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h index 353b0a5..6d801aa 100644..100755 --- a/parameter/TypeElement.h +++ b/parameter/TypeElement.h @@ -64,6 +64,15 @@ public: // Array Length uint32_t getArrayLength() const; + /** + * Converts size optimized integer input data (int8, int16, int32) to plain int + * + * @param[in] iSizeOptimizedData the data to convert + * + * @return the data with int type + */ + virtual int toPlainInteger(int iSizeOptimizedData) const; + protected: // Object creation virtual void populate(CElement* pElement) const; |