Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Simplify Xml handling #110

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ after_success:
--exclude "bindings/c/Test.cpp"
--exclude "parameter/criterion/test/"
--exclude "test/tokenizer"
--exclude "xmlserializer/test"
--gcov /usr/bin/gcov-4.8
--gcov-options '\--long-file-names --preserve-paths'

Expand Down
1 change: 0 additions & 1 deletion Schemas/SystemClass.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="SubsystemInclude" type="FileIncluderType"/>
<xs:element ref="Subsystem"/>
</xs:choice>
</xs:sequence>
Expand Down
16 changes: 7 additions & 9 deletions bindings/c/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,15 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use") {
// Create valid pfw config file
const char *intParameterPath = "/test/system/integer";
const char *stringParameterPath = "/test/system/string";
TmpFile system("<?xml version='1.0' encoding='UTF-8'?>\
<Subsystem Name='system' Type='Virtual' Endianness='Little'>\
<ComponentLibrary/>\
<InstanceDefinition>\
<IntegerParameter Name='integer' Size='32' Signed='true' Max='100'/>\
<StringParameter Name='string' MaxLength='9'/>\
</InstanceDefinition>\
</Subsystem>");
TmpFile libraries("<?xml version='1.0' encoding='UTF-8'?>\
<SystemClass Name='test'>\
<SubsystemInclude Path='" + system.path() + "'/>\
<Subsystem Name='system' Type='Virtual' Endianness='Little'>\
<ComponentLibrary/>\
<InstanceDefinition>\
<IntegerParameter Name='integer' Size='32' Signed='true' Max='100'/>\
<StringParameter Name='string' MaxLength='9'/>\
</InstanceDefinition>\
</Subsystem>\
</SystemClass>");
TmpFile config("<?xml version='1.0' encoding='UTF-8'?>\
<ParameterFrameworkConfiguration\
Expand Down
1 change: 0 additions & 1 deletion parameter/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ common_src_files := \
VirtualSubsystem.cpp \
VirtualSyncer.cpp \
XmlElementSerializingContext.cpp \
XmlFileIncluderElement.cpp \
XmlParameterSerializingContext.cpp

common_module := libparameter
Expand Down
5 changes: 3 additions & 2 deletions parameter/BitParameterBlockType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ uint32_t CBitParameterBlockType::getSize() const
bool CBitParameterBlockType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
{
// Size
_uiSize = xmlElement.getAttributeInteger("Size") / 8;
xmlElement.getAttribute("Size", _uiSize);
_uiSize /= 8;

// Base
return base::fromXml(xmlElement, serializingContext);
Expand All @@ -75,7 +76,7 @@ CInstanceConfigurableElement* CBitParameterBlockType::doInstantiate() const
void CBitParameterBlockType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
{
// Size
xmlElement.setAttributeString("Size", CUtility::toString(_uiSize * 8));
xmlElement.setAttribute("Size", CUtility::toString(_uiSize * 8));

base::toXml(xmlElement, serializingContext);
}
12 changes: 6 additions & 6 deletions parameter/BitParameterType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void CBitParameterType::showProperties(string& strResult) const
bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
{
// Pos
_uiBitPos = xmlElement.getAttributeInteger("Pos");
xmlElement.getAttribute("Pos", _uiBitPos);

// Size
_uiBitSize = xmlElement.getAttributeInteger("Size");
xmlElement.getAttribute("Size", _uiBitSize);

// Validate bit pos and size still fit into parent type
const CBitParameterBlockType* pBitParameterBlockType = static_cast<const CBitParameterBlockType*>(getParent());
Expand All @@ -99,7 +99,7 @@ bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingCo
// Max
if (xmlElement.hasAttribute("Max")) {

_uiMax = xmlElement.getAttributeInteger("Max");
xmlElement.getAttribute("Max", _uiMax);

if (_uiMax > getMaxEncodableValue()) {

Expand Down Expand Up @@ -246,13 +246,13 @@ bool CBitParameterType::isEncodable(uint64_t uiData) const
void CBitParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
{
// Position
xmlElement.setAttributeString("Pos", CUtility::toString(_uiBitPos));
xmlElement.setAttribute("Pos", _uiBitPos);

// Size
xmlElement.setAttributeString("Size", CUtility::toString(_uiBitSize));
xmlElement.setAttribute("Size", _uiBitSize);

// Maximum
xmlElement.setAttributeString("Max", CUtility::toString(_uiMax));
xmlElement.setAttribute("Max", _uiMax);

base::toXml(xmlElement, serializingContext);

Expand Down
6 changes: 1 addition & 5 deletions parameter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ add_library(parameter SHARED
ErrorContext.cpp
FixedPointParameterType.cpp
FormattedSubsystemObject.cpp
FrameworkConfigurationLocation.cpp
HardwareBackSynchronizer.cpp
InstanceConfigurableElement.cpp
InstanceDefinition.cpp
Expand All @@ -73,14 +72,12 @@ add_library(parameter SHARED
ParameterBlackboard.cpp
ParameterBlockType.cpp
Parameter.cpp
ParameterFrameworkConfiguration.cpp
ParameterHandle.cpp
ParameterMgr.cpp
ParameterMgrFullConnector.cpp
ParameterMgrPlatformConnector.cpp
ParameterType.cpp
PathNavigator.cpp
PluginLocation.cpp
RuleParser.cpp
SelectionCriterionRule.cpp
SimulatedBackSynchronizer.cpp
Expand All @@ -96,7 +93,6 @@ add_library(parameter SHARED
VirtualSubsystem.cpp
VirtualSyncer.cpp
XmlElementSerializingContext.cpp
XmlFileIncluderElement.cpp
XmlParameterSerializingContext.cpp
command/src/Parser.cpp)

Expand All @@ -105,6 +101,7 @@ include_directories(
command/include
"${PROJECT_SOURCE_DIR}/parameter"
"${PROJECT_SOURCE_DIR}/xmlserializer"
"${PROJECT_SOURCE_DIR}/xmlserializer/include"
"${PROJECT_SOURCE_DIR}/utility"
"${PROJECT_SOURCE_DIR}/remote-processor"
"${PROJECT_SOURCE_DIR}/parameter/log/include"
Expand All @@ -131,7 +128,6 @@ install(FILES
Element.h
ElementBuilder.h
ElementLibrary.h
FileIncluderElementBuilder.h
FormattedSubsystemObject.h
InstanceConfigurableElement.h
Mapper.h
Expand Down
3 changes: 2 additions & 1 deletion parameter/ComponentInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ bool CComponentInstance::fromXml(const CXmlElement& xmlElement, CXmlSerializingC

const CComponentLibrary* pComponentLibrary = parameterBuildContext.getComponentLibrary();

std::string strComponentType = xmlElement.getAttributeString("Type");
std::string strComponentType;
xmlElement.getAttribute("Type", strComponentType);

_pComponentType = pComponentLibrary->getComponentType(strComponentType);

Expand Down
3 changes: 2 additions & 1 deletion parameter/ComponentType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ bool CComponentType::fromXml(const CXmlElement& xmlElement, CXmlSerializingConte
// Check for Extends attribute (extensions will be populated after and not before)
if (xmlElement.hasAttribute("Extends")) {

std::string strExtendsType = xmlElement.getAttributeString("Extends");
std::string strExtendsType;
xmlElement.getAttribute("Extends", strExtendsType);

_pExtendsComponentType = pComponentLibrary->getComponentType(strExtendsType);

Expand Down
2 changes: 1 addition & 1 deletion parameter/CompoundRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool CCompoundRule::fromXml(const CXmlElement& xmlElement, CXmlSerializingContex
void CCompoundRule::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
{
// Set type
xmlElement.setAttributeString("Type", _apcTypes[_bTypeAll]);
xmlElement.setAttribute("Type", _apcTypes[_bTypeAll]);

// Base
base::toXml(xmlElement, serializingContext);
Expand Down
13 changes: 8 additions & 5 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CConfigurableDomain::toXml(CXmlElement& xmlElement, CXmlSerializingContext&
base::toXml(xmlElement, serializingContext);

// Sequence awareness
xmlElement.setAttributeBoolean("SequenceAware", _bSequenceAware);
xmlElement.setAttribute("SequenceAware", _bSequenceAware);
}

void CConfigurableDomain::childrenToXml(CXmlElement& xmlElement,
Expand Down Expand Up @@ -168,7 +168,7 @@ void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement) c
xmlConfigurableElementsElement.createChild(xmlChildConfigurableElement, "ConfigurableElement");

// Set Path attribute
xmlChildConfigurableElement.setAttributeString("Path", pConfigurableElement->getPath());
xmlChildConfigurableElement.setAttribute("Path", pConfigurableElement->getPath());
}
}

Expand Down Expand Up @@ -217,9 +217,11 @@ bool CConfigurableDomain::fromXml(const CXmlElement& xmlElement, CXmlSerializing
static_cast<CXmlDomainImportContext&>(serializingContext);

// Sequence awareness (optional)
_bSequenceAware = xmlElement.hasAttribute("SequenceAware") && xmlElement.getAttributeBoolean("SequenceAware");
xmlElement.getAttribute("SequenceAware", _bSequenceAware);

setName(xmlElement.getAttributeString("Name"));
std::string name;
xmlElement.getAttribute("Name", name);
setName(name);

// Local parsing. Do not dig
if (!parseDomainConfigurations(xmlElement, xmlDomainImportContext) ||
Expand Down Expand Up @@ -273,7 +275,8 @@ bool CConfigurableDomain::parseConfigurableElements(const CXmlElement& xmlElemen
while (it.next(xmlConfigurableElementElement)) {

// Locate configurable element
string strConfigurableElementPath = xmlConfigurableElementElement.getAttributeString("Path");
string strConfigurableElementPath;
xmlConfigurableElementElement.getAttribute("Path", strConfigurableElementPath);

CPathNavigator pathNavigator(strConfigurableElementPath);
string strError;
Expand Down
2 changes: 1 addition & 1 deletion parameter/ConfigurableDomains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard,
void CConfigurableDomains::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
{
// Set attribute
xmlElement.setAttributeString("SystemClassName", getName());
xmlElement.setAttribute("SystemClassName", getName());

base::childrenToXml(xmlElement, serializingContext);
}
Expand Down
46 changes: 28 additions & 18 deletions parameter/PluginLocation.h → parameter/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,37 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "KindElement.h"
#include <list>

#include <string>
#include <list>

class CPluginLocation : public CKindElement
namespace core
{

public:
CPluginLocation(const std::string& strName, const std::string& strKind);

// From IXmlSink
virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);

// Folder
const std::string& getFolder() const;

// Plugin list
const std::list<std::string>& getPluginList() const;

private:
std::string _strFolder;
std::list<std::string> _pluginList;
/** Parameter-Framework Configuration holder */
struct Configuration
{
/** @param[in] file the file which contains the configuration */
Configuration(const std::string &file) : configurationFile(file) {}

/** System class name */
std::string systemClassName;
/** Indicate if the tuning is allowed */
bool tuningAllowed = false;
/** Remote command server listening port */
uint16_t serverPort = 0;
/** File which contains the configuration */
std::string configurationFile;
/** Application XML schemas directory */
std::string schemasLocation;
/** Application structure file */
std::string structureFile;
/** Application settings file */
std::string settingsFile;
/** Application binary settings file */
std::string binarySettingsFile;
/** Application plugin path list */
std::list<std::string> plugins;
};

} /** core namespace */
5 changes: 3 additions & 2 deletions parameter/DomainConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ bool CDomainConfiguration::parseSettings(CXmlElement& xmlConfigurationSettingsEl
while (it.next(xmlConfigurableElementSettingsElement)) {

// Retrieve area configuration
string strConfigurableElementPath = xmlConfigurableElementSettingsElement.getAttributeString("Path");
string strConfigurableElementPath;
xmlConfigurableElementSettingsElement.getAttribute("Path", strConfigurableElementPath);

CAreaConfiguration* pAreaConfiguration = findAreaConfiguration(strConfigurableElementPath);

Expand Down Expand Up @@ -131,7 +132,7 @@ void CDomainConfiguration::composeSettings(CXmlElement& xmlConfigurationSettings
xmlConfigurationSettingsElement.createChild(xmlConfigurableElementSettingsElement, "ConfigurableElement");

// Set Path attribute
xmlConfigurableElementSettingsElement.setAttributeString("Path", pConfigurableElement->getPath());
xmlConfigurableElementSettingsElement.setAttribute("Path", pConfigurableElement->getPath());

// Delegate composing to area configuration
((CDomainConfiguration&)(*this)).serializeConfigurableElementSettings((CAreaConfiguration*)pAreaConfiguration, xmlConfigurableElementSettingsElement, serializingContext, true);
Expand Down
9 changes: 2 additions & 7 deletions parameter/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void CElement::logValue(string& strValue, CErrorContext& errorContext) const
// From IXmlSink
bool CElement::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
{
setDescription(getXmlDescriptionAttribute(xmlElement));
xmlElement.getAttribute(gDescriptionPropertyName, _strDescription);

// Propagate through children
CXmlElement::CChildIterator childIterator(xmlElement);
Expand Down Expand Up @@ -206,15 +206,10 @@ void CElement::setXmlDescriptionAttribute(CXmlElement& xmlElement) const
{
const string &description = getDescription();
if (!description.empty()) {
xmlElement.setAttributeString(gDescriptionPropertyName, description);
xmlElement.setAttribute(gDescriptionPropertyName, description);
}
}

string CElement::getXmlDescriptionAttribute(const CXmlElement& xmlElement) const
{
return xmlElement.getAttributeString(gDescriptionPropertyName);
}

void CElement::setXmlNameAttribute(CXmlElement& xmlElement) const
{
// By default, set Name attribute if any
Expand Down
13 changes: 2 additions & 11 deletions parameter/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ class CElement : public IXmlSink, public IXmlSource
*/
void setXmlDescriptionAttribute(CXmlElement& xmlElement) const;

/**
* Extract the Description field from the Xml Element during XML decomposing.
*
* @param[in] xmlElement to extract the description from.
*
* @return description represented as a string, empty if not found
*/
std::string getXmlDescriptionAttribute(const CXmlElement &xmlElement) const;

/**
* Appends if found human readable description property.
*
Expand All @@ -171,6 +162,8 @@ class CElement : public IXmlSink, public IXmlSource
CElement* createChild(const CXmlElement& childElement,
CXmlSerializingContext& elementSerializingContext);

static const std::string gDescriptionPropertyName;

private:
// Returns Name or Kind if no Name
std::string getPathName() const;
Expand All @@ -194,6 +187,4 @@ class CElement : public IXmlSink, public IXmlSource
std::vector<CElement*> _childArray;
// Parent
CElement* _pParent;

static const std::string gDescriptionPropertyName;
};
5 changes: 3 additions & 2 deletions parameter/EnumParameterType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void CEnumParameterType::showProperties(string& strResult) const
bool CEnumParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
{
// Size in bits
uint32_t uiSizeInBits = xmlElement.getAttributeInteger("Size");
uint32_t uiSizeInBits;
xmlElement.getAttribute("Size", uiSizeInBits);

// Size
setSize(uiSizeInBits / 8);
Expand Down Expand Up @@ -345,7 +346,7 @@ bool CEnumParameterType::isValid(int iNumerical, CParameterAccessContext& parame
void CEnumParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
{
// Size
xmlElement.setAttributeString("Size", CUtility::toString(getSize() * 8));
xmlElement.setAttribute("Size", getSize() * 8);

base::toXml(xmlElement, serializingContext);
}
Loading