diff options
author | Frederic Boisnard <fredericx.boisnard@intel.com> | 2013-05-23 15:28:31 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:04:04 +0100 |
commit | 390b36d8129d3ece769c8542d9d3d3895ab13fbb (patch) | |
tree | 693f1bbc58ef05d0cbd6182b23be3cf6b413dbc2 /parameter | |
parent | 55f41bcc3edf282f236539bb26bd6dc8638f235e (diff) | |
download | external_parameter-framework-390b36d8129d3ece769c8542d9d3d3895ab13fbb.zip external_parameter-framework-390b36d8129d3ece769c8542d9d3d3895ab13fbb.tar.gz external_parameter-framework-390b36d8129d3ece769c8542d9d3d3895ab13fbb.tar.bz2 |
[PFW] Add getFormattedMapping for InstanceConfigurableElements
BZ: 99822
The mapping data need to be printed, however helper methods are
missing to achieve this easily.
This patch aims to add a new method "getFormattedMapping()" for
CMappingData, allowing to format the mapping data as a string.
Change-Id: Ia030c6b88905fcb7591ad45339712051eb88d1c1
Signed-off-by: Frederic Boisnard <fredericx.boisnard@intel.com>
Reviewed-on: http://android.intel.com:8080/109301
Reviewed-by: Benavoli, Patrick <patrick.benavoli@intel.com>
Reviewed-by: De Chivre, Renaud <renaud.de.chivre@intel.com>
Reviewed-by: Rocard, KevinX <kevinx.rocard@intel.com>
Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter')
-rw-r--r-- | parameter/ComponentInstance.cpp | 12 | ||||
-rw-r--r-- | parameter/ComponentInstance.h | 6 | ||||
-rw-r--r-- | parameter/ComponentType.cpp | 12 | ||||
-rw-r--r-- | parameter/ComponentType.h | 6 | ||||
-rw-r--r-- | parameter/InstanceConfigurableElement.cpp | 7 | ||||
-rw-r--r-- | parameter/InstanceConfigurableElement.h | 9 | ||||
-rw-r--r-- | parameter/MappingData.cpp | 10 | ||||
-rw-r--r-- | parameter/MappingData.h | 7 | ||||
-rw-r--r-- | parameter/ParameterMgr.cpp | 10 | ||||
-rw-r--r-- | parameter/TypeElement.cpp | 9 | ||||
-rw-r--r-- | parameter/TypeElement.h | 7 |
11 files changed, 90 insertions, 5 deletions
diff --git a/parameter/ComponentInstance.cpp b/parameter/ComponentInstance.cpp index 83e7448..4ffdab9 100644 --- a/parameter/ComponentInstance.cpp +++ b/parameter/ComponentInstance.cpp @@ -56,6 +56,18 @@ bool CComponentInstance::hasMappingData() const return base::hasMappingData() || (_pComponentType && _pComponentType->hasMappingData()); } +string CComponentInstance::getFormattedMapping() const +{ + // Try myself first then associated component type + string strValue = base::getFormattedMapping(); + if (_pComponentType) { + + strValue += _pComponentType->getFormattedMapping(); + } + + return strValue; +} + bool CComponentInstance::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Context diff --git a/parameter/ComponentInstance.h b/parameter/ComponentInstance.h index 536adb8..7a2f268 100644 --- a/parameter/ComponentInstance.h +++ b/parameter/ComponentInstance.h @@ -36,6 +36,12 @@ public: // Mapping info virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; + /** + * Returns the mapping associated to the current TypeElement instance + * + * @return A string containing the mapping as a comma separated key value pairs + */ + virtual string getFormattedMapping() const; // From IXmlSink virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); diff --git a/parameter/ComponentType.cpp b/parameter/ComponentType.cpp index 3b5729a..0f7dc32 100644 --- a/parameter/ComponentType.cpp +++ b/parameter/ComponentType.cpp @@ -56,6 +56,18 @@ bool CComponentType::hasMappingData() const return base::hasMappingData() || (_pExtendsComponentType && _pExtendsComponentType->hasMappingData()); } +string CComponentType::getFormattedMapping() const +{ + // Try myself first then associated component type + string strValue = base::getFormattedMapping(); + if (_pExtendsComponentType) { + + strValue += _pExtendsComponentType->getFormattedMapping(); + } + + return strValue; +} + bool CComponentType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Context diff --git a/parameter/ComponentType.h b/parameter/ComponentType.h index 7984fa7..d255e62 100644 --- a/parameter/ComponentType.h +++ b/parameter/ComponentType.h @@ -39,6 +39,12 @@ public: // Mapping info virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; + /** + * Returns the mapping associated to the current TypeElement instance + * + * @return A string containing the mapping as a comma separated key value pairs + */ + virtual string getFormattedMapping() const; // From IXmlSink virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); diff --git a/parameter/InstanceConfigurableElement.cpp b/parameter/InstanceConfigurableElement.cpp index 40ef18b..cc84a3e 100644 --- a/parameter/InstanceConfigurableElement.cpp +++ b/parameter/InstanceConfigurableElement.cpp @@ -55,6 +55,13 @@ bool CInstanceConfigurableElement::getMappingData(const string& strKey, const st return getTypeElement()->getMappingData(strKey, pStrValue); } +// Returns the formatted mapping +string CInstanceConfigurableElement::getFormattedMapping() const +{ + // Delegate + return getTypeElement()->getFormattedMapping(); +} + bool CInstanceConfigurableElement::map(IMapper& mapper, string& strError) { bool bHasMappingData = getTypeElement()->hasMappingData(); diff --git a/parameter/InstanceConfigurableElement.h b/parameter/InstanceConfigurableElement.h index e27ad4b..b1ffdf8 100644 --- a/parameter/InstanceConfigurableElement.h +++ b/parameter/InstanceConfigurableElement.h @@ -48,9 +48,16 @@ public: // Instantiated type const CTypeElement* getTypeElement() const; - // Mapping info bool getMappingData(const string& strKey, const string*& pStrValue) const; + /** + * Returns the mapping data associated to the type element of the current + * InstanceConfigurableElement, as a formatted string + * + * @return A string containing the formatted mapping + */ + string getFormattedMapping() const; + // From CElement virtual string getKind() const; diff --git a/parameter/MappingData.cpp b/parameter/MappingData.cpp index 4ec58e3..63c65af 100644 --- a/parameter/MappingData.cpp +++ b/parameter/MappingData.cpp @@ -24,6 +24,7 @@ */ #include "MappingData.h" #include "Tokenizer.h" +#include "Utility.h" #include <assert.h> CMappingData::CMappingData() @@ -86,6 +87,15 @@ bool CMappingData::getValue(const string& strkey, const string*& pStrValue) cons return false; } +string CMappingData::asString() const +{ + string strValue; + + CUtility::asString(_keyToValueMap, strValue, ", ", ":"); + + return strValue; +} + bool CMappingData::addValue(const string& strkey, const string& strValue) { if (_keyToValueMap.find(strkey) != _keyToValueMap.end()) { diff --git a/parameter/MappingData.h b/parameter/MappingData.h index 03f8e2a..0d16eb3 100644 --- a/parameter/MappingData.h +++ b/parameter/MappingData.h @@ -42,6 +42,13 @@ public: // Query bool getValue(const string& strkey, const string*& pStrValue) const; + /** + * Formats the mapping as a list of comma-space separated key:value pairs + * + * @return the formatted string + */ + string asString() const; + private: bool addValue(const string& strkey, const string& strValue); diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 02bedb9..6293129 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -771,7 +771,9 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProces list<string> lstrSelectionCriteria; getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true); // Concatenate the criterion list as the command result - CUtility::concatenate(lstrSelectionCriteria, strResult); + string strCriteriaStates; + CUtility::asString(lstrSelectionCriteria, strCriteriaStates); + strResult += strCriteriaStates; return CCommandHandler::ESucceeded; } @@ -933,7 +935,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommman getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable); // Concatenate the criterion list as the command result - CUtility::concatenate(lstrResult, strResult); + CUtility::asString(lstrResult, strResult); return CCommandHandler::ESucceeded; } @@ -1077,7 +1079,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfiguratio list<string> lstrResult; if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) { //Concatenate the error list as the command result - CUtility::concatenate(lstrResult, strResult); + CUtility::asString(lstrResult, strResult); return CCommandHandler::EFailed; } @@ -1652,7 +1654,7 @@ bool CParameterMgr::sync(string& strError) list<string> lstrError; if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){ - CUtility::concatenate(lstrError, strError); + CUtility::asString(lstrError, strError); return false; }; diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp index 405dc7d..5bfc2d7 100644 --- a/parameter/TypeElement.cpp +++ b/parameter/TypeElement.cpp @@ -126,6 +126,15 @@ CMappingData* CTypeElement::getMappingData() return _pMappingData; } +string CTypeElement::getFormattedMapping() const +{ + if (_pMappingData) { + + return _pMappingData->asString(); + } + return ""; +} + // From IXmlSource void CTypeElement::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h index bf0b306..db40412 100644 --- a/parameter/TypeElement.h +++ b/parameter/TypeElement.h @@ -42,6 +42,13 @@ public: virtual bool getMappingData(const string& strKey, const string*& pStrValue) const; virtual bool hasMappingData() const; + /** + * Returns the mapping associated to the current TypeElement instance + * + * @return A string containing the mapping as a comma separated key value pairs + */ + virtual string getFormattedMapping() const; + // Element properties virtual void showProperties(string& strResult) const; |