diff options
Diffstat (limited to 'parameter/ParameterType.cpp')
-rw-r--r-- | parameter/ParameterType.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp index 01d94aa..eb9fd3d 100644 --- a/parameter/ParameterType.cpp +++ b/parameter/ParameterType.cpp @@ -31,11 +31,14 @@ #include "Parameter.h" #include "ArrayParameter.h" #include "ParameterAccessContext.h" +#include "Utility.h" #define base CTypeElement using std::string; +const std::string CParameterType::gUnitPropertyName = "Unit"; + CParameterType::CParameterType(const string& strName) : base(strName), _uiSize(0) { } @@ -68,15 +71,33 @@ string CParameterType::getUnit() const return _strUnit; } +void CParameterType::setUnit(const std::string& strUnit) +{ + _strUnit = strUnit; +} + // From IXmlSink bool CParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { - // Unit - _strUnit = xmlElement.getAttributeString("Unit"); - + setUnit(xmlElement.getAttributeString(gUnitPropertyName)); return base::fromXml(xmlElement, serializingContext); } +// From IXmlSource +void CParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + base::toXml(xmlElement, serializingContext); + setXmlUnitAttribute(xmlElement); +} + +void CParameterType::setXmlUnitAttribute(CXmlElement& xmlElement) const +{ + const string& unit = getUnit(); + if (!unit.empty()) { + xmlElement.setAttributeString(gUnitPropertyName, unit); + } +} + // XML Serialization value space handling // Value space handling for configuration import/export void CParameterType::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const @@ -91,14 +112,13 @@ void CParameterType::showProperties(string& strResult) const { base::showProperties(strResult); - // Unit - if (!_strUnit.empty()) { - - strResult += "Unit: " + _strUnit + "\n"; + // Add Unit property if found + if (!getUnit().empty()) { + strResult += gUnitPropertyName + ": " + getUnit() + "\n"; } // Scalar size - strResult += "Scalar size: " + toString(getSize()) + " byte(s) \n"; + strResult += "Scalar size: " + CUtility::toString(getSize()) + " byte(s) \n"; } // Default value handling (simulation only) |