diff options
78 files changed, 1057 insertions, 654 deletions
diff --git a/parameter-connector-test/main.cpp b/parameter-connector-test/main.cpp index 2fb8218..ebd6986 100644 --- a/parameter-connector-test/main.cpp +++ b/parameter-connector-test/main.cpp @@ -36,7 +36,8 @@ using namespace std; #ifdef SIMULATION -const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/projects/qt/parameter-framework/XML"; +//const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/projects/qt/parameter-framework/XML"; +const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/Documents/gingerbread/hardware/intel/PRIVATE/parameter-framework/XML"; #else const char* gpcParameterFrameworkConfigurationFolderPath = "/etc/parameter-framework"; #endif diff --git a/parameter/Android.mk b/parameter/Android.mk index 8db8179..3ed382f 100644 --- a/parameter/Android.mk +++ b/parameter/Android.mk @@ -45,8 +45,6 @@ LOCAL_SRC_FILES:= \ ArrayParameter.cpp \ InstanceDefinition.cpp \ ParameterMgrPlatformConnector.cpp \ - ComputedSizeParameterType.cpp \ - ComputedSizeParameter.cpp \ FixedPointParameterType.cpp \ ParameterAccessContext.cpp \ XmlFileIncluderElement.cpp \ diff --git a/parameter/AreaConfiguration.cpp b/parameter/AreaConfiguration.cpp index ecc84a7..d9d3fcf 100644 --- a/parameter/AreaConfiguration.cpp +++ b/parameter/AreaConfiguration.cpp @@ -91,7 +91,7 @@ void CAreaConfiguration::validateAgainst(const CAreaConfiguration* pValidAreaCon } // XML configuration settings parsing -bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext) +bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) { // Assign blackboard to configuration context configurationAccessContext.setParameterBlackboard(&_blackboard); @@ -99,12 +99,12 @@ bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSetti // Assign base offset to configuration context configurationAccessContext.setBaseOffset(_pConfigurableElement->getOffset()); - // Parse configuration settings - if (_pConfigurableElement->serializeXmlSettings(xmlConfigurationSettingsElement, configurationAccessContext)) { + // Parse configuration settings (element contents) + if (_pConfigurableElement->serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext)) { if (!configurationAccessContext.serializeOut()) { - // Serialized in areas are valid + // Serialized-in areas are valid _bValid = true; } return true; diff --git a/parameter/AreaConfiguration.h b/parameter/AreaConfiguration.h index 4e7e2f0..541a07f 100644 --- a/parameter/AreaConfiguration.h +++ b/parameter/AreaConfiguration.h @@ -69,7 +69,7 @@ public: void copyToInner(CAreaConfiguration* pToAreaConfiguration) const; // XML configuration settings parsing/composing - bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext); + bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); // Serialization void serialize(CBinaryStream& binaryStream); diff --git a/parameter/ArrayParameter.cpp b/parameter/ArrayParameter.cpp index 2cdae2f..abb3f6d 100644 --- a/parameter/ArrayParameter.cpp +++ b/parameter/ArrayParameter.cpp @@ -48,16 +48,16 @@ uint32_t CArrayParameter::getFootPrint() const } // XML configuration settings parsing -bool CArrayParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +bool CArrayParameter::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { // Check for value space - handleValueSpaceAttribute(xmlConfigurableElementSettingsElement, configurationAccessContext); + handleValueSpaceAttribute(xmlConfigurationSettingsElementContent, configurationAccessContext); // Handle access if (!configurationAccessContext.serializeOut()) { // Actually set values to blackboard - if (!setValues(0, configurationAccessContext.getBaseOffset(), xmlConfigurableElementSettingsElement.getTextContent(), configurationAccessContext)) { + if (!setValues(0, configurationAccessContext.getBaseOffset(), xmlConfigurationSettingsElementContent.getTextContent(), configurationAccessContext)) { return false; } @@ -70,7 +70,7 @@ bool CArrayParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSe getValues(configurationAccessContext.getBaseOffset(), strValue, configurationAccessContext); // Populate value into xml text node - xmlConfigurableElementSettingsElement.setTextContent(strValue); + xmlConfigurationSettingsElementContent.setTextContent(strValue); } // Done @@ -220,7 +220,7 @@ bool CArrayParameter::getIndex(CPathNavigator& pathNavigator, uint32_t& uiIndex, bool CArrayParameter::setValues(uint32_t uiStartIndex, uint32_t uiBaseOffset, const string& strValue, CParameterAccessContext& parameterContext) const { // Deal with value(s) - Tokenizer tok(strValue); + Tokenizer tok(strValue, DEFAULT_DELIMITER + ","); vector<string> astrValues = tok.split(); uint32_t uiNbValues = astrValues.size(); @@ -261,12 +261,22 @@ void CArrayParameter::getValues(uint32_t uiBaseOffset, string& strValues, CParam uint32_t uiSize = getSize(); uint32_t uiOffset = getOffset() - uiBaseOffset; + bool bFirst = true; + for (uiValueIndex = 0; uiValueIndex < _uiLength; uiValueIndex++) { string strReadValue; doGetValue(strReadValue, uiOffset, parameterContext); - strValues += strReadValue + " "; + if (!bFirst) { + + strValues += " "; + } else { + + bFirst = false; + } + + strValues += strReadValue; uiOffset += uiSize; } diff --git a/parameter/ArrayParameter.h b/parameter/ArrayParameter.h index b102d06..bcedfad 100644 --- a/parameter/ArrayParameter.h +++ b/parameter/ArrayParameter.h @@ -41,7 +41,7 @@ public: virtual uint32_t getFootPrint() const; // XML configuration settings parsing - virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; protected: // User set/get virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; diff --git a/parameter/BitParameter.cpp b/parameter/BitParameter.cpp index f687544..cb75477 100644 --- a/parameter/BitParameter.cpp +++ b/parameter/BitParameter.cpp @@ -54,13 +54,13 @@ uint32_t CBitParameter::getSize() const } // XML configuration settings parsing/composing -bool CBitParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +bool CBitParameter::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { // Handle access if (!configurationAccessContext.serializeOut()) { // Write to blackboard - if (!doSetValue(xmlConfigurableElementSettingsElement.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { + if (!doSetValue(xmlConfigurationSettingsElementContent.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { // Append parameter path to error configurationAccessContext.appendToError(" " + getPath()); @@ -75,7 +75,7 @@ bool CBitParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSett doGetValue(strValue, getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext); // Populate value into xml text node - xmlConfigurableElementSettingsElement.setTextContent(strValue); + xmlConfigurationSettingsElementContent.setTextContent(strValue); } // Done @@ -175,6 +175,6 @@ void CBitParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAc pBlackboard->read(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); // Convert - static_cast<const CBitParameterType*>(getTypeElement())->asString(uiData, strValue); + static_cast<const CBitParameterType*>(getTypeElement())->asString(uiData, strValue, parameterAccessContext); } diff --git a/parameter/BitParameter.h b/parameter/BitParameter.h index 15be074..41f449e 100644 --- a/parameter/BitParameter.h +++ b/parameter/BitParameter.h @@ -49,7 +49,7 @@ public: virtual Type getType() const; // XML configuration settings parsing/composing - virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; protected: // Parameter Access virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp index e12cd60..d9d1861 100644 --- a/parameter/BitParameterType.cpp +++ b/parameter/BitParameterType.cpp @@ -80,6 +80,10 @@ bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingCo // Conversion bool CBitParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const { + // Hexa + bool bValueProvidedAsHexa = !strValue.compare(0, 2, "0x"); + + // Get value uint32_t uiConvertedValue = strtoul(strValue.c_str(), NULL, 0); if (uiConvertedValue > getMaxValue()) { @@ -87,26 +91,41 @@ bool CBitParameterType::asInteger(const string& strValue, uint32_t& uiValue, CPa // Range exceeded ostringstream strStream; - strStream << strValue << " value out of range [0, " << getMaxValue() << "] for " + getKind(); + strStream << "Value " << strValue << " standing out of admitted range ["; + + if (bValueProvidedAsHexa) { + + strStream << "0x0, " << "0x" << hex << uppercase; + } else { + + strStream << "0, "; + } + strStream << getMaxValue() << "] for " + getKind(); parameterAccessContext.setError(strStream.str()); return false; } - // Do bitwise operation + // Do bitwise RMW operation uiValue = (uiValue & ~getMask()) | (uiConvertedValue << _uiBitPos); return true; } -void CBitParameterType::asString(const uint32_t& uiValue, string& strValue) const +void CBitParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const { uint32_t uiConvertedValue = (uiValue & getMask()) >> _uiBitPos; // Format ostringstream strStream; + // Take care of format + if (parameterAccessContext.valueSpaceIsRaw() && parameterAccessContext.outputRawFormatIsHex()) { + + strStream << "0x" << hex << uppercase; + } + strStream << uiConvertedValue; strValue = strStream.str(); @@ -134,3 +153,17 @@ uint32_t CBitParameterType::getMask() const { return getMaxValue() << _uiBitPos; } + +// Check data has no bit set outside available range +bool CBitParameterType::isEncodable(uint32_t uiData) const +{ + uint32_t uiShift = 32 - _uiBitSize; + + if (uiShift) { + + // Check high bits are clean + return !(uiData >> uiShift); + } + + return true; +} diff --git a/parameter/BitParameterType.h b/parameter/BitParameterType.h index 2a94922..f3f18b8 100644 --- a/parameter/BitParameterType.h +++ b/parameter/BitParameterType.h @@ -46,7 +46,7 @@ public: // Conversion bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; - void asString(const uint32_t& uiValue, string& strValue) const; + void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; // Bit Size uint32_t getBitSize() const; @@ -60,6 +60,8 @@ private: uint32_t getMaxValue() const; // Biwise mask uint32_t getMask() const; + // Check data has no bit set outside available range + bool isEncodable(uint32_t uiData) const; // Pos in bits uint32_t _uiBitPos; diff --git a/parameter/BooleanParameterType.cpp b/parameter/BooleanParameterType.cpp index d84d683..425596d 100644 --- a/parameter/BooleanParameterType.cpp +++ b/parameter/BooleanParameterType.cpp @@ -49,15 +49,26 @@ string CBooleanParameterType::getKind() const bool CBooleanParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const { - if (strValue == "1") { + if (strValue == "1" || strValue == "0x1") { uiValue = true; - } else if (strValue == "0") { + } else if (strValue == "0" || strValue == "0x0") { uiValue = false; } else { + parameterAccessContext.setError(strValue + " value not part of numerical space {"); - parameterAccessContext.setError(strValue + " value not part of numerical space {0, 1} for " + getKind()); + // Hexa + bool bValueProvidedAsHexa = !strValue.compare(0, 2, "0x"); + + if (bValueProvidedAsHexa) { + + parameterAccessContext.appendToError("0x0, 0x1"); + } else { + + parameterAccessContext.appendToError("0, 1"); + } + parameterAccessContext.appendToError("} for " + getKind()); return false; } @@ -67,7 +78,10 @@ bool CBooleanParameterType::asInteger(const string& strValue, uint32_t& uiValue, void CBooleanParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const { - (void)parameterAccessContext; + if (parameterAccessContext.valueSpaceIsRaw() && parameterAccessContext.outputRawFormatIsHex()) { + + strValue = "0x"; + } - strValue = uiValue ? "1" : "0"; + strValue += uiValue ? "1" : "0"; } diff --git a/parameter/ComponentInstance.cpp b/parameter/ComponentInstance.cpp index 12566d5..572de7a 100644 --- a/parameter/ComponentInstance.cpp +++ b/parameter/ComponentInstance.cpp @@ -50,10 +50,10 @@ bool CComponentInstance::childrenAreDynamic() const return true; } -bool CComponentInstance::getMappingData(const string& strKey, string& strValue) const +bool CComponentInstance::getMappingData(const string& strKey, const string*& pStrValue) const { // Try myself first then associated component type - return base::getMappingData(strKey, strValue) || (_pComponentType && _pComponentType->getMappingData(strKey, strValue)); + return base::getMappingData(strKey, pStrValue) || (_pComponentType && _pComponentType->getMappingData(strKey, pStrValue)); } bool CComponentInstance::hasMappingData() const diff --git a/parameter/ComponentInstance.h b/parameter/ComponentInstance.h index dffab7f..161d049 100644 --- a/parameter/ComponentInstance.h +++ b/parameter/ComponentInstance.h @@ -40,7 +40,7 @@ public: CComponentInstance(const string& strName); // Mapping info - virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; // From IXmlSink @@ -53,6 +53,7 @@ private: virtual CInstanceConfigurableElement* doInstantiate() const; virtual void populate(CElement* pElement) const; + // Related component type const CComponentType* _pComponentType; }; diff --git a/parameter/ComponentType.cpp b/parameter/ComponentType.cpp index ee83464..5a18803 100644 --- a/parameter/ComponentType.cpp +++ b/parameter/ComponentType.cpp @@ -50,10 +50,10 @@ bool CComponentType::childrenAreDynamic() const return true; } -bool CComponentType::getMappingData(const string& strKey, string& strValue) const +bool CComponentType::getMappingData(const string& strKey, const string*& pStrValue) const { // Try myself first then extended component type - return base::getMappingData(strKey, strValue) || (_pExtendsComponentType && _pExtendsComponentType->getMappingData(strKey, strValue)); + return base::getMappingData(strKey, pStrValue) || (_pExtendsComponentType && _pExtendsComponentType->getMappingData(strKey, pStrValue)); } bool CComponentType::hasMappingData() const diff --git a/parameter/ComponentType.h b/parameter/ComponentType.h index 0bd311b..a6e04cd 100644 --- a/parameter/ComponentType.h +++ b/parameter/ComponentType.h @@ -42,7 +42,7 @@ public: void populate(CElement* pElement) const; // Mapping info - virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; // From IXmlSink diff --git a/parameter/ComputedSizeParameter.cpp b/parameter/ComputedSizeParameter.cpp deleted file mode 100644 index 4d263da..0000000 --- a/parameter/ComputedSizeParameter.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* <auto_header> - * <FILENAME> - * - * INTEL CONFIDENTIAL - * Copyright © 2011 Intel - * Corporation All Rights Reserved. - * - * The source code contained or described herein and all documents related to - * the source code ("Material") are owned by Intel Corporation or its suppliers - * or licensors. Title to the Material remains with Intel Corporation or its - * suppliers and licensors. The Material contains trade secrets and proprietary - * and confidential information of Intel or its suppliers and licensors. The - * Material is protected by worldwide copyright and trade secret laws and - * treaty provisions. No part of the Material may be used, copied, reproduced, - * modified, published, uploaded, posted, transmitted, distributed, or - * disclosed in any way without Intel’s prior express written permission. - * - * No license under any patent, copyright, trade secret or other intellectual - * property right is granted to or conferred upon you by disclosure or delivery - * of the Materials, either expressly, by implication, inducement, estoppel or - * otherwise. Any license under such intellectual property rights must be - * express and approved by Intel in writing. - * - * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) - * CREATED: 2011-06-01 - * UPDATED: 2011-07-27 - * - * - * </auto_header> - */ -#include "ComputedSizeParameter.h" -#include "ConfigurableElement.h" -#include "ParameterType.h" -#include "InstanceConfigurableElement.h" -#include "ComputedSizeParameterType.h" -#include <assert.h> -#include <sstream> -#include "ParameterAccessContext.h" - -#define base CParameter - -CComputedSizeParameter::CComputedSizeParameter(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement), _pReferredElement(NULL) -{ -} - -uint32_t CComputedSizeParameter::getFootPrint() const -{ - // Virtual parameter - return 0; -} - -bool CComputedSizeParameter::init(string& strError) -{ - // Seek referred parameter in parent hierarchy - const CElement* pParent = getParent(); - - assert(pParent); - - _pReferredElement = static_cast<const CConfigurableElement*>(pParent->findChild(static_cast<const CComputedSizeParameterType*>(getTypeElement())->getReferredElementName())); - - if (!_pReferredElement) { - - strError = "Could not find referred Parameter " + getTypeElement()->getName() + " from " + getKind() + " " + getPath(); - - return false; - } - - return true; -} - -bool CComputedSizeParameter::doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) -{ - // Read only kind of parameter, can't be set! - (void)strValue; - (void)uiOffset; - - parameterAccessContext.setError("Read only parameter"); - - return false; -} - -void CComputedSizeParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const -{ - assert(_pReferredElement); - // Parameter can't be an array - assert(uiOffset == getOffset()); - - static_cast<const CParameterType*>(getTypeElement())->asString(_pReferredElement->getFootPrint(), strValue, parameterAccessContext); -} - diff --git a/parameter/ComputedSizeParameterType.cpp b/parameter/ComputedSizeParameterType.cpp deleted file mode 100644 index 02daf79..0000000 --- a/parameter/ComputedSizeParameterType.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* <auto_header> - * <FILENAME> - * - * INTEL CONFIDENTIAL - * Copyright © 2011 Intel - * Corporation All Rights Reserved. - * - * The source code contained or described herein and all documents related to - * the source code ("Material") are owned by Intel Corporation or its suppliers - * or licensors. Title to the Material remains with Intel Corporation or its - * suppliers and licensors. The Material contains trade secrets and proprietary - * and confidential information of Intel or its suppliers and licensors. The - * Material is protected by worldwide copyright and trade secret laws and - * treaty provisions. No part of the Material may be used, copied, reproduced, - * modified, published, uploaded, posted, transmitted, distributed, or - * disclosed in any way without Intel’s prior express written permission. - * - * No license under any patent, copyright, trade secret or other intellectual - * property right is granted to or conferred upon you by disclosure or delivery - * of the Materials, either expressly, by implication, inducement, estoppel or - * otherwise. Any license under such intellectual property rights must be - * express and approved by Intel in writing. - * - * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) - * CREATED: 2011-06-01 - * UPDATED: 2011-07-27 - * - * - * </auto_header> - */ -#include "ComputedSizeParameterType.h" -#include "ComputedSizeParameter.h" -#include <sstream> -#include <stdlib.h> - -#define base CParameterType - -CComputedSizeParameterType::CComputedSizeParameterType(const string& strName) : base(strName) -{ -} - -string CComputedSizeParameterType::getKind() const -{ - return "ComputedSizeParameter"; -} - -bool CComputedSizeParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) -{ - // Size - setSize(xmlElement.getAttributeInteger("Size") / 8); - - _strReferredElementName = xmlElement.getAttributeString("Parameter"); - - return base::fromXml(xmlElement, serializingContext); -} - -bool CComputedSizeParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const -{ - (void)parameterAccessContext; - - uiValue = strtoul(strValue.c_str(), NULL, 0); - - return true; -} - -void CComputedSizeParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const -{ - (void)parameterAccessContext; - - // Format - ostringstream strStream; - - strStream << uiValue; - - strValue = strStream.str(); -} - -const string& CComputedSizeParameterType::getReferredElementName() const -{ - return _strReferredElementName; -} - -CInstanceConfigurableElement* CComputedSizeParameterType::doInstantiate() const -{ - // Scalar parameter - return new CComputedSizeParameter(getName(), this); -} - diff --git a/parameter/ComputedSizeParameterType.h b/parameter/ComputedSizeParameterType.h deleted file mode 100644 index 63ae6b3..0000000 --- a/parameter/ComputedSizeParameterType.h +++ /dev/null @@ -1,54 +0,0 @@ -/* <auto_header> - * <FILENAME> - * - * INTEL CONFIDENTIAL - * Copyright © 2011 Intel - * Corporation All Rights Reserved. - * - * The source code contained or described herein and all documents related to - * the source code ("Material") are owned by Intel Corporation or its suppliers - * or licensors. Title to the Material remains with Intel Corporation or its - * suppliers and licensors. The Material contains trade secrets and proprietary - * and confidential information of Intel or its suppliers and licensors. The - * Material is protected by worldwide copyright and trade secret laws and - * treaty provisions. No part of the Material may be used, copied, reproduced, - * modified, published, uploaded, posted, transmitted, distributed, or - * disclosed in any way without Intel’s prior express written permission. - * - * No license under any patent, copyright, trade secret or other intellectual - * property right is granted to or conferred upon you by disclosure or delivery - * of the Materials, either expressly, by implication, inducement, estoppel or - * otherwise. Any license under such intellectual property rights must be - * express and approved by Intel in writing. - * - * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) - * CREATED: 2011-06-01 - * UPDATED: 2011-07-27 - * - * - * </auto_header> - */ -#pragma once - -#include "ParameterType.h" - -class CComputedSizeParameterType : public CParameterType -{ -public: - CComputedSizeParameterType(const string& strName); - - // From IXmlSink - virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); - - virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; - virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; - virtual string getKind() const; - - const string& getReferredElementName() const; - -private: - virtual CInstanceConfigurableElement* doInstantiate() const; - - string _strReferredElementName; -}; - diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp index 807171f..912fa5e 100644 --- a/parameter/ConfigurableDomain.cpp +++ b/parameter/ConfigurableDomain.cpp @@ -277,7 +277,38 @@ bool CConfigurableDomain::serializeConfigurableElementConfiguration(CDomainConfi // Actual XML context CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); - // Change context type for parameter settings access + // Element content + CXmlElement xmlConfigurationSettingsElementContent; + + // Deal with element itself + if (!bSerializeOut) { + + // Check structure + if (xmlConfigurationSettingsElement.getNbChildElements() != 1) { + + // Structure error + serializingContext.setError("Struture error encountered while parsing settinsg of " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " in Configuration " + pDomainConfiguration->getName() + " in Domain " + getName()); + + return false; + } + + // Check name and kind + if (!xmlConfigurationSettingsElement.getChildElement(pConfigurableElement->getKind(), pConfigurableElement->getName(), xmlConfigurationSettingsElementContent)) { + + serializingContext.setError("Couldn't find settings for " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " for Configuration " + pDomainConfiguration->getName() + " in Domain " + getName()); + + return false; + } + } else { + + // Create child XML element + xmlConfigurationSettingsElement.createChild(xmlConfigurationSettingsElementContent, pConfigurableElement->getKind()); + + // Set Name + xmlConfigurationSettingsElementContent.setNameAttribute(pConfigurableElement->getName()); + } + + // Change context type to parameter settings access string strError; // Create configuration access context @@ -286,6 +317,9 @@ bool CConfigurableDomain::serializeConfigurableElementConfiguration(CDomainConfi // Provide current value space configurationAccessContext.setValueSpaceRaw(xmlDomainSerializingContext.valueSpaceIsRaw()); + // Provide current output raw format + configurationAccessContext.setOutputRawFormat(xmlDomainSerializingContext.outputRawFormatIsHex()); + // Get subsystem const CSubsystem* pSubsystem = pConfigurableElement->getBelongingSubsystem(); @@ -298,7 +332,7 @@ bool CConfigurableDomain::serializeConfigurableElementConfiguration(CDomainConfi } // Have domain configuration parse settings for configurable element - if (!pDomainConfiguration->serializeXmlSettings(pConfigurableElement, xmlConfigurationSettingsElement, configurationAccessContext)) { + if (!pDomainConfiguration->serializeXmlSettings(pConfigurableElement, xmlConfigurationSettingsElementContent, configurationAccessContext)) { // Forward error xmlDomainSerializingContext.setError(strError); @@ -735,32 +769,7 @@ bool CConfigurableDomain::autoValidateConfiguration(CDomainConfiguration* pDomai } return false; } -#if 0 -void CConfigurableDomain::autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration) -{ - // Validate - ConfigurableElementListIterator it; - - // Browse all configurable elements for configuration validation - for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { - - const CConfigurableElement* pConfigurableElement = *it; - // Find first valid configuration for given configurable element - const CDomainConfiguration* pValidDomainConfiguration = findValidDomainConfiguration(pConfigurableElement); - - // Check valid configuration exists for that configurable element - if (pValidDomainConfiguration) { - - // Called on purpose - assert(pValidDomainConfiguration != pDomainConfiguration); - - // Validate - pDomainConfiguration->validateAgainst(pValidDomainConfiguration, pConfigurableElement); - } - } -} -#endif // Search for a valid configuration for given configurable element const CDomainConfiguration* CConfigurableDomain::findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const { diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index 1961b2f..fa794b3 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -32,6 +32,7 @@ #include "ConfigurableDomain.h" #include "ConfigurableElement.h" #include "BinaryStream.h" +#include "AutoLog.h" #define base CBinarySerializableElement @@ -67,7 +68,7 @@ void CConfigurableDomains::validate(const CParameterBlackboard* pMainBlackboard) // Configuration application if required bool CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError) { - log("Applying configurations"); + CAutoLog autoLog(this, "Applying configurations"); // Syncer set CSyncerSet syncerSet; @@ -359,8 +360,6 @@ bool CConfigurableDomains::saveConfiguration(const string& strDomain, const stri // Last applied configurations void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) const { - strResult = "\n"; - // Browse domains uint32_t uiChild; uint32_t uiNbConfigurableDomains = getNbChildren(); diff --git a/parameter/ConfigurableElement.cpp b/parameter/ConfigurableElement.cpp index 9707fb2..2fcde7a 100644 --- a/parameter/ConfigurableElement.cpp +++ b/parameter/ConfigurableElement.cpp @@ -34,6 +34,7 @@ #include "ConfigurableDomain.h" #include "ConfigurationAccessContext.h" #include "ConfigurableElementAggregator.h" +#include <sstream> #include <assert.h> #define base CElement @@ -47,14 +48,14 @@ CConfigurableElement::~CConfigurableElement() } // XML configuration settings parsing -bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { uint32_t uiIndex; uint32_t uiNbChildren = getNbChildren(); if (!configurationAccessContext.serializeOut()) { // Just do basic checks and propagate to children - CXmlElement::CChildIterator it(xmlConfigurableElementSettingsElement); + CXmlElement::CChildIterator it(xmlConfigurationSettingsElementContent); CXmlElement xmlChildConfigurableElementSettingsElement; @@ -113,7 +114,7 @@ bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElem // Create corresponding child element CXmlElement xmlChildConfigurableElementSettingsElement; - xmlConfigurableElementSettingsElement.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); + xmlConfigurationSettingsElementContent.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); // Handle element name attribute xmlChildConfigurableElementSettingsElement.setNameAttribute(pChildConfigurableElement->getName()); @@ -126,67 +127,6 @@ bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElem return true; } -#if 0 -bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const -{ - if (!configurationAccessContext.serializeOut()) { - // Just do basic checks and propagate to children - CXmlElement::CChildIterator it(xmlConfigurableElementSettingsElement); - - CXmlElement xmlChildConfigurableElementSettingsElement; - - while (it.next(xmlChildConfigurableElementSettingsElement)) { - - // Find child configurable element - const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(findChild(xmlChildConfigurableElementSettingsElement.getNameAttribute())); - - if (!pChildConfigurableElement) { - - configurationAccessContext.setError("Configuration settings parsing: Unable to find configurable element " + xmlChildConfigurableElementSettingsElement.getNameAttribute() + " under configurable element " + getName()); - - return false; - } - - // Check element type matches - if (xmlChildConfigurableElementSettingsElement.getType() != pChildConfigurableElement->getKind()) { - - configurationAccessContext.setError("Settings for configurable element " + pChildConfigurableElement->getName() + " does not match expected type: " + xmlChildConfigurableElementSettingsElement.getType() + " instead of " + pChildConfigurableElement->getKind()); - - return false; - } - - // Parse child configurable element's settings - if (!pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext)) { - - return false; - } - } - } else { - // Propagate to children - uint32_t uiIndex; - uint32_t uiNbChildren = getNbChildren(); - - for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { - - const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); - - // Create corresponding child element - CXmlElement xmlChildConfigurableElementSettingsElement; - - xmlConfigurableElementSettingsElement.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); - - // Handle element name attribute - xmlChildConfigurableElementSettingsElement.setNameAttribute(pChildConfigurableElement->getName()); - - // Propagate - pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext); - } - } - // Done - return true; -} -#endif - // Parameter access bool CConfigurableElement::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const { @@ -406,6 +346,17 @@ void CConfigurableElement::listRogueElements(string& strResult) const } } +// Footprint as string +string CConfigurableElement::getFootprintAsString() const +{ + // Get size as string + ostringstream str; + + str << getFootPrint() << " bytes"; + + return str.str(); +} + // Matching check for no domain association bool CConfigurableElement::hasNoDomainAssociated() const { diff --git a/parameter/ConfigurableElement.h b/parameter/ConfigurableElement.h index 5b61d3b..34ade12 100644 --- a/parameter/ConfigurableElement.h +++ b/parameter/ConfigurableElement.h @@ -78,6 +78,9 @@ public: // Elements with no domains void listRogueElements(string& strResult) const; + // Footprint as string + string getFootprintAsString() const; + // Parameter access virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; @@ -85,7 +88,7 @@ public: virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; // XML configuration settings parsing - virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; protected: // Syncer (me or ascendant) virtual ISyncer* getSyncer() const; diff --git a/parameter/DomainConfiguration.cpp b/parameter/DomainConfiguration.cpp index 4ab5f1d..8d5ebfb 100644 --- a/parameter/DomainConfiguration.cpp +++ b/parameter/DomainConfiguration.cpp @@ -63,7 +63,7 @@ bool CDomainConfiguration::childrenAreDynamic() const } // XML configuration settings parsing -bool CDomainConfiguration::serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext) +bool CDomainConfiguration::serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) { // Find related AreaConfiguration CAreaConfiguration* pAreaConfiguration = getAreaConfiguration(pConfigurableElement); @@ -71,7 +71,7 @@ bool CDomainConfiguration::serializeXmlSettings(const CConfigurableElement* pCon assert(pAreaConfiguration); // Delegate to corresponding area configuration - return pAreaConfiguration->serializeXmlSettings(xmlConfigurationSettingsElement, configurationAccessContext); + return pAreaConfiguration->serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext); } // Configurable Elements association diff --git a/parameter/DomainConfiguration.h b/parameter/DomainConfiguration.h index 27779ec..26b0c41 100644 --- a/parameter/DomainConfiguration.h +++ b/parameter/DomainConfiguration.h @@ -75,7 +75,7 @@ public: void split(CConfigurableElement* pFromConfigurableElement); // XML configuration settings parsing/composing - bool serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext); + bool serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); // Presence of application condition bool hasRule() const; diff --git a/parameter/Element.cpp b/parameter/Element.cpp index 8cc6783..7b892b0 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -300,6 +300,7 @@ string CElement::getPathName() const } } +// Hierarchy void CElement::addChild(CElement* pChild) { _childArray.push_back(pChild); @@ -366,11 +367,17 @@ void CElement::listChildren(string& strChildList) const string CElement::listQualifiedPaths(bool bDive, uint32_t uiLevel) const { - string strResult = getQualifiedPath() + "\n"; + uint32_t uiNbChildren = getNbChildren(); + string strResult; + + // Dive Will cause only leaf nodes to be printed + if (!bDive || !uiNbChildren) { + + strResult = getQualifiedPath() + "\n"; + } if (bDive || !uiLevel) { // Get list of children paths - uint32_t uiNbChildren = getNbChildren(); uint32_t uiChild; for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { @@ -385,8 +392,6 @@ string CElement::listQualifiedPaths(bool bDive, uint32_t uiLevel) const void CElement::listChildrenPaths(string& strChildList) const { - strChildList = "\n"; - // Get list of children paths uint32_t uiNbChildren = getNbChildren(); uint32_t uiChild; @@ -647,3 +652,16 @@ uint8_t CElement::computeStructureChecksum() const return uiChecksum; } +// Utility to underline +void CElement::appendTitle(string& strTo, const string& strTitle) +{ + strTo += "\n" + strTitle + "\n"; + + uint32_t uiLength = strTitle.size(); + + while (uiLength--) { + + strTo += "─"; + } + strTo += "\n"; +} diff --git a/parameter/Element.h b/parameter/Element.h index b3c3060..e31d772 100644 --- a/parameter/Element.h +++ b/parameter/Element.h @@ -106,6 +106,8 @@ protected: virtual void logValue(string& strValue, CErrorContext& errorContext) const; // Name setting void setName(const string& strName); + // Utility to underline + static void appendTitle(string& strTo, const string& strTitle); // Hierarchy CElement* getLastChild(); diff --git a/parameter/ElementBuilderTemplate.h b/parameter/ElementBuilderTemplate.h index 3a1c968..0a10e1a 100644 --- a/parameter/ElementBuilderTemplate.h +++ b/parameter/ElementBuilderTemplate.h @@ -33,10 +33,10 @@ #include "ElementBuilder.h" template <class ElementType> -class CElementBuilderTemplate : public CElementBuilder +class TElementBuilderTemplate : public CElementBuilder { public: - CElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + TElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} virtual CElement* createElement(const CXmlElement& xmlElement) const { diff --git a/parameter/FixedPointParameterType.cpp b/parameter/FixedPointParameterType.cpp index 86c9053..a3c9bc5 100644 --- a/parameter/FixedPointParameterType.cpp +++ b/parameter/FixedPointParameterType.cpp @@ -31,6 +31,8 @@ #include "FixedPointParameterType.h" #include <stdlib.h> #include <sstream> +#include <iomanip> +#include <assert.h> #include "Parameter.h" #include "ParameterAccessContext.h" #include "ConfigurationAccessContext.h" @@ -82,7 +84,7 @@ bool CFixedPointParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerial // Size vs. Q notation integrity check if (uiSizeInBits < getUtilSizeInBits()) { - serializingContext.setError("Inconsistent Size vs. Q notation for " + getKind() + " " + xmlElement.getPath() + ": Summing (Integral + _uiFractional + 1) should be less than given Size (" + xmlElement.getAttributeString("Size") + ")"); + serializingContext.setError("Inconsistent Size vs. Q notation for " + getKind() + " " + xmlElement.getPath() + ": Summing (Integral + _uiFractional + 1) should not exceed given Size (" + xmlElement.getAttributeString("Size") + ")"); return false; } @@ -95,40 +97,50 @@ bool CFixedPointParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerial bool CFixedPointParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const { - int32_t iData; + // Hexa + bool bValueProvidedAsHexa = !strValue.compare(0, 2, "0x"); - if (parameterAccessContext.valueSpaceIsRaw()) { + // Check data integrity + if (bValueProvidedAsHexa && !parameterAccessContext.valueSpaceIsRaw()) { - iData = strtol(strValue.c_str(), NULL, 0); + parameterAccessContext.setError("Hexadecimal values are not supported for " + getKind() + " when selected value space is real:"); - } else { - double dData = strtod(strValue.c_str(), NULL); - - // Do the conversion - iData = (int32_t)(dData * (1UL << _uiFractional) + 0.5F - (double)(dData < 0)); + return false; } - // Check for admitted range: [-2^m, 2^m - 2^n] - uint32_t uiSizeInBits = getUtilSizeInBits(); + int32_t iData; - int32_t iMin = ((int32_t)1 << 31) >> (32 - uiSizeInBits); - int32_t iMax = -iMin - 1; + if (parameterAccessContext.valueSpaceIsRaw()) { - if (iData < iMin || iData > iMax) { - ostringstream strStream; + // Get data in integer form + iData = strtol(strValue.c_str(), NULL, 0); - strStream << "Value " << strValue << " standing out of admitted "; + if (bValueProvidedAsHexa) { - if (!parameterAccessContext.valueSpaceIsRaw()) { + if (!isEncodable(iData)) { - strStream << "real range [" << (double)iMin / (1UL << _uiFractional) << ", "<< (double)iMax / (1UL << _uiFractional) << "]"; - } else { + // Illegal value provided + parameterAccessContext.setError(getOutOfRangeError(strValue, parameterAccessContext.valueSpaceIsRaw(), true)); + + return false; + } else { - strStream << "raw range [" << iMin << ", " << iMax << "]"; + // Sign extend + signExtend(iData); + } } - strStream << " for " << getKind(); - parameterAccessContext.setError(strStream.str()); + } else { + double dData = strtod(strValue.c_str(), NULL); + + // Do the conversion + iData = (int32_t)(dData * (1UL << _uiFractional) + 0.5F - (double)(dData < 0)); + } + // Check integrity + if (!isConsistent(iData, true)) { + + // Illegal value provided + parameterAccessContext.setError(getOutOfRangeError(strValue, parameterAccessContext.valueSpaceIsRaw(), bValueProvidedAsHexa)); return false; } @@ -140,22 +152,28 @@ bool CFixedPointParameterType::asInteger(const string& strValue, uint32_t& uiVal void CFixedPointParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const { - int32_t iData = (int32_t)uiValue; + int32_t iData = uiValue; - // Sign extend - uint32_t uiShift = 32 - getUtilSizeInBits(); - - if (uiShift) { + // Check consistency + assert(isEncodable(iData)); - iData = (iData << uiShift) >> uiShift; - } + // Sign extend + signExtend(iData); // Format ostringstream strStream; + // Raw formatting? if (parameterAccessContext.valueSpaceIsRaw()) { - strStream << iData; + // Hexa formatting? + if (parameterAccessContext.outputRawFormatIsHex()) { + + strStream << "0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << uiValue; + } else { + + strStream << iData; + } } else { double dData = (double)iData / (1UL << _uiFractional); @@ -171,3 +189,38 @@ uint32_t CFixedPointParameterType::getUtilSizeInBits() const { return _uiIntegral + _uiFractional + 1; } + +// Out of range error +string CFixedPointParameterType::getOutOfRangeError(const string& strValue, bool bRawValueSpace, bool bHexaValue) const +{ + // Min/Max computation + int32_t iMin = ((int32_t)1 << 31) >> (32 - getUtilSizeInBits()); + int32_t iMax = -iMin - 1; + + ostringstream strStream; + + strStream << "Value " << strValue << " standing out of admitted "; + + if (!bRawValueSpace) { + + strStream << "real range [" << (double)iMin / (1UL << _uiFractional) << ", "<< (double)iMax / (1UL << _uiFractional) << "]"; + } else { + + strStream << "raw range ["; + + if (bHexaValue) { + + strStream << "0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << makeEncodable(iMin); + strStream << ", 0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << makeEncodable(iMax); + + } else { + + strStream << iMin << ", " << iMax; + } + + strStream << "]"; + } + strStream << " for " << getKind(); + + return strStream.str(); +} diff --git a/parameter/FixedPointParameterType.h b/parameter/FixedPointParameterType.h index 4aaf5a0..c0ffef3 100644 --- a/parameter/FixedPointParameterType.h +++ b/parameter/FixedPointParameterType.h @@ -53,6 +53,8 @@ public: private: // Util size uint32_t getUtilSizeInBits() const; + // Out of range error + string getOutOfRangeError(const string& strValue, bool bRawValueSpace, bool bHexaValue) const; // Integral part in Q notation uint32_t _uiIntegral; diff --git a/parameter/FrameworkConfigurationLocation.cpp b/parameter/FrameworkConfigurationLocation.cpp index 77c8d71..22f1c7f 100644 --- a/parameter/FrameworkConfigurationLocation.cpp +++ b/parameter/FrameworkConfigurationLocation.cpp @@ -51,6 +51,7 @@ bool CFrameworkConfigurationLocation::fromXml(const CXmlElement& xmlElement, CXm return true; } +// File path string CFrameworkConfigurationLocation::getFilePath(const string& strBaseFolder) const { if (isPathRelative()) { @@ -60,11 +61,7 @@ string CFrameworkConfigurationLocation::getFilePath(const string& strBaseFolder) return _strPath; } -bool CFrameworkConfigurationLocation::isPathRelative() const -{ - return _strPath[0] != '/'; -} - +// Folder path string CFrameworkConfigurationLocation::getFolderPath(const string& strBaseFolder) const { uint32_t uiSlashPos = _strPath.rfind('/', -1); @@ -93,17 +90,8 @@ string CFrameworkConfigurationLocation::getFolderPath(const string& strBaseFolde } } -#if 0 -string CFrameworkConfigurationLocation::getFileName() const +// Detect relative path +bool CFrameworkConfigurationLocation::isPathRelative() const { - uint32_t uiSlashPos = _strPath.rfind('/', -1); - - if (uiSlashPos != (uint32_t)-1) { - - return _strPath.substr(uiSlashPos + 1, _strPath.size() - uiSlashPos - 1); - } else { - - return _strPath; - } + return _strPath[0] != '/'; } -#endif diff --git a/parameter/FrameworkConfigurationLocation.h b/parameter/FrameworkConfigurationLocation.h index 2b3bd9a..6becfe5 100644 --- a/parameter/FrameworkConfigurationLocation.h +++ b/parameter/FrameworkConfigurationLocation.h @@ -37,13 +37,18 @@ class CFrameworkConfigurationLocation : public CKindElement public: CFrameworkConfigurationLocation(const string& strName, const string& strKind); + // File path string getFilePath(const string& strBaseFolder) const; + + // Folder path string getFolderPath(const string& strBaseFolder) const; // From IXmlSink virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); private: + // Detect relative path bool isPathRelative() const; + // Path string _strPath; }; diff --git a/parameter/InstanceConfigurableElement.cpp b/parameter/InstanceConfigurableElement.cpp index 9dcc2ef..fdce2b7 100644 --- a/parameter/InstanceConfigurableElement.cpp +++ b/parameter/InstanceConfigurableElement.cpp @@ -55,10 +55,10 @@ const CTypeElement* CInstanceConfigurableElement::getTypeElement() const } // Mapping -bool CInstanceConfigurableElement::getMappingData(const string& strKey, string& strValue) const +bool CInstanceConfigurableElement::getMappingData(const string& strKey, const string*& pStrValue) const { // Delegate - return getTypeElement()->getMappingData(strKey, strValue); + return getTypeElement()->getMappingData(strKey, pStrValue); } bool CInstanceConfigurableElement::map(IMapper& mapper, string& strError) @@ -139,7 +139,7 @@ bool CInstanceConfigurableElement::sync(CParameterAccessContext& parameterAccess if (!pSyncer) { - parameterAccessContext.setError("Unable to synchronize modification. No Syncer object assiciated to configurable element " + getPath()); + parameterAccessContext.setError("Unable to synchronize modification. No Syncer object associated to configurable element " + getPath()); return false; } diff --git a/parameter/InstanceConfigurableElement.h b/parameter/InstanceConfigurableElement.h index 517646c..4a032d4 100644 --- a/parameter/InstanceConfigurableElement.h +++ b/parameter/InstanceConfigurableElement.h @@ -54,7 +54,7 @@ public: const CTypeElement* getTypeElement() const; // Mapping info - bool getMappingData(const string& strKey, string& strValue) const; + bool getMappingData(const string& strKey, const string*& pStrValue) const; // From CElement virtual string getKind() const; diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp index 14093ff..72491a2 100644 --- a/parameter/IntegerParameterType.cpp +++ b/parameter/IntegerParameterType.cpp @@ -31,6 +31,7 @@ #include "IntegerParameterType.h" #include <stdlib.h> #include <sstream> +#include <iomanip> #include "ParameterAccessContext.h" #define base CParameterType @@ -91,48 +92,72 @@ bool CIntegerParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializi bool CIntegerParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const { - uiValue = strtoul(strValue.c_str(), NULL, 0); + // Hexa + bool bValueProvidedAsHexa = !strValue.compare(0, 2, "0x"); + // Get value + int32_t iData; + + if (_bSigned) { + + iData = strtoul(strValue.c_str(), NULL, 0); + } else { + + iData = strtol(strValue.c_str(), NULL, 0); + } + + if (bValueProvidedAsHexa) { + + if (isEncodable(iData)) { + + // Sign extend + signExtend(iData); + } + } // Check against Min / Max if (_bSigned) { - if (!checkValueAgainstRange<int32_t>(uiValue, parameterAccessContext)) { + if (!checkValueAgainstRange<int32_t>(strValue, iData, parameterAccessContext, bValueProvidedAsHexa)) { return false; } } else { - if (!checkValueAgainstRange<uint32_t>(uiValue, parameterAccessContext)) { + if (!checkValueAgainstRange<uint32_t>(strValue, iData, parameterAccessContext, bValueProvidedAsHexa)) { return false; } } + uiValue = iData; + return true; } void CIntegerParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const { - (void)parameterAccessContext; - // Format ostringstream strStream; - if (_bSigned) { - // Sign extend - uint32_t uiShift = (4 - getSize()) << 3; + // Take care of format + if (parameterAccessContext.valueSpaceIsRaw() && parameterAccessContext.outputRawFormatIsHex()) { - int32_t iValue = (int32_t)uiValue; + // Hexa display with unecessary bits cleared out + strStream << "0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << makeEncodable(uiValue); + } else { - if (uiShift) { + if (_bSigned) { - iValue = (iValue << uiShift) >> uiShift; - } + int32_t iValue = uiValue; - strStream << iValue; - } else { + // Sign extend + signExtend(iValue); - strStream << uiValue; + strStream << iValue; + } else { + + strStream << uiValue; + } } strValue = strStream.str(); @@ -145,12 +170,27 @@ uint32_t CIntegerParameterType::getDefaultValue() const } // Range checking -template <class type> bool CIntegerParameterType::checkValueAgainstRange(type value, CParameterAccessContext& parameterAccessContext) const +template <typename type> bool CIntegerParameterType::checkValueAgainstRange(const string& strValue, type value, CParameterAccessContext& parameterAccessContext, bool bHexaValue) const { if ((type)value < (type)_uiMin || (type)value > (type)_uiMax) { + ostringstream strStream; - strStream << "Value " << value << " standing out of admitted range: [" << (type)_uiMin << ", " << (type)_uiMax << "] for " << getKind(); + strStream << "Value " << strValue << " standing out of admitted range ["; + + if (bHexaValue) { + + // Format Min + strStream << "0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << makeEncodable(_uiMin); + // Format Max + strStream << ", 0x" << hex << uppercase << setw(getSize()*2) << setfill('0') << makeEncodable(_uiMax); + + } else { + + strStream << (type)_uiMin << ", " << (type)_uiMax; + } + + strStream << "] for " << getKind(); parameterAccessContext.setError(strStream.str()); diff --git a/parameter/IntegerParameterType.h b/parameter/IntegerParameterType.h index f1b3e64..db4be41 100644 --- a/parameter/IntegerParameterType.h +++ b/parameter/IntegerParameterType.h @@ -51,7 +51,7 @@ public: virtual string getKind() const; private: // Range checking - template <class type> bool checkValueAgainstRange(type value, CParameterAccessContext& parameterAccessContext) const; + template <typename type> bool checkValueAgainstRange(const string& strValue, type value, CParameterAccessContext& parameterAccessContext, bool bHexaValue) const; // Signing bool _bSigned; diff --git a/parameter/KindElementBuilderTemplate.h b/parameter/KindElementBuilderTemplate.h index 3f6677b..f75882a 100644 --- a/parameter/KindElementBuilderTemplate.h +++ b/parameter/KindElementBuilderTemplate.h @@ -33,10 +33,10 @@ #include "ElementBuilder.h" template <class ElementType> -class CKindElementBuilderTemplate : public CElementBuilder +class TKindElementBuilderTemplate : public CElementBuilder { public: - CKindElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + TKindElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} virtual CElement* createElement(const CXmlElement& xmlElement) const { diff --git a/parameter/MappingContext.cpp b/parameter/MappingContext.cpp index 2f36c97..c460ab8 100644 --- a/parameter/MappingContext.cpp +++ b/parameter/MappingContext.cpp @@ -32,10 +32,10 @@ #include <string.h> #include <stdlib.h> -CMappingContext::CMappingContext(uint32_t uiNbItems) : _pstItemArray(new CMappingContext::SItem[uiNbItems]), _uiNbItems(uiNbItems) +CMappingContext::CMappingContext(uint32_t uiNbItemTypes) : _pstItemArray(new CMappingContext::SItem[uiNbItemTypes]), _uiNbItemTypes(uiNbItemTypes) { // Clear items - memset(_pstItemArray, 0, sizeof(*_pstItemArray) * uiNbItems); + memset(_pstItemArray, 0, sizeof(*_pstItemArray) * uiNbItemTypes); } CMappingContext::~CMappingContext() @@ -44,10 +44,10 @@ CMappingContext::~CMappingContext() } // Copy constructor -CMappingContext::CMappingContext(const CMappingContext& from) : _pstItemArray(new CMappingContext::SItem[from._uiNbItems]), _uiNbItems(from._uiNbItems) +CMappingContext::CMappingContext(const CMappingContext& from) : _pstItemArray(new CMappingContext::SItem[from._uiNbItemTypes]), _uiNbItemTypes(from._uiNbItemTypes) { // Copy content items - memcpy(_pstItemArray, from._pstItemArray, sizeof(*_pstItemArray) * _uiNbItems); + memcpy(_pstItemArray, from._pstItemArray, sizeof(*_pstItemArray) * _uiNbItemTypes); } // Affectation @@ -56,23 +56,23 @@ const CMappingContext& CMappingContext::operator=(const CMappingContext& right) if (&right != this) { // Size - _uiNbItems = right._uiNbItems; + _uiNbItemTypes = right._uiNbItemTypes; // Content // Delete previous array delete [] _pstItemArray; // Reallocate it - _pstItemArray = new CMappingContext::SItem[_uiNbItems]; + _pstItemArray = new CMappingContext::SItem[_uiNbItemTypes]; // Copy content items - memcpy(_pstItemArray, right._pstItemArray, sizeof(*_pstItemArray) * _uiNbItems); + memcpy(_pstItemArray, right._pstItemArray, sizeof(*_pstItemArray) * _uiNbItemTypes); } return *this; } // Item access -bool CMappingContext::setItem(uint32_t uiItemType, const string& strItem) +bool CMappingContext::setItem(uint32_t uiItemType, const string* pStrItem) { // Do some checks if (_pstItemArray[uiItemType].bSet) { @@ -81,7 +81,7 @@ bool CMappingContext::setItem(uint32_t uiItemType, const string& strItem) return false; } // Get item value - _pstItemArray[uiItemType].uiItem = strtoul(strItem.c_str(), NULL, 0); + _pstItemArray[uiItemType].strItem = pStrItem; // Now is set _pstItemArray[uiItemType].bSet = true; @@ -89,9 +89,19 @@ bool CMappingContext::setItem(uint32_t uiItemType, const string& strItem) return true; } -uint32_t CMappingContext::getItem(uint32_t uiItemType) const +const string& CMappingContext::getItem(uint32_t uiItemType) const { - return _pstItemArray[uiItemType].uiItem; + return *_pstItemArray[uiItemType].strItem; +} + +uint32_t CMappingContext::getItemAsInteger(uint32_t uiItemType) const +{ + if (!_pstItemArray[uiItemType].strItem) { + + return 0; + } + + return strtoul(_pstItemArray[uiItemType].strItem->c_str(), NULL, 0); } bool CMappingContext::iSet(uint32_t uiItemType) const diff --git a/parameter/MappingContext.h b/parameter/MappingContext.h index aca9349..40f8438 100644 --- a/parameter/MappingContext.h +++ b/parameter/MappingContext.h @@ -39,13 +39,13 @@ class CMappingContext { // Item structure struct SItem { - uint32_t uiItem; + const string* strItem; bool bSet; }; public: // Regular Constructor - CMappingContext(uint32_t uiNbItems); + CMappingContext(uint32_t uiNbItemTypes); ~CMappingContext(); // Copy constructor @@ -55,13 +55,14 @@ public: const CMappingContext& operator=(const CMappingContext& right); // Item access - bool setItem(uint32_t uiItemType, const string& strItem); - uint32_t getItem(uint32_t uiItemType) const; + bool setItem(uint32_t uiItemType, const string* pStrItem); + const string& getItem(uint32_t uiItemType) const; + uint32_t getItemAsInteger(uint32_t uiItemType) const; bool iSet(uint32_t uiItemType) const; private: // Item array SItem* _pstItemArray; // Items array size - uint32_t _uiNbItems; + uint32_t _uiNbItemTypes; }; diff --git a/parameter/MappingData.cpp b/parameter/MappingData.cpp index 7975eb8..145d522 100644 --- a/parameter/MappingData.cpp +++ b/parameter/MappingData.cpp @@ -42,7 +42,7 @@ bool CMappingData::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext string strMapping = xmlElement.getAttributeString("Mapping"); - Tokenizer mappingTok(strMapping, ", "); + Tokenizer mappingTok(strMapping, ","); string strMappingElement; @@ -63,13 +63,13 @@ bool CMappingData::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext return true; } -bool CMappingData::getValue(const string& strkey, string& strValue) const +bool CMappingData::getValue(const string& strkey, const string*& pStrValue) const { KeyToValueMapConstIterator it = _keyToValueMap.find(strkey); if (it != _keyToValueMap.end()) { - strValue = it->second; + pStrValue = &it->second; return true; } diff --git a/parameter/MappingData.h b/parameter/MappingData.h index 99be431..df140da 100644 --- a/parameter/MappingData.h +++ b/parameter/MappingData.h @@ -46,7 +46,7 @@ public: virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); // Query - bool getValue(const string& strkey, string& strValue) const; + bool getValue(const string& strkey, const string*& pStrValue) const; private: bool addValue(const string& strkey, const string& strValue); diff --git a/parameter/NamedElementBuilderTemplate.h b/parameter/NamedElementBuilderTemplate.h index 82bf2e1..793c3ac 100644 --- a/parameter/NamedElementBuilderTemplate.h +++ b/parameter/NamedElementBuilderTemplate.h @@ -33,10 +33,10 @@ #include "ElementBuilder.h" template <class ElementType> -class CNamedElementBuilderTemplate : public CElementBuilder +class TNamedElementBuilderTemplate : public CElementBuilder { public: - CNamedElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + TNamedElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} virtual CElement* createElement(const CXmlElement& xmlElement) const { diff --git a/parameter/Parameter.cpp b/parameter/Parameter.cpp index 5f1f389..57a78b1 100644 --- a/parameter/Parameter.cpp +++ b/parameter/Parameter.cpp @@ -50,16 +50,16 @@ CInstanceConfigurableElement::Type CParameter::getType() const } // XML configuration settings parsing/composing -bool CParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +bool CParameter::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { // Check for value space - handleValueSpaceAttribute(xmlConfigurableElementSettingsElement, configurationAccessContext); + handleValueSpaceAttribute(xmlConfigurationSettingsElementContent, configurationAccessContext); // Handle access if (!configurationAccessContext.serializeOut()) { // Write to blackboard - if (!doSetValue(xmlConfigurableElementSettingsElement.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { + if (!doSetValue(xmlConfigurationSettingsElementContent.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { // Append parameter path to error configurationAccessContext.appendToError(" " + getPath()); @@ -74,7 +74,7 @@ bool CParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSetting doGetValue(strValue, getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext); // Populate value into xml text node - xmlConfigurableElementSettingsElement.setTextContent(strValue); + xmlConfigurationSettingsElementContent.setTextContent(strValue); } // Done diff --git a/parameter/Parameter.h b/parameter/Parameter.h index dcb535f..c62f151 100644 --- a/parameter/Parameter.h +++ b/parameter/Parameter.h @@ -50,7 +50,7 @@ public: virtual Type getType() const; // XML configuration settings parsing/composing - virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; protected: // Parameter Access virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; @@ -59,9 +59,9 @@ protected: // Used for simulation only virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; - // To be implemented by derived - virtual bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; - virtual void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + // Actual value access + bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; // Value space handling for configuration import void handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; diff --git a/parameter/ParameterAccessContext.cpp b/parameter/ParameterAccessContext.cpp index 1508d73..e296d23 100644 --- a/parameter/ParameterAccessContext.cpp +++ b/parameter/ParameterAccessContext.cpp @@ -32,13 +32,16 @@ #define base CErrorContext -CParameterAccessContext::CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw) : - base(strError), _pParameterBlackboard(pParameterBlackboard), _bValueSpaceIsRaw(bValueSpaceIsRaw), _bBigEndianSubsystem(false), _bAutoSync(true) +CParameterAccessContext::CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex) : + base(strError), _pParameterBlackboard(pParameterBlackboard), + _bValueSpaceIsRaw(bValueSpaceIsRaw), _bOutputRawFormatIsHex(bOutputRawFormatIsHex), + _bBigEndianSubsystem(false), _bAutoSync(true) { } CParameterAccessContext::CParameterAccessContext(string& strError) : - base(strError), _pParameterBlackboard(NULL), _bValueSpaceIsRaw(false), _bBigEndianSubsystem(false), _bAutoSync(true) + base(strError), _pParameterBlackboard(NULL), _bValueSpaceIsRaw(false), + _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(false), _bAutoSync(true) { } @@ -64,6 +67,17 @@ bool CParameterAccessContext::valueSpaceIsRaw() const return _bValueSpaceIsRaw; } +// Output Raw Format for user get value interpretation +void CParameterAccessContext::setOutputRawFormat(bool bIsHex) +{ + _bOutputRawFormatIsHex = bIsHex; +} + +bool CParameterAccessContext::outputRawFormatIsHex() +{ + return _bOutputRawFormatIsHex; +} + // Endianness void CParameterAccessContext::setBigEndianSubsystem(bool bBigEndian) { diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h index dbeb730..cfdca7f 100644 --- a/parameter/ParameterAccessContext.h +++ b/parameter/ParameterAccessContext.h @@ -37,17 +37,21 @@ class CParameterBlackboard; class CParameterAccessContext : public CErrorContext { public: - CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw); + CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex); CParameterAccessContext(string& strError); // ParameterBlackboard CParameterBlackboard* getParameterBlackboard(); void setParameterBlackboard(CParameterBlackboard* pBlackboard); - // Value interpretation as Real or Raw (usefull for Fixed point parameters) + // Value interpretation as Real or Raw void setValueSpaceRaw(bool bIsRaw); bool valueSpaceIsRaw() const; + // Output Raw Format for user get value interpretation + void setOutputRawFormat(bool bIsHex); + bool outputRawFormatIsHex(); + // Endianness void setBigEndianSubsystem(bool bBigEndian); bool isBigEndianSubsystem() const; @@ -61,6 +65,8 @@ private: CParameterBlackboard* _pParameterBlackboard; // Value space bool _bValueSpaceIsRaw; + // Output Raw Format + bool _bOutputRawFormatIsHex; // Subsystem Endianness bool _bBigEndianSubsystem; // Automatic synchronization to HW diff --git a/parameter/ParameterBlackboard.cpp b/parameter/ParameterBlackboard.cpp index ecf4476..242c6a8 100644 --- a/parameter/ParameterBlackboard.cpp +++ b/parameter/ParameterBlackboard.cpp @@ -32,26 +32,26 @@ #include <string.h> #include <assert.h> -CParameterBlackboard::CParameterBlackboard() : _puiData(NULL), _uiSize(0) +CParameterBlackboard::CParameterBlackboard() : _pucData(NULL), _uiSize(0) { } CParameterBlackboard::~CParameterBlackboard() { - delete [] _puiData; + delete [] _pucData; } // Size void CParameterBlackboard::setSize(uint32_t uiSize) { - if (_puiData) { + if (_pucData) { - delete [] _puiData; + delete [] _pucData; } - _puiData = new uint8_t[uiSize]; + _pucData = new uint8_t[uiSize]; - memset(_puiData, 0, uiSize); + memset(_pucData, 0, uiSize); _uiSize = uiSize; } @@ -68,7 +68,7 @@ void CParameterBlackboard::write(const void* pvSrcData, uint32_t uiSize, uint32_ if (!bBigEndian) { - memcpy(_puiData + uiOffset, pvSrcData, uiSize); + memcpy(_pucData + uiOffset, pvSrcData, uiSize); } else { uint32_t uiIndex; @@ -76,7 +76,7 @@ void CParameterBlackboard::write(const void* pvSrcData, uint32_t uiSize, uint32_ for (uiIndex = 0; uiIndex < uiSize; uiIndex++) { - _puiData[uiIndex + uiOffset] = puiSrcData[uiSize - uiIndex - 1]; + _pucData[uiIndex + uiOffset] = puiSrcData[uiSize - uiIndex - 1]; } } } @@ -87,7 +87,7 @@ void CParameterBlackboard::read(void* pvDstData, uint32_t uiSize, uint32_t uiOff if (!bBigEndian) { - memcpy(pvDstData, _puiData + uiOffset, uiSize); + memcpy(pvDstData, _pucData + uiOffset, uiSize); } else { uint32_t uiIndex; @@ -95,35 +95,26 @@ void CParameterBlackboard::read(void* pvDstData, uint32_t uiSize, uint32_t uiOff for (uiIndex = 0; uiIndex < uiSize; uiIndex++) { - puiDstData[uiSize - uiIndex - 1] = _puiData[uiIndex + uiOffset]; + puiDstData[uiSize - uiIndex - 1] = _pucData[uiIndex + uiOffset]; } } } // Access from/to subsystems -void CParameterBlackboard::rawRead(void* pvDstData, uint32_t uiSize, uint32_t uiOffset) const +uint8_t* CParameterBlackboard::getLocation(uint32_t uiOffset) { - assert(uiSize + uiOffset <= _uiSize); - - memcpy(pvDstData, _puiData + uiOffset, uiSize); -} - -void CParameterBlackboard::rawWrite(const void* pvDstData, uint32_t uiSize, uint32_t uiOffset) -{ - assert(uiSize + uiOffset <= _uiSize); - - memcpy(_puiData + uiOffset, pvDstData, uiSize); + return _pucData + uiOffset; } // Configuration handling void CParameterBlackboard::restoreFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset) { - memcpy(_puiData + uiOffset, pFromBlackboard->_puiData, pFromBlackboard->_uiSize); + memcpy(_pucData + uiOffset, pFromBlackboard->_pucData, pFromBlackboard->_uiSize); } void CParameterBlackboard::saveTo(CParameterBlackboard* pToBlackboard, uint32_t uiOffset) const { - memcpy(pToBlackboard->_puiData, _puiData + uiOffset, pToBlackboard->_uiSize); + memcpy(pToBlackboard->_pucData, _pucData + uiOffset, pToBlackboard->_uiSize); } // Serialization @@ -131,9 +122,9 @@ void CParameterBlackboard::serialize(CBinaryStream& binaryStream) { if (binaryStream.isOut()) { - binaryStream.write(_puiData, _uiSize); + binaryStream.write(_pucData, _uiSize); } else { - binaryStream.read(_puiData, _uiSize); + binaryStream.read(_pucData, _uiSize); } } diff --git a/parameter/ParameterBlackboard.h b/parameter/ParameterBlackboard.h index 5812d0b..da4fc7b 100644 --- a/parameter/ParameterBlackboard.h +++ b/parameter/ParameterBlackboard.h @@ -50,8 +50,7 @@ public: void read(void* pvDstData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian) const; // Access from/to subsystems - void rawRead(void* pvDstData, uint32_t uiSize, uint32_t uiOffset) const; - void rawWrite(const void* pvDstData, uint32_t uiSize, uint32_t uiOffset); + uint8_t* getLocation(uint32_t uiOffset); // Configuration handling void restoreFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset); @@ -60,7 +59,7 @@ public: // Serialization void serialize(CBinaryStream& binaryStream); private: - uint8_t* _puiData; + uint8_t* _pucData; uint32_t _uiSize; }; diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index b9e9f30..3ff76a5 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -50,7 +50,6 @@ #include "FixedPointParameterType.h" #include "ParameterBlackboard.h" #include "Parameter.h" -#include "ComputedSizeParameterType.h" #include "ParameterBlackboard.h" #include "ParameterAccessContext.h" #include "XmlFileIncluderElement.h" @@ -75,7 +74,6 @@ #include <strings.h> #include <dlfcn.h> #include <assert.h> -#include <sstream> #define base CElement @@ -112,12 +110,17 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gaRemoteCommandPars { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" }, { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" }, /// Value Space - { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for fixed point integer value interpretation" }, + { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" }, { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" }, + /// Output Raw Format + { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" }, + { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" }, /// Sync { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" }, { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" }, { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" }, + /// Criteria + { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List available selection criteria" }, /// Domains { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" }, { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" }, @@ -136,7 +139,7 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gaRemoteCommandPars { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" }, /// Elements/Parameters { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" }, - { "listElementsRecursive", &CParameterMgr::listElementsRecursiveCommmandProcess, 1, "<elem path>|/", "Recursively list elements under element at given path or root" }, + { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "Recursively list elements under element at given path or root" }, { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" }, { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" }, { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<elem ath>", "Get value for parameter at given path" }, @@ -161,6 +164,7 @@ const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gaRemoteCom CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) : _bTuningModeIsOn(false), _bValueSpaceIsRaw(false), + _bOutputRawFormatIsHex(false), _bAutoSyncOn(true), _pMainParameterBlackboard(new CParameterBlackboard), _pElementLibrarySet(new CElementLibrarySet), @@ -370,6 +374,8 @@ bool CParameterMgr::loadStructure(string& strError) // Parse Structure XML file CXmlParameterSerializingContext parameterBuildContext(strError); + log("Importing system structure from file %s", strXmlStructureFilePath.c_str()); + if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { return false; @@ -432,6 +438,8 @@ bool CParameterMgr::loadSettings(string& strError) // Selection criteria definition for rule creation xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with"); + // Do parse if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { @@ -544,7 +552,7 @@ CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strNa // Selection criteria changed event void CParameterMgr::selectionCriterionChanged(const CSelectionCriterion* pSelectionCriterion) { - CAutoLog autoLog(this, pSelectionCriterion->getName() + " selection criterion changed event"); + CAutoLog autoLog(this, "Selection criterion changed event: " + pSelectionCriterion->getFormattedDescription(false)); // Lock state pthread_mutex_lock(&_tuningModeMutex); @@ -665,41 +673,52 @@ CParameterMgr::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCo // System class const CSystemClass* pSystemClass = getSystemClass(); - strResult = "\n"; - // Show status - /// System class + /// General section + appendTitle(strResult, "General:"); + // System class strResult += "System Class: "; strResult += pSystemClass->getName(); strResult += "\n"; - /// Tuning mode + // Tuning mode strResult += "Tuning Mode: "; strResult += tuningModeOn() ? "on" : "off"; strResult += "\n"; - /// Value space + // Value space strResult += "Value Space: "; strResult += valueSpaceIsRaw() ? "raw" : "real"; strResult += "\n"; - /// Value space + // Output raw format + strResult += "Output Raw Format: "; + strResult += outputRawFormatIsHex() ? "hex" : "dec"; + strResult += "\n"; + + // Auto Sync strResult += "Auto Sync: "; strResult += autoSyncOn() ? "on" : "off"; strResult += "\n"; /// Subsystem list - strResult += "\nSubsystems:"; + appendTitle(strResult, "Subsystems:"); string strSubsystemList; pSystemClass->listChildrenPaths(strSubsystemList); strResult += strSubsystemList; /// Last applied configurations - strResult += "\nLast applied configurations:"; + appendTitle(strResult, "Last applied configurations:"); string strLastAppliedConfigurations; getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); strResult += strLastAppliedConfigurations; + /// Criteria states + appendTitle(strResult, "Selection criteria:"); + string strSelectionCriteria; + getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false); + strResult += strSelectionCriteria; + return ESucceeded; } @@ -767,6 +786,39 @@ CParameterMgr::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const I return ESucceeded; } +/// Output Raw Format +CParameterMgr::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)strResult; + + if (remoteCommand.getArgument(0) == "hex") { + + setOutputRawFormat(true); + + return EDone; + + } else if (remoteCommand.getArgument(0) == "dec") { + + setOutputRawFormat(false); + + return EDone; + + } else { + // Show usage + return EShowUsgae; + } + return EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + strResult = outputRawFormatIsHex() ? "hex" : "dec"; + + return ESucceeded; +} + /// Sync CParameterMgr::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { @@ -805,6 +857,15 @@ CParameterMgr::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCom return sync(strResult) ? EDone : EFailed; } +/// Criteria +CParameterMgr::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + getSelectionCriteria()->listSelectionCriteria(strResult, true); + + return ESucceeded; +} /// Domains CParameterMgr::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) @@ -911,7 +972,7 @@ CParameterMgr::CommandStatus CParameterMgr::listElementsCommmandProcess(const IR } /// Elements/Parameters -CParameterMgr::CommandStatus CParameterMgr::listElementsRecursiveCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass(), false); @@ -951,7 +1012,7 @@ CParameterMgr::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRe string strError; - CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); // Dump elements pLocatedElement->dumpContent(strResult, parameterAccessContext); @@ -974,11 +1035,7 @@ CParameterMgr::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); // Get size as string - ostringstream str; - - str << endl << pConfigurableElement->getFootPrint() << " bytes" << endl; - - strResult = str.str(); + strResult = pConfigurableElement->getFootprintAsString(); return ESucceeded; } @@ -999,7 +1056,7 @@ CParameterMgr::CommandStatus CParameterMgr::getParameterCommmandProcess(const IR CParameterMgr::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return setValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1), strResult) ? EDone : EFailed; } CParameterMgr::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) @@ -1135,7 +1192,7 @@ bool CParameterMgr::setValue(const string& strPath, const string& strValue, stri } // Define context - CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); // Set auto sync parameterAccessContext.setAutoSync(_bAutoSyncOn); @@ -1172,7 +1229,7 @@ bool CParameterMgr::getValue(const string& strPath, string& strValue, string& st } // Define context - CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); // Do the get return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext); @@ -1229,6 +1286,17 @@ bool CParameterMgr::valueSpaceIsRaw() return _bValueSpaceIsRaw; } +// Current Output Raw Format for user get value interpretation +void CParameterMgr::setOutputRawFormat(bool bIsHex) +{ + _bOutputRawFormatIsHex = bIsHex; +} + +bool CParameterMgr::outputRawFormatIsHex() +{ + return _bOutputRawFormatIsHex; +} + /// Sync // Automatic hardware synchronization control (during tuning session) bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError) @@ -1289,7 +1357,7 @@ void CParameterMgr::logStructureContent(string& strContent) const { string strError; - CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); dumpContent(strContent, parameterAccessContext); } @@ -1499,6 +1567,9 @@ bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettin // Value space xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); + // Output raw format + xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); + // Instantiate composer CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext); @@ -1582,15 +1653,15 @@ void CParameterMgr::feedElementLibraries() // Global Configuration handling CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary; - pFrameworkConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation")); - pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation")); _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary); @@ -1598,26 +1669,25 @@ void CParameterMgr::feedElementLibraries() CElementLibrary* pParameterCreationLibrary = new CElementLibrary; pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComponentType>("ComponentType")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComponentInstance>("Component")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBitParameterType>("BitParameter")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter")); - pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComputedSizeParameterType>("ComputedSizeParameter")); - pParameterCreationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter")); + pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter")); + pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude")); _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary); // Parameter Configuration Domains creation CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary; - pParameterConfigurationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain")); - pParameterConfigurationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CDomainConfiguration>("Configuration")); - pParameterConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CCompoundRule>("CompoundRule")); - pParameterConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule")); + pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain")); + pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration")); + pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule")); + pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule")); _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary); } diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index a4ef01a..e1843d9 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -122,6 +122,10 @@ public: void setValueSpace(bool bIsRaw); bool valueSpaceIsRaw(); + // Current Output Raw Format for user get value interpretation + void setOutputRawFormat(bool bIsHex); + bool outputRawFormatIsHex(); + // Automatic hardware synchronization control (during tuning session) bool setAutoSync(bool bAutoSyncOn, string& strError); bool autoSyncOn() const; @@ -183,10 +187,15 @@ private: /// Value Space CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + /// Output Raw Format + CommandStatus setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Sync CommandStatus setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + /// Criteria + CommandStatus listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Domains CommandStatus listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); @@ -205,7 +214,7 @@ private: CommandStatus restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Elements/Parameters CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listElementsRecursiveCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); @@ -274,6 +283,9 @@ private: // Value Space bool _bValueSpaceIsRaw; + // Output Raw Format + bool _bOutputRawFormatIsHex; + // Automatic synchronization to HW during Tuning session bool _bAutoSyncOn; diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp index 9a23c40..054c5e8 100644 --- a/parameter/ParameterType.cpp +++ b/parameter/ParameterType.cpp @@ -95,3 +95,58 @@ CInstanceConfigurableElement* CParameterType::doInstantiate() const } } +// Sign extension +void CParameterType::signExtend(int32_t& iData) const +{ + uint32_t uiSizeInBits = _uiSize << 3; + uint32_t uiShift = 32 - uiSizeInBits; + + if (uiShift) { + + iData = (iData << uiShift) >> uiShift; + } +} + +// Check data has no bit set outside available range +bool CParameterType::isEncodable(uint32_t uiData) const +{ + uint32_t uiSizeInBits = _uiSize << 3; + uint32_t uiShift = 32 - uiSizeInBits; + + if (uiShift) { + + // Check high bits are clean + return !(uiData >> uiShift); + } + + return true; +} + +// Remove all bits set outside available range +uint32_t CParameterType::makeEncodable(uint32_t uiData) const +{ + uint32_t uiSizeInBits = _uiSize << 3; + + uint32_t uiMask = (1 << uiSizeInBits) - 1; + + return uiData & uiMask; +} + +// Check data is consistent with available range, with respect to its sign +bool CParameterType::isConsistent(uint32_t uiData, bool bSigned) const +{ + uint32_t uiSizeInBits = _uiSize << 3; + uint32_t uiShift = 32 - uiSizeInBits; + + if (uiShift) { + + // Negative value? + bool bIsValueExpectedNegative = bSigned && (uiData & (1 << (uiShift - 1))) != 0; + + // Check high bits are clean + return bIsValueExpectedNegative ? !(~uiData >> uiShift) : !(uiData >> uiShift); + } + + return true; +} + diff --git a/parameter/ParameterType.h b/parameter/ParameterType.h index 9f136a9..0c7e0ff 100644 --- a/parameter/ParameterType.h +++ b/parameter/ParameterType.h @@ -65,8 +65,17 @@ public: protected: // Size void setSize(uint32_t uiSize); + // Sign extension + void signExtend(int32_t& iData) const; + // Check data has no bit set outside available range + bool isEncodable(uint32_t uiData) const; + // Remove all bits set outside available range + uint32_t makeEncodable(uint32_t uiData) const; + // Check data is consistent with available range, with respect to its sign + bool isConsistent(uint32_t uiData, bool bSigned) const; private: + // Instantiation virtual CInstanceConfigurableElement* doInstantiate() const; // Size in bytes diff --git a/parameter/SelectionCriteria.cpp b/parameter/SelectionCriteria.cpp index f92807c..9377e31 100644 --- a/parameter/SelectionCriteria.cpp +++ b/parameter/SelectionCriteria.cpp @@ -63,6 +63,12 @@ void CSelectionCriteria::setObserver(ISelectionCriterionObserver* pSelectionCrit getSelectionCriteriaDefinition()->setObserver(pSelectionCriterionObserver); } +// List available criteria +void CSelectionCriteria::listSelectionCriteria(string& strResult, bool bWithTypeInfo) const +{ + getSelectionCriteriaDefinition()->listSelectionCriteria(strResult, bWithTypeInfo); +} + // Children access CSelectionCriterionLibrary* CSelectionCriteria::getSelectionCriterionLibrary() { diff --git a/parameter/SelectionCriteria.h b/parameter/SelectionCriteria.h index 70528a9..4751d59 100644 --- a/parameter/SelectionCriteria.h +++ b/parameter/SelectionCriteria.h @@ -57,6 +57,9 @@ public: // Subscription void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + // List available criteria + void listSelectionCriteria(string& strResult, bool bWithTypeInfo) const; + // Base virtual string getKind() const; private: diff --git a/parameter/SelectionCriteriaDefinition.cpp b/parameter/SelectionCriteriaDefinition.cpp index eae8944..e23f326 100644 --- a/parameter/SelectionCriteriaDefinition.cpp +++ b/parameter/SelectionCriteriaDefinition.cpp @@ -70,3 +70,19 @@ void CSelectionCriteriaDefinition::setObserver(ISelectionCriterionObserver* pSel pSelectionCriterion->setObserver(pSelectionCriterionObserver); } } + +// List available criteria +void CSelectionCriteriaDefinition::listSelectionCriteria(string& strResult, bool bWithTypeInfo) const +{ + // Propagate + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CSelectionCriterion* pSelectionCriterion = static_cast<const CSelectionCriterion*>(getChild(uiChild)); + + strResult += pSelectionCriterion->getFormattedDescription(bWithTypeInfo) + "\n"; + } +} + diff --git a/parameter/SelectionCriteriaDefinition.h b/parameter/SelectionCriteriaDefinition.h index 2e1a2d6..e8487b5 100644 --- a/parameter/SelectionCriteriaDefinition.h +++ b/parameter/SelectionCriteriaDefinition.h @@ -49,6 +49,9 @@ public: // Subscription void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + // List available criteria + void listSelectionCriteria(string& strResult, bool bWithTypeInfo) const; + // Base virtual string getKind() const; }; diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp index 4c032bb..9640b3b 100644 --- a/parameter/SelectionCriterion.cpp +++ b/parameter/SelectionCriterion.cpp @@ -82,12 +82,56 @@ void CSelectionCriterion::setObserver(ISelectionCriterionObserver* pSelectionCri } /// Match methods -bool CSelectionCriterion::equals(int iState) const +bool CSelectionCriterion::is(int iState) const { return _iState == iState; } -bool CSelectionCriterion::contains(int iState) const +bool CSelectionCriterion::isNot(int iState) const +{ + return _iState != iState; +} + +bool CSelectionCriterion::includes(int iState) const { return (_iState & iState) != 0; } + +bool CSelectionCriterion::excludes(int iState) const +{ + return (_iState & iState) == 0; +} + +/// User request +string CSelectionCriterion::getFormattedDescription(bool bWithTypeInfo) const +{ + string strFormattedDescription; + + if (bWithTypeInfo) { + + // Display type info + appendTitle(strFormattedDescription, getName() + ":"); + + // States + strFormattedDescription += "Possible states "; + + // Type Kind + strFormattedDescription += "("; + strFormattedDescription += _pType->isTypeInclusive() ? "Inclusive" : "Exclusive"; + strFormattedDescription += "): "; + + // States + strFormattedDescription += _pType->listPossibleValues() + "\n"; + + // Current State + strFormattedDescription += "Current state"; + } else { + // Name only + strFormattedDescription = getName(); + } + + // Current State + strFormattedDescription += " = " + _pType->getFormattedState(_iState); + + return strFormattedDescription; +} diff --git a/parameter/SelectionCriterion.h b/parameter/SelectionCriterion.h index 8bdca68..e7b44fe 100644 --- a/parameter/SelectionCriterion.h +++ b/parameter/SelectionCriterion.h @@ -57,8 +57,13 @@ public: void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); /// Match methods - bool equals(int iState) const; - bool contains(int iState) const; + bool is(int iState) const; + bool isNot(int iState) const; + bool includes(int iState) const; + bool excludes(int iState) const; + + /// User request + string getFormattedDescription(bool bWithTypeInfo) const; /// From CElement virtual string getKind() const; diff --git a/parameter/SelectionCriterionRule.cpp b/parameter/SelectionCriterionRule.cpp index 4b5956c..e43c9e8 100644 --- a/parameter/SelectionCriterionRule.cpp +++ b/parameter/SelectionCriterionRule.cpp @@ -32,13 +32,16 @@ #include "SelectionCriterion.h" #include "XmlDomainSerializingContext.h" #include "SelectionCriteriaDefinition.h" +#include "SelectionCriterionTypeInterface.h" #include <assert.h> #define base CRule -const char* CSelectionCriterionRule::_apcMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = { - "Is", - "Contains" +CSelectionCriterionRule::SMatchingRuleDescription CSelectionCriterionRule::_astMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = { + { "Is", false }, + { "IsNot", false }, + { "Includes", true }, + { "Excludes", true } }; CSelectionCriterionRule::CSelectionCriterionRule() : _pSelectionCriterion(NULL), _eMatchesWhen(CSelectionCriterionRule::EIs), _iMatchValue(0) @@ -58,9 +61,13 @@ bool CSelectionCriterionRule::matches() const switch(_eMatchesWhen) { case EIs: - return _pSelectionCriterion->equals(_iMatchValue); - case EContains: - return _pSelectionCriterion->contains(_iMatchValue); + return _pSelectionCriterion->is(_iMatchValue); + case EIsNot: + return _pSelectionCriterion->isNot(_iMatchValue); + case EIncludes: + return _pSelectionCriterion->includes(_iMatchValue); + case EExcludes: + return _pSelectionCriterion->excludes(_iMatchValue); default: assert(0); return false; @@ -88,10 +95,11 @@ bool CSelectionCriterionRule::fromXml(const CXmlElement& xmlElement, CXmlSeriali // Get MatchesWhen string strMatchesWhen = xmlElement.getAttributeString("MatchesWhen"); + string strError; - if (!setMatchesWhen(strMatchesWhen)) { + if (!setMatchesWhen(strMatchesWhen, strError)) { - xmlDomainSerializingContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath()); + xmlDomainSerializingContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath() + ": " + strError); return false; } @@ -121,7 +129,7 @@ void CSelectionCriterionRule::toXml(CXmlElement& xmlElement, CXmlSerializingCont xmlElement.setAttributeString("SelectionCriterion", _pSelectionCriterion->getName()); // Set MatchesWhen - xmlElement.setAttributeString("MatchesWhen", _apcMatchesWhen[_eMatchesWhen]); + xmlElement.setAttributeString("MatchesWhen", _astMatchesWhen[_eMatchesWhen].pcMatchesWhen); // Set Value string strValue; @@ -132,19 +140,37 @@ void CSelectionCriterionRule::toXml(CXmlElement& xmlElement, CXmlSerializingCont } // XML MatchesWhen attribute parsing -bool CSelectionCriterionRule::setMatchesWhen(const string& strMatchesWhen) +bool CSelectionCriterionRule::setMatchesWhen(const string& strMatchesWhen, string& strError) { uint32_t uiMatchesWhen; for (uiMatchesWhen = 0; uiMatchesWhen < ENbMatchesWhen; uiMatchesWhen++) { - if (strMatchesWhen == _apcMatchesWhen[uiMatchesWhen]) { + const SMatchingRuleDescription* pstMatchingRuleDescription = &_astMatchesWhen[uiMatchesWhen]; + + if (strMatchesWhen == pstMatchingRuleDescription->pcMatchesWhen) { // Found it! + + // Get Type + const ISelectionCriterionTypeInterface* pSelectionCriterionType = _pSelectionCriterion->getCriterionType(); + + // Check compatibility if relevant + if (pSelectionCriterionType->isTypeInclusive() && !pstMatchingRuleDescription->bInclusiveTypeCompatible) { + + strError = "Value incompatible with inclusive kind of type"; + + return false; + } + + // Store _eMatchesWhen = (MatchesWhen)uiMatchesWhen; return true; } } + + strError = "Value not found"; + return false; } diff --git a/parameter/SelectionCriterionRule.h b/parameter/SelectionCriterionRule.h index ebd7611..528e584 100644 --- a/parameter/SelectionCriterionRule.h +++ b/parameter/SelectionCriterionRule.h @@ -36,12 +36,21 @@ class CSelectionCriterion; class CSelectionCriterionRule : public CRule { + // Matching rules enum MatchesWhen { EIs, - EContains, + EIsNot, + EIncludes, + EExcludes, ENbMatchesWhen }; + // Matching rule description + struct SMatchingRuleDescription + { + const char* pcMatchesWhen; + bool bInclusiveTypeCompatible; + }; public: CSelectionCriterionRule(); @@ -58,12 +67,12 @@ public: // Class kind virtual string getKind() const; private: + // XML MatchesWhen attribute parsing + bool setMatchesWhen(const string& strMatchesWhen, string& strError); + // Selection criterion const CSelectionCriterion* _pSelectionCriterion; - // XML MatchesWhen attribute parsing - bool setMatchesWhen(const string& strMatchesWhen); - // MatchesWhen MatchesWhen _eMatchesWhen; @@ -71,6 +80,6 @@ private: int32_t _iMatchValue; // Used for XML MatchesWhen attribute parsing - static const char* _apcMatchesWhen[ENbMatchesWhen]; + static SMatchingRuleDescription _astMatchesWhen[ENbMatchesWhen]; }; diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp index 2e562da..478fb43 100644 --- a/parameter/SelectionCriterionType.cpp +++ b/parameter/SelectionCriterionType.cpp @@ -42,15 +42,21 @@ string CSelectionCriterionType::getKind() const } // From ISelectionCriterionTypeInterface -std::string CSelectionCriterionType::getCriterionTypeName() -{ - return getName(); -} - bool CSelectionCriterionType::addValuePair(int iValue, const string& strValue) { + // Check 1 bit set only for inclusive types + if (_bInclusive && (!iValue || (iValue & (iValue - 1)))) { + + log("Rejecting value pair association: 0x%X - %s for Selection Criterion Type %s", iValue, strValue.c_str(), getName().c_str()); + + return false; + } + + // Check already inserted if (_numToLitMap.find(strValue) != _numToLitMap.end()) { + log("Rejecting value pair association (literal already present): 0x%X - %s for Selection Criterion Type %s", iValue, strValue.c_str(), getName().c_str()); + return false; } _numToLitMap[strValue] = iValue; @@ -91,3 +97,78 @@ bool CSelectionCriterionType::isTypeInclusive() const { return _bInclusive; } + +// Value list +string CSelectionCriterionType::listPossibleValues() const +{ + string strValueList = "{"; + + // Get comma seprated list of values + NumToLitMapConstIt it; + bool bFirst = true; + + for (it = _numToLitMap.begin(); it != _numToLitMap.end(); ++it) { + + if (bFirst) { + + bFirst = false; + } else { + strValueList += ", "; + } + strValueList += it->first; + } + + strValueList += "}"; + + return strValueList; +} + +// Formatted state +string CSelectionCriterionType::getFormattedState(int iValue) const +{ + string strFormattedState; + + if (_bInclusive) { + + // Need to go through all set bit + uint32_t uiBit; + bool bFirst = true; + + for (uiBit = 0; uiBit < sizeof(iValue) << 3; uiBit++) { + + int iSingleBitValue = iValue & (1 << uiBit); + + // Check if current bit is set + if (!iSingleBitValue) { + + continue; + } + + // Simple translation + string strSingleValue; + + getLiteralValue(iSingleBitValue, strSingleValue); + + if (bFirst) { + + bFirst = false; + } else { + strFormattedState += "|"; + } + + strFormattedState += strSingleValue; + } + + } else { + // Simple translation + getLiteralValue(iValue, strFormattedState); + } + + // Sometimes nothing is set + if (strFormattedState.empty()) { + + strFormattedState = "<none>"; + } + + return strFormattedState; +} diff --git a/parameter/SelectionCriterionType.h b/parameter/SelectionCriterionType.h index ca0571f..d534b8f 100644 --- a/parameter/SelectionCriterionType.h +++ b/parameter/SelectionCriterionType.h @@ -43,12 +43,17 @@ public: CSelectionCriterionType(bool bIsInclusive); // From ISelectionCriterionTypeInterface - virtual std::string getCriterionTypeName(); virtual bool addValuePair(int iValue, const string& strValue); virtual bool getNumericalValue(const string& strValue, int& iValue) const; virtual bool getLiteralValue(int iValue, string& strValue) const; virtual bool isTypeInclusive() const; + // Value list + string listPossibleValues() const; + + // Formatted state + string getFormattedState(int iValue) const; + // From CElement virtual string getKind() const; private: diff --git a/parameter/Subsystem.cpp b/parameter/Subsystem.cpp index a501f91..25da60a 100644 --- a/parameter/Subsystem.cpp +++ b/parameter/Subsystem.cpp @@ -125,12 +125,12 @@ bool CSubsystem::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& } // XML configuration settings parsing -bool CSubsystem::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +bool CSubsystem::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { // Fix Endianness configurationAccessContext.setBigEndianSubsystem(_bBigEndian); - return base::serializeXmlSettings(xmlConfigurableElementSettingsElement, configurationAccessContext); + return base::serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext); } @@ -208,7 +208,7 @@ void CSubsystem::addContextMappingKey(const string& strMappingKey) } // Subsystem object creator publication (strong reference) -void CSubsystem::addSubsystemObjectCreator(CSubsystemObjectCreator* pSubsystemObjectCreator) +void CSubsystem::addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator) { _subsystemObjectCreatorArray.push_back(pSubsystemObjectCreator); } @@ -222,11 +222,11 @@ bool CSubsystem::handleMappingContext(const CInstanceConfigurableElement* pInsta for (uiItem = 0; uiItem < _contextMappingKeyArray.size(); uiItem++) { string strKey = _contextMappingKeyArray[uiItem]; - string strValue; + const string* pStrValue; - if (pInstanceConfigurableElement->getMappingData(strKey, strValue)) { + if (pInstanceConfigurableElement->getMappingData(strKey, pStrValue)) { // Assign item to context - if (!context.setItem(uiItem, strValue)) { + if (!context.setItem(uiItem, pStrValue)) { getMappingError(strError, strKey, "Already set", pInstanceConfigurableElement); @@ -249,39 +249,41 @@ bool CSubsystem::handleSubsystemObjectCreation(CInstanceConfigurableElement* pIn // Mapping key string strKey = pSubsystemObjectCreator->getMappingKey(); // Object id - string strId; + const string* pStrValue; - if (pInstanceConfigurableElement->getMappingData(strKey, strId)) { + if (pInstanceConfigurableElement->getMappingData(strKey, pStrValue)) { - // First check context consisteny + // First check context consistensy (required ancestors must have been set prior to object creation) uint32_t uiAncestorKey; uint32_t uiAncestorMask = pSubsystemObjectCreator->getAncestorMask(); - for (uiAncestorKey = 0; uiAncestorKey & uiAncestorMask; uiAncestorKey++) { - - string strAncestorKey = _subsystemObjectCreatorArray[uiAncestorKey]->getMappingKey(); + for (uiAncestorKey = 0; uiAncestorKey < _contextMappingKeyArray.size(); uiAncestorKey++) { + if (!((1 << uiAncestorKey) & uiAncestorMask)) { + // Ancestor not required + continue; + } + // Check ancestor was provided if (!context.iSet(uiAncestorKey)) { - getMappingError(strError, strKey, strAncestorKey + " not set", pInstanceConfigurableElement); + getMappingError(strError, strKey, _contextMappingKeyArray[uiAncestorKey] + " not set", pInstanceConfigurableElement); return false; } } - // Do create object - string strCreationError; + // Then check configurable element size is correct + if (pInstanceConfigurableElement->getFootPrint() > pSubsystemObjectCreator->getMaxConfigurableElementSize()) { - CSubsystemObject* pSubsystemObject = pSubsystemObjectCreator->objectCreate(strId, pInstanceConfigurableElement, context, strCreationError); + string strSizeError = "Size should not exceed " + pInstanceConfigurableElement->getFootprintAsString(); - if (!pSubsystemObject) { - - getMappingError(strError, strKey, strCreationError, pInstanceConfigurableElement); + getMappingError(strError, strKey, strSizeError, pInstanceConfigurableElement); return false; } - // Keep track of created object - _subsystemObjectList.push_back(pSubsystemObject); + + // Do create object and keep its track + _subsystemObjectList.push_back(pSubsystemObjectCreator->objectCreate(*pStrValue, pInstanceConfigurableElement, context)); // Done return true; diff --git a/parameter/Subsystem.h b/parameter/Subsystem.h index af98608..14dcdb4 100644 --- a/parameter/Subsystem.h +++ b/parameter/Subsystem.h @@ -56,7 +56,7 @@ public: bool isBigEndian() const; // XML configuration settings parsing - virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; // from CElement virtual string getKind() const; @@ -72,7 +72,7 @@ protected: // Subsystem context mapping keys publication void addContextMappingKey(const string& strMappingKey); // Subsystem object creator publication (strong reference) - void addSubsystemObjectCreator(CSubsystemObjectCreator* pSubsystemObjectCreator); + void addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator); private: // Belonging subsystem virtual const CSubsystem* getBelongingSubsystem() const; diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index fb53520..f0f1985 100644 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -32,9 +32,15 @@ #include "InstanceConfigurableElement.h" #include "ParameterBlackboard.h" #include <assert.h> +#include <stdlib.h> +#include <string.h> +#include <sstream> CSubsystemObject::CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement) - : _pInstanceConfigurableElement(pInstanceConfigurableElement), _uiDataSize(pInstanceConfigurableElement->getFootPrint()), _pvSynchronizedLocation(NULL) + : _pInstanceConfigurableElement(pInstanceConfigurableElement), + _uiDataSize(pInstanceConfigurableElement->getFootPrint()), + _pucBlackboardLocation(NULL), + _uiAccessedIndex(0) { // Syncer _pInstanceConfigurableElement->setSyncer(this); @@ -45,10 +51,10 @@ CSubsystemObject::~CSubsystemObject() _pInstanceConfigurableElement->unsetSyncer(); } -// Synchronized location -void CSubsystemObject::setSynchronizedLocation(void* pvSynchronizedLocation) +// Blackboard data location +uint8_t* CSubsystemObject::getBlackboardLocation() const { - _pvSynchronizedLocation = pvSynchronizedLocation; + return _pucBlackboardLocation; } // Size @@ -57,10 +63,28 @@ uint32_t CSubsystemObject::getSize() const return _uiDataSize; } +// Conversion utility +uint32_t CSubsystemObject::asInteger(const string& strValue) +{ + return strtoul(strValue.c_str(), NULL, 0); +} + +string CSubsystemObject::asString(uint32_t uiValue) +{ + ostringstream ostr; + + ostr << uiValue; + + return ostr.str(); +} + // Synchronization bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) { - assert(_pvSynchronizedLocation); + // Get blackboard location + _pucBlackboardLocation = parameterBlackboard.getLocation(_pInstanceConfigurableElement->getOffset()); + // Access index init + _uiAccessedIndex = 0; #ifdef SIMULATION return true; @@ -70,28 +94,69 @@ bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBac if (bBack) { // Read from HW - if (!receiveFromHW()) { + if (!accessHW(true, strError)) { - strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError; return false; } - // Write parameter block data - parameterBlackboard.rawWrite(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); - } else { - // Read parameter block data - parameterBlackboard.rawRead(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); - // Send to HW - if (!sendToHW()) { + if (!accessHW(false, strError)) { - strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError; return false; } } return true; } + +// Sync to/from HW +bool CSubsystemObject::sendToHW(string& strError) +{ + strError = "Send to HW interface not implemented at subsystsem level!"; + + return false; +} + +bool CSubsystemObject::receiveFromHW(string& strError) +{ + strError = "Receive from HW interface not implemented at subsystsem level!"; + + return false; +} + +// Fall back HW access +bool CSubsystemObject::accessHW(bool bReceive, string& strError) +{ + // Default access falls back + if (bReceive) { + + return receiveFromHW(strError); + } else { + + return sendToHW(strError); + } +} + +// Blackboard access from subsystems +void CSubsystemObject::blackboardRead(void* pvData, uint32_t uiSize) +{ + assert(_uiAccessedIndex + uiSize <= _uiDataSize); + + memcpy(pvData, _pucBlackboardLocation + _uiAccessedIndex, uiSize); + + _uiAccessedIndex += uiSize; +} + +void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize) +{ + assert(_uiAccessedIndex + uiSize <= _uiDataSize); + + memcpy(_pucBlackboardLocation + _uiAccessedIndex, pvData, uiSize); + + _uiAccessedIndex += uiSize; +} diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index c4e88fb..e702c87 100644 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h @@ -45,20 +45,30 @@ public: virtual bool sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError); protected: - // Synchronized location - void setSynchronizedLocation(void* pvSynchronizedLocation); + // Blackboard data location + uint8_t* getBlackboardLocation() const; // Size uint32_t getSize() const; + // Conversion utility + static uint32_t asInteger(const string& strValue); + static string asString(uint32_t uiValue); // Sync to/from HW - virtual bool sendToHW() = 0; - virtual bool receiveFromHW() = 0; + virtual bool sendToHW(string& strError); + virtual bool receiveFromHW(string& strError); + // Fall back HW access + virtual bool accessHW(bool bReceive, string& strError); + // Blackboard access from subsystems + void blackboardRead(void* pvData, uint32_t uiSize); + void blackboardWrite(const void* pvData, uint32_t uiSize); private: // Instance element to sync from/to CInstanceConfigurableElement* _pInstanceConfigurableElement; // Data size uint32_t _uiDataSize; - // Synchronized location - void* _pvSynchronizedLocation; + // Blackboard data location + uint8_t* _pucBlackboardLocation; + // Accessed index for Subsystem read/write from/to blackboard + uint32_t _uiAccessedIndex; }; diff --git a/parameter/SubsystemObjectCreator.cpp b/parameter/SubsystemObjectCreator.cpp index b0f0dde..3a719bc 100644 --- a/parameter/SubsystemObjectCreator.cpp +++ b/parameter/SubsystemObjectCreator.cpp @@ -30,8 +30,8 @@ */ #include "SubsystemObjectCreator.h" -CSubsystemObjectCreator::CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask) - : _strMappingKey(strMappingKey), _uiAncestorIdMask(uiAncestorIdMask) +CSubsystemObjectCreator::CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask, uint32_t uiMaxConfigurableElementSize) + : _strMappingKey(strMappingKey), _uiAncestorIdMask(uiAncestorIdMask), _uiMaxConfigurableElementSize(uiMaxConfigurableElementSize) { } @@ -45,3 +45,8 @@ uint32_t CSubsystemObjectCreator::getAncestorMask() const { return _uiAncestorIdMask; } + +uint32_t CSubsystemObjectCreator::getMaxConfigurableElementSize() const +{ + return _uiMaxConfigurableElementSize; +} diff --git a/parameter/SubsystemObjectCreator.h b/parameter/SubsystemObjectCreator.h index 91ad5be..aad7528 100644 --- a/parameter/SubsystemObjectCreator.h +++ b/parameter/SubsystemObjectCreator.h @@ -39,19 +39,22 @@ using namespace std; class CSubsystemObjectCreator { public: - CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask); + CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask, uint32_t uiMaxConfigurableElementSize); // Accessors const string& getMappingKey() const; uint32_t getAncestorMask() const; + uint32_t getMaxConfigurableElementSize() const; // Object creation - virtual CSubsystemObject* objectCreate(const string& strId, CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError) const = 0; + virtual CSubsystemObject* objectCreate(const string& strMappingValue, CInstanceConfigurableElement* pInstanceConfigurableElement, const CMappingContext& context) const = 0; private: // Mapping key string _strMappingKey; // Mask of must-be-specified ancestors uint32_t _uiAncestorIdMask; + // Masximum expected size for configurable elment (-1 means none) + uint32_t _uiMaxConfigurableElementSize; }; diff --git a/parameter/ComputedSizeParameter.h b/parameter/SubsystemObjectFactory.h index 99c1ad2..b8016c4 100644 --- a/parameter/ComputedSizeParameter.h +++ b/parameter/SubsystemObjectFactory.h @@ -1,10 +1,10 @@ /* <auto_header> * <FILENAME> - * + * * INTEL CONFIDENTIAL - * Copyright © 2011 Intel + * Copyright © 2011 Intel * Corporation All Rights Reserved. - * + * * The source code contained or described herein and all documents related to * the source code ("Material") are owned by Intel Corporation or its suppliers * or licensors. Title to the Material remains with Intel Corporation or its @@ -14,38 +14,33 @@ * treaty provisions. No part of the Material may be used, copied, reproduced, * modified, published, uploaded, posted, transmitted, distributed, or * disclosed in any way without Intel’s prior express written permission. - * + * * No license under any patent, copyright, trade secret or other intellectual * property right is granted to or conferred upon you by disclosure or delivery * of the Materials, either expressly, by implication, inducement, estoppel or * otherwise. Any license under such intellectual property rights must be * express and approved by Intel in writing. - * + * * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) * CREATED: 2011-06-01 * UPDATED: 2011-07-27 - * - * + * + * * </auto_header> */ #pragma once -#include "Parameter.h" +#include "SubsystemObjectCreator.h" -class CConfigurableElement; - -class CComputedSizeParameter : public CParameter +template <class SubsystemObjectType> +class TSubsystemObjectFactory : public CSubsystemObjectCreator { public: - CComputedSizeParameter(const string& strName, const CTypeElement* pTypeElement); - - virtual bool init(string& strError); + TSubsystemObjectFactory(const string& strMappingKey, uint32_t uiAncestorIdMask, uint32_t uiMaxConfigurableElementSize = -1) : CSubsystemObjectCreator(strMappingKey, uiAncestorIdMask, uiMaxConfigurableElementSize) {} - virtual uint32_t getFootPrint() const; -protected: - virtual bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext); - virtual void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; -private: - const CConfigurableElement* _pReferredElement; + // Object creation + virtual CSubsystemObject* objectCreate(const string& strMappingValue, CInstanceConfigurableElement* pInstanceConfigurableElement, const CMappingContext& context) const + { + return new SubsystemObjectType(strMappingValue, pInstanceConfigurableElement, context); + } }; - diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp index 2b9c663..34b3ce0 100644 --- a/parameter/TypeElement.cpp +++ b/parameter/TypeElement.cpp @@ -55,11 +55,11 @@ uint32_t CTypeElement::getArrayLength() const return _uiArrayLength; } -bool CTypeElement::getMappingData(const string& strKey, string& strValue) const +bool CTypeElement::getMappingData(const string& strKey, const string*& pStrValue) const { if (_pMappingData) { - return _pMappingData->getValue(strKey, strValue); + return _pMappingData->getValue(strKey, pStrValue); } return false; } diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h index 9391729..3468c35 100644 --- a/parameter/TypeElement.h +++ b/parameter/TypeElement.h @@ -45,7 +45,7 @@ public: CInstanceConfigurableElement* instantiate() const; // Mapping info - virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; // From IXmlSink diff --git a/parameter/XmlDomainSerializingContext.cpp b/parameter/XmlDomainSerializingContext.cpp index 34a465c..cb5a20d 100644 --- a/parameter/XmlDomainSerializingContext.cpp +++ b/parameter/XmlDomainSerializingContext.cpp @@ -33,7 +33,7 @@ #define base CXmlElementSerializingContext CXmlDomainSerializingContext::CXmlDomainSerializingContext(string& strError, bool bWithSettings) - : base(strError), _bWithSettings(bWithSettings), _bValueSpaceIsRaw(false), _pSelectionCriteriaDefinition(NULL) + : base(strError), _bWithSettings(bWithSettings), _bValueSpaceIsRaw(false), _bOutputRawFormatIsHex(false), _pSelectionCriteriaDefinition(NULL) { } @@ -54,6 +54,17 @@ bool CXmlDomainSerializingContext::valueSpaceIsRaw() const return _bValueSpaceIsRaw; } +// Output Raw Format for user get value interpretation +void CXmlDomainSerializingContext::setOutputRawFormat(bool bIsHex) +{ + _bOutputRawFormatIsHex = bIsHex; +} + +bool CXmlDomainSerializingContext::outputRawFormatIsHex() +{ + return _bOutputRawFormatIsHex; +} + // Criteria defintion void CXmlDomainSerializingContext::setSelectionCriteriaDefinition(const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition) { diff --git a/parameter/XmlDomainSerializingContext.h b/parameter/XmlDomainSerializingContext.h index 770f14b..c63552c 100644 --- a/parameter/XmlDomainSerializingContext.h +++ b/parameter/XmlDomainSerializingContext.h @@ -43,10 +43,14 @@ public: // Settings to be serialized or not bool withSettings() const; - // Value interpretation as Real or Raw (usefull for Fixed point parameters) + // Value interpretation as Real or Raw void setValueSpaceRaw(bool bIsRaw); bool valueSpaceIsRaw() const; + // Output Raw Format for user get value interpretation + void setOutputRawFormat(bool bIsHex); + bool outputRawFormatIsHex(); + // ParameterBlackboard const CParameterBlackboard* getParameterBlackboard() const; @@ -59,6 +63,8 @@ private: bool _bWithSettings; // Value Space bool _bValueSpaceIsRaw; + // Output Raw Format + bool _bOutputRawFormatIsHex; // Criteria defintion const CSelectionCriteriaDefinition* _pSelectionCriteriaDefinition; }; diff --git a/parameter/parameter b/parameter/parameter index 837edd0..6d8ad82 100755 --- a/parameter/parameter +++ b/parameter/parameter @@ -1,2 +1,2 @@ -#! /bin/sh +#!/bin/sh ./remote-process localhost 5000 $* diff --git a/remote-processor/RemoteCommand.h b/remote-processor/RemoteCommand.h index 8409468..e55d3cb 100644 --- a/remote-processor/RemoteCommand.h +++ b/remote-processor/RemoteCommand.h @@ -43,4 +43,5 @@ public: virtual void addArgument(const std::string& strArgument) = 0; virtual uint32_t getArgumentCount() const = 0; virtual const std::string& getArgument(uint32_t uiArgument) const = 0; + virtual const std::string packArguments(uint32_t uiStartArgument, uint32_t uiNbArguments) const = 0; }; diff --git a/remote-processor/RequestMessage.cpp b/remote-processor/RequestMessage.cpp index 6f71b8a..8c6c2a3 100644 --- a/remote-processor/RequestMessage.cpp +++ b/remote-processor/RequestMessage.cpp @@ -73,6 +73,33 @@ const string& CRequestMessage::getArgument(uint32_t uiArgument) const return _argumentVector[uiArgument]; } +const string CRequestMessage::packArguments(uint32_t uiStartArgument, uint32_t uiNbArguments) const +{ + string strPackedArguments; + + assert(uiStartArgument + uiNbArguments <= _argumentVector.size()); + + // Pack arguments, separating them with a space + uint32_t uiArgument; + + bool bFirst = true; + + for (uiArgument = uiStartArgument; uiArgument < uiStartArgument + uiNbArguments; uiArgument++) { + + if (!bFirst) { + + strPackedArguments += " "; + } else { + + bFirst = false; + } + + strPackedArguments += _argumentVector[uiArgument]; + } + + return strPackedArguments; +} + // Fill data to send void CRequestMessage::fillDataToSend() { diff --git a/remote-processor/RequestMessage.h b/remote-processor/RequestMessage.h index c0b2183..8428aad 100644 --- a/remote-processor/RequestMessage.h +++ b/remote-processor/RequestMessage.h @@ -47,6 +47,7 @@ public: virtual void addArgument(const string& strArgument); virtual uint32_t getArgumentCount() const; virtual const string& getArgument(uint32_t uiArgument) const; + virtual const string packArguments(uint32_t uiStartArgument, uint32_t uiNbArguments) const; private: // Fill data to send diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp index cea7a1d..11b9a94 100644 --- a/xmlserializer/XmlElement.cpp +++ b/xmlserializer/XmlElement.cpp @@ -166,6 +166,20 @@ bool CXmlElement::getChildElement(const string& strType, const string& strNameAt return false; } +uint32_t CXmlElement::getNbChildElements() const +{ + CXmlElement childElement; + uint32_t uiNbChildren = 0; + + CChildIterator childIterator(*this); + + while (childIterator.next(childElement)) { + + uiNbChildren++; + } + return uiNbChildren; +} + bool CXmlElement::getParentElement(CXmlElement& parentElement) const { _xmlNode* pXmlNode = _pXmlElement->parent; diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h index 797179f..1028d60 100644 --- a/xmlserializer/XmlElement.h +++ b/xmlserializer/XmlElement.h @@ -64,6 +64,7 @@ public: // Navigation bool getChildElement(const string& strType, CXmlElement& childElement) const; bool getChildElement(const string& strType, const string& strNameAttribute, CXmlElement& childElement) const; + uint32_t getNbChildElements() const; bool getParentElement(CXmlElement& parentElement) const; // Setters |