diff options
author | David Wagner <david.wagner@intel.com> | 2015-02-18 15:15:04 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2015-02-18 15:15:04 +0100 |
commit | 8a4661428263e1f1a082b635a4e860818fb2fb52 (patch) | |
tree | 7a9d640b291f90723af9b463878dc5ed951bd4f2 | |
parent | d37ca914061debbd6135840834f2cae2ffbeb07e (diff) | |
parent | 36423a49fdde5755faea5914e554b64363034b0c (diff) | |
download | external_parameter-framework-8a4661428263e1f1a082b635a4e860818fb2fb52.zip external_parameter-framework-8a4661428263e1f1a082b635a4e860818fb2fb52.tar.gz external_parameter-framework-8a4661428263e1f1a082b635a4e860818fb2fb52.tar.bz2 |
Merge pull request #49 from pafonso/iminleg_rebase
Iminleg rebase
37 files changed, 498 insertions, 202 deletions
diff --git a/Schemas/Parameter.xsd b/Schemas/Parameter.xsd index 3b635fc..f174b6e 100644 --- a/Schemas/Parameter.xsd +++ b/Schemas/Parameter.xsd @@ -34,12 +34,21 @@ <xs:complexType name="Adaptation">
<xs:attribute name="Offset" type="xs:integer" default="0"/>
</xs:complexType>
- <xs:element name="LinearAdaptation">
+ <xs:complexType name="LinearAdaptationType">
+ <xs:complexContent>
+ <xs:extension base="Adaptation">
+ <xs:attribute name="SlopeNumerator" type="xs:double" default="1"/>
+ <xs:attribute name="SlopeDenominator" type="xs:double" default="1"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:element name="LinearAdaptation" type="LinearAdaptationType"/>
+ <xs:element name="LogarithmicAdaptation">
<xs:complexType>
<xs:complexContent>
- <xs:extension base="Adaptation">
- <xs:attribute name="SlopeNumerator" type="xs:double" default="1"/>
- <xs:attribute name="SlopeDenominator" type="xs:double" default="1"/>
+ <xs:extension base="LinearAdaptationType">
+ <xs:attribute name="LogarithmBase" type="xs:double" default="10"/>
+ <xs:attribute name="FloorValue" type="xs:double" default="-INF"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
@@ -63,6 +72,7 @@ <xs:extension base="Parameter">
<xs:choice minOccurs="0">
<xs:element ref="LinearAdaptation"/>
+ <xs:element ref="LogarithmicAdaptation"/>
</xs:choice>
<xs:attributeGroup ref="IntegerParameterAttributes"/>
<xs:attribute name="Unit" type="xs:token" use="optional"/>
diff --git a/bindings/python/Android.mk b/bindings/python/Android.mk index 296d4bc..0558344 100644 --- a/bindings/python/Android.mk +++ b/bindings/python/Android.mk @@ -76,6 +76,7 @@ $(generated-sources-dir)/pfw_wrap.h: $(generated-sources-dir)/pfw_wrap.cxx $(generated-sources-dir)/pfw_wrap.cxx: $(LOCAL_PATH)/pfw.i @echo "Generating Python binding files" mkdir -p $(dir $@) # surprisingly, path is not generated by build system + mkdir -p $(HOST_LIBRARY_PATH) prebuilts/misc/linux-x86_64/swig/swig \ -Iprebuilts/misc/common/swig/include/2.0.11/python/ \ -Iprebuilts/misc/common/swig/include/2.0.11/ \ diff --git a/bindings/python/pfw.i b/bindings/python/pfw.i index ce27173..9dbccbd 100644 --- a/bindings/python/pfw.i +++ b/bindings/python/pfw.i @@ -169,10 +169,6 @@ public: bool exportSingleDomainXml(std::string& strXmlDest, const std::string& strDomainName, bool bWithSettings, bool bToFile, std::string& strError) const; %clear std::string& strXmlDest; - -%apply std::string &OUTPUT { std::string& strResult } - bool getSystemClassXMLString(std::string& strResult); -%clear std::string& strResult; }; // SWIG nested class support is not complete - cf. diff --git a/parameter/Android.mk b/parameter/Android.mk index 8592c52..90e33f0 100644 --- a/parameter/Android.mk +++ b/parameter/Android.mk @@ -79,6 +79,7 @@ common_src_files := \ InstanceDefinition.cpp \ IntegerParameterType.cpp \ LinearParameterAdaptation.cpp \ + LogarithmicParameterAdaptation.cpp \ MappingContext.cpp \ MappingData.cpp \ ParameterAccessContext.cpp \ @@ -155,6 +156,8 @@ LOCAL_C_INCLUDES := $(common_c_includes) LOCAL_SHARED_LIBRARIES := $(common_shared_libraries) libdl LOCAL_STATIC_LIBRARIES := libxmlserializer libpfw_utility libxml2 +LOCAL_REQUIRED_MODULES := libremote-processor + LOCAL_CLANG := false include external/stlport/libstlport.mk include $(BUILD_SHARED_LIBRARY) diff --git a/parameter/CMakeLists.txt b/parameter/CMakeLists.txt index 9f93da7..94369fb 100644 --- a/parameter/CMakeLists.txt +++ b/parameter/CMakeLists.txt @@ -64,6 +64,7 @@ add_library(parameter SHARED InstanceDefinition.cpp IntegerParameterType.cpp LinearParameterAdaptation.cpp + LogarithmicParameterAdaptation.cpp MappingContext.cpp MappingData.cpp ParameterAccessContext.cpp diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp index edc3d46..edc3d46 100755..100644 --- a/parameter/IntegerParameterType.cpp +++ b/parameter/IntegerParameterType.cpp diff --git a/parameter/IntegerParameterType.h b/parameter/IntegerParameterType.h index 53bd4a8..53bd4a8 100755..100644 --- a/parameter/IntegerParameterType.h +++ b/parameter/IntegerParameterType.h diff --git a/parameter/LinearParameterAdaptation.cpp b/parameter/LinearParameterAdaptation.cpp index 4be92a9..ea833b3 100644 --- a/parameter/LinearParameterAdaptation.cpp +++ b/parameter/LinearParameterAdaptation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -37,6 +37,11 @@ CLinearParameterAdaptation::CLinearParameterAdaptation() : base("Linear"), _dSlo { } +CLinearParameterAdaptation::CLinearParameterAdaptation(const string& strType) : + base(strType), _dSlopeNumerator(1), _dSlopeDenominator(1) +{ +} + // Element properties void CLinearParameterAdaptation::showProperties(string& strResult) const { diff --git a/parameter/LinearParameterAdaptation.h b/parameter/LinearParameterAdaptation.h index f72f27b..8037c31 100644 --- a/parameter/LinearParameterAdaptation.h +++ b/parameter/LinearParameterAdaptation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -37,6 +37,7 @@ class CLinearParameterAdaptation : public CParameterAdaptation { public: CLinearParameterAdaptation(); + CLinearParameterAdaptation(const std::string& strType); // Conversions virtual int64_t fromUserValue(double dValue) const; diff --git a/parameter/LogarithmicParameterAdaptation.cpp b/parameter/LogarithmicParameterAdaptation.cpp new file mode 100644 index 0000000..688527d --- /dev/null +++ b/parameter/LogarithmicParameterAdaptation.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "LogarithmicParameterAdaptation.h" +#include <math.h> + +#define base CLinearParameterAdaptation + +// M_E is the base of the natural logarithm for 'e' from math.h +CLogarithmicParameterAdaptation::CLogarithmicParameterAdaptation() : base("Logarithmic"), + _dLogarithmBase(M_E), _dFloorValue(-INFINITY) +{ +} + +// Element properties +void CLogarithmicParameterAdaptation::showProperties(std::string& strResult) const +{ + base::showProperties(strResult); + + strResult += " - LogarithmBase: "; + strResult += toString(_dLogarithmBase); + strResult += "\n"; + strResult += " - FloorValue: "; + strResult += toString(_dFloorValue); + strResult += "\n"; +} + +bool CLogarithmicParameterAdaptation::fromXml(const CXmlElement& xmlElement, + CXmlSerializingContext& serializingContext) +{ + + if (xmlElement.hasAttribute("LogarithmBase")) { + + _dLogarithmBase = xmlElement.getAttributeDouble("LogarithmBase"); + + // Avoid negative and 1 values + if (_dLogarithmBase <= 0 || _dLogarithmBase == 1) { + serializingContext.setError("LogarithmBase attribute cannot be negative or 1 on element" + + xmlElement.getPath()); + + return false; + } + } + + if (xmlElement.hasAttribute("FloorValue")) { + _dFloorValue = xmlElement.getAttributeDouble("FloorValue"); + } + // Base + return base::fromXml(xmlElement, serializingContext); +} + + +int64_t CLogarithmicParameterAdaptation::fromUserValue(double dValue) const +{ + return fmax(round(base::fromUserValue(log(dValue) / log(_dLogarithmBase))), + _dFloorValue); +} + +double CLogarithmicParameterAdaptation::toUserValue(int64_t iValue) const +{ + return exp(base::toUserValue(iValue) * log(_dLogarithmBase)); +} diff --git a/parameter/LogarithmicParameterAdaptation.h b/parameter/LogarithmicParameterAdaptation.h new file mode 100644 index 0000000..3b7fd4d --- /dev/null +++ b/parameter/LogarithmicParameterAdaptation.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011-2015, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "LinearParameterAdaptation.h" + +/** + * This class is used to perform a logarithmic adapation of type: + * (slopeNumerator / slopeDenominator) * log(parameter) + offset + * Since log(x) == -INFINITY , we can define FloorValue as a + * x -> 0 + * a lower bound limit for the adaptation + */ +class CLogarithmicParameterAdaptation : public CLinearParameterAdaptation +{ +public: + CLogarithmicParameterAdaptation(); + + /** + * Conversions must satisfy the following: f(f'(a)) = a + * Let f=fromUserValue and f'=toUserValue + * if y = f(log(x)/log(base)), then + * f'(y) * log(base) = log (x) + * exp(f'(y)*log(base)) = x + */ + virtual int64_t fromUserValue(double dValue) const; + virtual double toUserValue(int64_t iValue) const; + + virtual void showProperties(std::string& strResult) const; + + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); +private: + /** + * _dLogarithmBase characterizes the new logarithm logB(x) with + * the following property: logB(x) = log(x) / log(_dLogarithmBase). + * log being the base-e logarithm. + */ + double _dLogarithmBase; + /** + * _dFloorValue reflects the lower bound for volume attenuation + */ + double _dFloorValue; +}; diff --git a/parameter/ParameterAccessContext.cpp b/parameter/ParameterAccessContext.cpp index bbbbd22..e228d9b 100644 --- a/parameter/ParameterAccessContext.cpp +++ b/parameter/ParameterAccessContext.cpp @@ -98,7 +98,7 @@ void CParameterAccessContext::setOutputRawFormat(bool bIsHex) _bOutputRawFormatIsHex = bIsHex; } -bool CParameterAccessContext::outputRawFormatIsHex() +bool CParameterAccessContext::outputRawFormatIsHex() const { return _bOutputRawFormatIsHex; } diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h index b59debb..302f920 100644 --- a/parameter/ParameterAccessContext.h +++ b/parameter/ParameterAccessContext.h @@ -57,9 +57,20 @@ public: void setValueSpaceRaw(bool bIsRaw); bool valueSpaceIsRaw() const; - // Output Raw Format for user get value interpretation + /** + * Assigns Output Raw Format for user get value interpretation. + * + * @param[in] bIsHex "true" for hexadecimal, "false" for decimal + * + */ void setOutputRawFormat(bool bIsHex); - bool outputRawFormatIsHex(); + /** + * Returns Output Raw Format for user get value interpretation. + * + * @return "true" for hexadecimal, "false" for decimal + * + */ + bool outputRawFormatIsHex() const; // Endianness void setBigEndianSubsystem(bool bBigEndian); diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 4b8bdf6..fb09a7f 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -79,6 +79,7 @@ #include <assert.h> #include "ParameterHandle.h" #include "LinearParameterAdaptation.h" +#include "LogarithmicParameterAdaptation.h" #include "EnumValuePair.h" #include "Subsystem.h" #include "XmlFileDocSink.h" @@ -87,8 +88,11 @@ #include "XmlStringDocSource.h" #include "XmlMemoryDocSink.h" #include "XmlMemoryDocSource.h" +#include "SelectionCriteriaDefinition.h" #include "Utility.h" #include <sstream> +#include <algorithm> +#include <ctype.h> #include <memory> #define base CElement @@ -160,7 +164,7 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa /// Criteria { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, - "[csv]", "List selection criteria" }, + "[CSV|XML]", "List selection criteria" }, /// Domains { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, @@ -300,7 +304,7 @@ CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) : _pElementLibrarySet(new CElementLibrarySet), _strXmlConfigurationFilePath(strConfigurationFilePath), _pSubsystemPlugins(NULL), - _handleLibRemoteProcessor(NULL), + _pvLibRemoteProcessorHandle(NULL), _uiStructureChecksum(0), _pRemoteProcessorServer(NULL), _uiMaxCommandUsageLength(0), @@ -358,8 +362,9 @@ CParameterMgr::~CParameterMgr() delete _pElementLibrarySet; // Close remote processor library - if (_handleLibRemoteProcessor != NULL) { - dlclose(_handleLibRemoteProcessor); + if (_pvLibRemoteProcessorHandle) { + + dlclose(_pvLibRemoteProcessorHandle); } // Tuning Mode Mutex @@ -454,6 +459,12 @@ bool CParameterMgr::load(string& strError) return false; } + // Init flow of element tree + if (!init(strError)) { + + return false; + } + // Back synchronization for areas in parameter blackboard not covered by any domain CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(); @@ -1076,28 +1087,53 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess /// Criteria CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - (void)remoteCommand; + if (remoteCommand.getArgumentCount() > 1) { + + return CCommandHandler::EShowUsage; + } - bool humanReadable = true; + string strOutputFormat; // Look for optional arguments - if (remoteCommand.getArgumentCount() >= 1) { + if (remoteCommand.getArgumentCount() == 1) { + + // Get requested format + strOutputFormat = remoteCommand.getArgument(0); + + // Capitalize + std::transform(strOutputFormat.begin(), strOutputFormat.end(), strOutputFormat.begin(), ::toupper); + + if (strOutputFormat != "XML" && strOutputFormat != "CSV") { - // If csv is provided, format the criterion list in Commas Separated Value pairs - if (remoteCommand.getArgument(0) == "csv") { - humanReadable = false; - } else { return CCommandHandler::EShowUsage; } } - list<string> lstrResult; - getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable); + if (strOutputFormat == "XML") { + // Get Root element where to export from + const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition = getConstSelectionCriteria()->getSelectionCriteriaDefinition(); - // Concatenate the criterion list as the command result - CUtility::asString(lstrResult, strResult); + if (!exportElementToXMLString(pSelectionCriteriaDefinition, "SelectionCriteria", + strResult)) { - return CCommandHandler::ESucceeded; + return CCommandHandler::EFailed; + } + + // Succeeded + return CCommandHandler::ESucceeded; + } else { + + // Requested format will be either CSV or human readable based on strOutputFormat content + bool bHumanReadable = strOutputFormat.empty(); + + list<string> lstrResult; + getSelectionCriteria()->listSelectionCriteria(lstrResult, true, bHumanReadable); + + // Concatenate the criterion list as the command result + CUtility::asString(lstrResult, strResult); + + return CCommandHandler::ESucceeded; + } } /// Domains @@ -1639,7 +1675,10 @@ CParameterMgr::CCommandHandler::CommandStatus { (void)remoteCommand; - if (!getSystemClassXMLString(strResult)) { + // Get Root element where to export from + const CSystemClass* pSystemClass = getSystemClass(); + + if (!exportElementToXMLString(pSystemClass, pSystemClass->getKind(), strResult)) { return CCommandHandler::EFailed; } @@ -2409,6 +2448,7 @@ void CParameterMgr::feedElementLibraries() pParameterCreationLibrary->addElementBuilder("BooleanParameter", new TNamedElementBuilderTemplate<CBooleanParameterType>()); pParameterCreationLibrary->addElementBuilder("IntegerParameter", new TNamedElementBuilderTemplate<CIntegerParameterType>()); pParameterCreationLibrary->addElementBuilder("LinearAdaptation", new TElementBuilderTemplate<CLinearParameterAdaptation>()); + pParameterCreationLibrary->addElementBuilder("LogarithmicAdaptation", new TElementBuilderTemplate<CLogarithmicParameterAdaptation>()); pParameterCreationLibrary->addElementBuilder("EnumParameter", new TNamedElementBuilderTemplate<CEnumParameterType>()); pParameterCreationLibrary->addElementBuilder("ValuePair", new TElementBuilderTemplate<CEnumValuePair>()); pParameterCreationLibrary->addElementBuilder("FixedPointParameter", new TNamedElementBuilderTemplate<CFixedPointParameterType>()); @@ -2453,9 +2493,9 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) log_info("Loading remote processor library"); // Load library - _handleLibRemoteProcessor = dlopen("libremote-processor.so", RTLD_NOW); + _pvLibRemoteProcessorHandle = dlopen("libremote-processor.so", RTLD_NOW); - if (!_handleLibRemoteProcessor) { + if (!_pvLibRemoteProcessorHandle) { // Return error const char* pcError = dlerror(); @@ -2471,7 +2511,7 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) return false; } - CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_handleLibRemoteProcessor, "createRemoteProcessorServer"); + CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_pvLibRemoteProcessorHandle, "createRemoteProcessorServer"); if (!pfnCreateRemoteProcessorServer) { @@ -2574,28 +2614,27 @@ void CParameterMgr::doApplyConfigurations(bool bForce) getSelectionCriteria()->resetModifiedStatus(); } -bool CParameterMgr::getSystemClassXMLString(string& strResult) +// Export to XML string +bool CParameterMgr::exportElementToXMLString(const IXmlSource* pXmlSource, + const string& strRootElementType, + string& strResult) const { - // Root element - const CSystemClass* pSystemClass = getSystemClass(); - string strError; CXmlSerializingContext xmlSerializingContext(strError); // Use a doc source by loading data from instantiated Configurable Domains - CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind(), - _bValidateSchemasOnStart); + CXmlMemoryDocSource memorySource(pXmlSource, strRootElementType, false); // Use a doc sink that write the doc data in a string CXmlStringDocSink stringSink(strResult); + // Do the export bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext); if (!bProcessSuccess) { strResult = strError; - } return bProcessSuccess; diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index c6a2fd5..6a3ecb8 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -88,7 +88,7 @@ class CParameterMgr : private CElement }; // Version static const uint32_t guiEditionMajor = 0x2; - static const uint32_t guiEditionMinor = 0x3; + static const uint32_t guiEditionMinor = 0x4; static const uint32_t guiRevision = 0x0; // Parameter handle friendship @@ -340,14 +340,17 @@ public: bool exportDomainsBinary(const std::string& strFileName, std::string& strError); /** - * Method that creates an Xml description of the instanciated parameter structure contained - * in SystemClass. + * Method that exports an Xml description of the passed element into a string * - * @param[out] strResult contains the xml description of SystemClass or the errors if any + * @param[in] pXmlSource The source element to export + * @param[in] strRootElementType The XML root element name of the exported instance document + * @param[out] strResult contains the xml description or the error description in case false is returned * - * @return false if any error occures during the creation of the xml description + * @return true for success, false if any error occurs during the creation of the xml description (validation or encoding) */ - bool getSystemClassXMLString(std::string& strResult); + bool exportElementToXMLString(const IXmlSource* pXmlSource, + const std::string& strRootElementType, + std::string& strResult) const; // CElement virtual std::string getKind() const; @@ -597,8 +600,10 @@ private: // Subsystem plugin location const CSubsystemPlugins* _pSubsystemPlugins; - // Remote processor library handle - void *_handleLibRemoteProcessor; + /** + * Remote processor library handle + */ + void* _pvLibRemoteProcessorHandle; // Whole system structure checksum uint8_t _uiStructureChecksum; diff --git a/parameter/ParameterMgrFullConnector.cpp b/parameter/ParameterMgrFullConnector.cpp index b03facc..30f31e9 100644 --- a/parameter/ParameterMgrFullConnector.cpp +++ b/parameter/ParameterMgrFullConnector.cpp @@ -363,8 +363,3 @@ bool CParameterMgrFullConnector::exportSingleDomainXml(string& strXmlDest, return _pParameterMgr->exportSingleDomainXml(strXmlDest, strDomainName, bWithSettings, bToFile, strError); } - -bool CParameterMgrFullConnector::getSystemClassXMLString(string& strResult) -{ - return _pParameterMgr->getSystemClassXMLString(strResult); -} diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index f29c8a8..d49003d 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -175,12 +175,6 @@ bool CParameterMgrPlatformConnector::start(string& strError) return false; } - // Init flow - if (!_pParameterMgr->init(strError)) { - - return false; - } - _bStarted = true; return true; diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp index 01d94aa..01d94aa 100755..100644 --- a/parameter/ParameterType.cpp +++ b/parameter/ParameterType.cpp diff --git a/parameter/ParameterType.h b/parameter/ParameterType.h index 7d7caf7..7d7caf7 100755..100644 --- a/parameter/ParameterType.h +++ b/parameter/ParameterType.h diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp index f49137b..7818924 100644 --- a/parameter/SelectionCriterion.cpp +++ b/parameter/SelectionCriterion.cpp @@ -27,6 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include "SelectionCriterion.h" #include "AutoLog.h" @@ -168,3 +169,15 @@ std::string CSelectionCriterion::getFormattedDescription(bool bWithTypeInfo, boo } return strFormattedDescription; } + +// XML export +void CSelectionCriterion::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Current Value + xmlElement.setAttributeString("Value", _pType->getFormattedState(_iState)); + + // Serialize Type node + _pType->toXml(xmlElement, serializingContext); + + base::toXml(xmlElement, serializingContext); +} diff --git a/parameter/SelectionCriterion.h b/parameter/SelectionCriterion.h index c61d7d0..cf99035 100644 --- a/parameter/SelectionCriterion.h +++ b/parameter/SelectionCriterion.h @@ -63,6 +63,15 @@ public: /// From CElement virtual std::string getKind() const; + + /** + * Export to XML + * + * @param[in] xmlElement The XML element to export to + * @param[in] serializingContext The serializing context + * + */ + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; private: // Current state int _iState; diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp index 3e9cc80..95e8e46 100644 --- a/parameter/SelectionCriterionType.cpp +++ b/parameter/SelectionCriterionType.cpp @@ -203,3 +203,26 @@ std::string CSelectionCriterionType::getFormattedState(int iValue) const return strFormattedState; } + +// From IXmlSource +void CSelectionCriterionType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Type Kind + xmlElement.setAttributeString("Kind", isTypeInclusive() ? "Inclusive" : "Exclusive"); + + // Value pairs as children + NumToLitMapConstIt it; + + for (it = _numToLitMap.begin(); it != _numToLitMap.end(); ++it) { + + CXmlElement childValuePairElement; + + xmlElement.createChild(childValuePairElement, "ValuePair"); + // Literal + childValuePairElement.setAttributeString("Literal", it->first); + // Numerical + childValuePairElement.setAttributeSignedInteger("Numerical", it->second); + } + + base::toXml(xmlElement, serializingContext); +} diff --git a/parameter/SelectionCriterionType.h b/parameter/SelectionCriterionType.h index bfef21e..ef4176a 100644 --- a/parameter/SelectionCriterionType.h +++ b/parameter/SelectionCriterionType.h @@ -63,6 +63,15 @@ public: // Formatted state virtual std::string getFormattedState(int iValue) const; + /** + * Export to XML + * + * @param[in] xmlElement The XML element to export to + * @param[in] serializingContext The serializing context + * + */ + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + // From CElement virtual std::string getKind() const; private: diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index 76b9549..76b9549 100755..100644 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index ab085bc..ab085bc 100755..100644 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index effc573..334772a 100644 --- a/parameter/SystemClass.cpp +++ b/parameter/SystemClass.cpp @@ -71,11 +71,16 @@ CSystemClass::~CSystemClass() { delete _pSubsystemLibrary; - // Close all previously opened libraries - while (!_subsystemLibraries.empty()) - { - dlclose(_subsystemLibraries.back()); - _subsystemLibraries.pop_back(); + // Destroy child subsystems *before* unloading the libraries (otherwise crashes will occur + // as unmapped code will be referenced) + clean(); + + // Close all previously opened subsystem libraries + list<void*>::const_iterator it; + + for (it = _subsystemLibraryHandleList.begin(); it != _subsystemLibraryHandleList.end(); ++it) { + + dlclose(*it); } } @@ -238,7 +243,7 @@ bool CSystemClass::loadPlugins(list<string>& lstrPluginFiles, list<string>& lstr } // Store libraries handles - _subsystemLibraries.push_back(lib_handle); + _subsystemLibraryHandleList.push_back(lib_handle); // Get plugin symbol string strPluginSymbol = getPluginSymbol(strPluginFileName); @@ -309,12 +314,3 @@ bool CSystemClass::init(string& strError) { return base::init(strError); } - -// From IXmlSource -void CSystemClass::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const -{ - // Set the name of system class - xmlElement.setNameAttribute(getName()); - - base::toXml(xmlElement, serializingContext); -} diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h index 3ffbf25..a224609 100644 --- a/parameter/SystemClass.h +++ b/parameter/SystemClass.h @@ -75,9 +75,6 @@ public: virtual bool init(std::string& strError); virtual std::string getKind() const; - // From IXmlSource - virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; - private: CSystemClass(const CSystemClass&); CSystemClass& operator=(const CSystemClass&); @@ -111,6 +108,6 @@ private: // Subsystem factory CSubsystemLibrary* _pSubsystemLibrary; - std::list<void*> _subsystemLibraries; /**< Contains the list of all open plugin libs. */ + std::list<void*> _subsystemLibraryHandleList; /**< Contains the list of all open plugin libs. */ }; diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp index 7e58c75..7e58c75 100755..100644 --- a/parameter/TypeElement.cpp +++ b/parameter/TypeElement.cpp diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h index 8f474c0..8f474c0 100755..100644 --- a/parameter/TypeElement.h +++ b/parameter/TypeElement.h diff --git a/parameter/include/ParameterMgrFullConnector.h b/parameter/include/ParameterMgrFullConnector.h index 8ef7bb7..31022a6 100644 --- a/parameter/include/ParameterMgrFullConnector.h +++ b/parameter/include/ParameterMgrFullConnector.h @@ -259,16 +259,6 @@ public: bool exportSingleDomainXml(std::string& strXmlDest, const std::string& strDomainName, bool bWithSettings, bool bToFile, std::string& strError) const; - /** - * Method that creates an Xml description of the instanciated parameter structure contained - * in SystemClass. - * - * @param[out] strResult contains the xml description of SystemClass or the errors if any - * - * @return false if any error occures during the creation of the xml description - */ - bool getSystemClassXMLString(std::string& strResult); - private: // disallow copying because this class manages raw pointers' lifecycle CParameterMgrFullConnector(const CParameterMgrFullConnector&); diff --git a/remote-process/main.cpp b/remote-process/main.cpp index bcf825b..97881dc 100644 --- a/remote-process/main.cpp +++ b/remote-process/main.cpp @@ -157,9 +157,6 @@ int main(int argc, char *argv[]) // Connect to target CConnectionSocket connectionSocket; - // Set timeout - connectionSocket.setTimeout(5000); - string strError; // Connect if (!connectionSocket.connect(argv[1], uiPort, strError)) { diff --git a/remote-processor/RemoteProcessorServer.cpp b/remote-processor/RemoteProcessorServer.cpp index dff935b..c1d87e5 100644 --- a/remote-processor/RemoteProcessorServer.cpp +++ b/remote-processor/RemoteProcessorServer.cpp @@ -157,9 +157,6 @@ void CRemoteProcessorServer::handleNewConnection() return; } - // Set timeout - clientSocket->setTimeout(5000); - // Process all incoming requests from the client while (true) { diff --git a/test/test-platform/TestPlatform.cpp b/test/test-platform/TestPlatform.cpp index b2b895c..a6613e9 100644 --- a/test/test-platform/TestPlatform.cpp +++ b/test/test-platform/TestPlatform.cpp @@ -47,7 +47,8 @@ class CParameterMgrPlatformConnectorLogger : public CParameterMgrPlatformConnect public: CParameterMgrPlatformConnectorLogger() {} - virtual void log(bool bIsWarning, const string& strLog) { + virtual void log(bool bIsWarning, const string& strLog) + { if (bIsWarning) { @@ -71,24 +72,24 @@ CTestPlatform::CTestPlatform(const string& strClass, int iPortNumber, sem_t& exi _pCommandHandler->addCommandParser("exit", &CTestPlatform::exit, 0, "", "Exit TestPlatform"); _pCommandHandler->addCommandParser( - "createExclusiveSelectionCriterionFromStateList", - &CTestPlatform::createExclusiveSelectionCriterionFromStateList, - 2, "<name> <stateList>", - "Create inclusive selection criterion from state name list"); + "createExclusiveSelectionCriterionFromStateList", + &CTestPlatform::createExclusiveSelectionCriterionFromStateList, + 2, "<name> <stateList>", + "Create inclusive selection criterion from state name list"); _pCommandHandler->addCommandParser( - "createInclusiveSelectionCriterionFromStateList", - &CTestPlatform::createInclusiveSelectionCriterionFromStateList, - 2, "<name> <stateList>", - "Create exclusive selection criterion from state name list"); + "createInclusiveSelectionCriterionFromStateList", + &CTestPlatform::createInclusiveSelectionCriterionFromStateList, + 2, "<name> <stateList>", + "Create exclusive selection criterion from state name list"); _pCommandHandler->addCommandParser( - "createExclusiveSelectionCriterion", - &CTestPlatform::createExclusiveSelectionCriterion, - 2, "<name> <nbStates>", "Create inclusive selection criterion"); + "createExclusiveSelectionCriterion", + &CTestPlatform::createExclusiveSelectionCriterion, + 2, "<name> <nbStates>", "Create inclusive selection criterion"); _pCommandHandler->addCommandParser( - "createInclusiveSelectionCriterion", - &CTestPlatform::createInclusiveSelectionCriterion, - 2, "<name> <nbStates>", "Create exclusive selection criterion"); + "createInclusiveSelectionCriterion", + &CTestPlatform::createInclusiveSelectionCriterion, + 2, "<name> <nbStates>", "Create exclusive selection criterion"); _pCommandHandler->addCommandParser("start", &CTestPlatform::startParameterMgr, 0, "", "Start ParameterMgr"); @@ -97,42 +98,42 @@ CTestPlatform::CTestPlatform(const string& strClass, int iPortNumber, sem_t& exi 2, "<name> <state>", "Set the current state of a selection criterion"); _pCommandHandler->addCommandParser( - "applyConfigurations", - &CTestPlatform::applyConfigurations, - 0, "", "Apply configurations selected by current selection criteria states"); + "applyConfigurations", + &CTestPlatform::applyConfigurations, + 0, "", "Apply configurations selected by current selection criteria states"); _pCommandHandler->addCommandParser( - "setFailureOnMissingSubsystem", - &CTestPlatform::setter<&CParameterMgrPlatformConnector::setFailureOnMissingSubsystem>, - 1, "true|false", "Set policy for missing subsystems, " - "either abort start or fallback on virtual subsystem."); + "setFailureOnMissingSubsystem", + &CTestPlatform::setter<& CParameterMgrPlatformConnector::setFailureOnMissingSubsystem>, + 1, "true|false", "Set policy for missing subsystems, " + "either abort start or fallback on virtual subsystem."); _pCommandHandler->addCommandParser( - "getMissingSubsystemPolicy", - &CTestPlatform::getter<&CParameterMgrPlatformConnector::getFailureOnMissingSubsystem>, - 0, "", "Get policy for missing subsystems, " - "either abort start or fallback on virtual subsystem."); + "getMissingSubsystemPolicy", + &CTestPlatform::getter<& CParameterMgrPlatformConnector::getFailureOnMissingSubsystem>, + 0, "", "Get policy for missing subsystems, " + "either abort start or fallback on virtual subsystem."); _pCommandHandler->addCommandParser( - "setFailureOnFailedSettingsLoad", - &CTestPlatform::setter<&CParameterMgrPlatformConnector::setFailureOnFailedSettingsLoad>, - 1, "true|false", - "Set policy for failed settings load, either abort start or continue without domains."); + "setFailureOnFailedSettingsLoad", + &CTestPlatform::setter<& CParameterMgrPlatformConnector::setFailureOnFailedSettingsLoad>, + 1, "true|false", + "Set policy for failed settings load, either abort start or continue without domains."); _pCommandHandler->addCommandParser( - "getFailedSettingsLoadPolicy", - &CTestPlatform::getter<&CParameterMgrPlatformConnector::getFailureOnFailedSettingsLoad>, - 0, "", - "Get policy for failed settings load, either abort start or continue without domains."); + "getFailedSettingsLoadPolicy", + &CTestPlatform::getter<& CParameterMgrPlatformConnector::getFailureOnFailedSettingsLoad>, + 0, "", + "Get policy for failed settings load, either abort start or continue without domains."); _pCommandHandler->addCommandParser( - "setValidateSchemasOnStart", - &CTestPlatform::setter<&CParameterMgrPlatformConnector::setValidateSchemasOnStart>, - 1, "true|false", - "Set policy for schema validation based on .xsd files (false by default)."); + "setValidateSchemasOnStart", + &CTestPlatform::setter<& CParameterMgrPlatformConnector::setValidateSchemasOnStart>, + 1, "true|false", + "Set policy for schema validation based on .xsd files (false by default)."); _pCommandHandler->addCommandParser( - "getValidateSchemasOnStart", - &CTestPlatform::getter<&CParameterMgrPlatformConnector::getValidateSchemasOnStart>, - 0, "", - "Get policy for schema validation based on .xsd files."); + "getValidateSchemasOnStart", + &CTestPlatform::getter<& CParameterMgrPlatformConnector::getValidateSchemasOnStart>, + 0, "", + "Get policy for schema validation based on .xsd files."); // Create server _pRemoteProcessorServer = new CRemoteProcessorServer(iPortNumber, _pCommandHandler); @@ -149,7 +150,7 @@ CTestPlatform::~CTestPlatform() } CTestPlatform::CommandReturn CTestPlatform::exit( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; @@ -180,53 +181,53 @@ bool CTestPlatform::load(std::string& strError) //////////////// Remote command parsers /// Selection Criterion CTestPlatform::CommandReturn CTestPlatform::createExclusiveSelectionCriterionFromStateList( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { return createExclusiveSelectionCriterionFromStateList( - remoteCommand.getArgument(0), remoteCommand, strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + remoteCommand.getArgument(0), remoteCommand, strResult) ? + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } CTestPlatform::CommandReturn CTestPlatform::createInclusiveSelectionCriterionFromStateList( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { return createInclusiveSelectionCriterionFromStateList( - remoteCommand.getArgument(0), remoteCommand, strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + remoteCommand.getArgument(0), remoteCommand, strResult) ? + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } CTestPlatform::CommandReturn CTestPlatform::createExclusiveSelectionCriterion( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { return createExclusiveSelectionCriterion( - remoteCommand.getArgument(0), - strtoul(remoteCommand.getArgument(1).c_str(), NULL, 0), - strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + remoteCommand.getArgument(0), + strtoul(remoteCommand.getArgument(1).c_str(), NULL, 0), + strResult) ? + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } CTestPlatform::CommandReturn CTestPlatform::createInclusiveSelectionCriterion( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { return createInclusiveSelectionCriterion( - remoteCommand.getArgument(0), - strtoul(remoteCommand.getArgument(1).c_str(), NULL, 0), - strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + remoteCommand.getArgument(0), + strtoul(remoteCommand.getArgument(1).c_str(), NULL, 0), + strResult) ? + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } CTestPlatform::CommandReturn CTestPlatform::startParameterMgr( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; return _pParameterMgrPlatformConnector->start(strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } -template<CTestPlatform::setter_t setFunction> +template <CTestPlatform::setter_t setFunction> CTestPlatform::CommandReturn CTestPlatform::setter( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { const string& strAbort = remoteCommand.getArgument(0); @@ -237,49 +238,51 @@ CTestPlatform::CommandReturn CTestPlatform::setter( } return (_pParameterMgrPlatformConnector->*setFunction)(bFail, strResult) ? - CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; } -template<CTestPlatform::getter_t getFunction> +template <CTestPlatform::getter_t getFunction> CTestPlatform::CommandReturn CTestPlatform::getter( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; strResult = (_pParameterMgrPlatformConnector->*getFunction)() ? "true" : "false"; - return CTestPlatform::CCommandHandler::ESucceeded; + return CTestPlatform::CCommandHandler::ESucceeded; } CTestPlatform::CommandReturn CTestPlatform::setCriterionState( - const IRemoteCommand& remoteCommand, string& strResult) + const IRemoteCommand& remoteCommand, string& strResult) { bool bSuccess; - const char * pcState = remoteCommand.getArgument(1).c_str(); + const char* pcState = remoteCommand.getArgument(1).c_str(); - char *pcStrEnd; + char* pcStrEnd; // Reset errno to check if it is updated during the conversion (strtol/strtoul) errno = 0; - uint32_t state = strtoul(pcState , &pcStrEnd, 0); + uint32_t state = strtoul(pcState, &pcStrEnd, 0); if (!errno && (*pcStrEnd == '\0')) { // Sucessfull conversion, set criterion state by numerical state - bSuccess = setCriterionState(remoteCommand.getArgument(0), state , strResult ) ; + bSuccess = setCriterionState(remoteCommand.getArgument(0), state, strResult); } else { // Conversion failed, set criterion state by lexical state - bSuccess = setCriterionStateByLexicalSpace(remoteCommand , strResult ); + bSuccess = setCriterionStateByLexicalSpace(remoteCommand, strResult); } - return bSuccess ? CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; + return bSuccess ? CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler:: + EFailed; } -CTestPlatform::CommandReturn CTestPlatform::applyConfigurations(const IRemoteCommand& remoteCommand, string& strResult) +CTestPlatform::CommandReturn CTestPlatform::applyConfigurations(const IRemoteCommand& remoteCommand, + string& strResult) { (void)remoteCommand; (void)strResult; @@ -291,16 +294,20 @@ CTestPlatform::CommandReturn CTestPlatform::applyConfigurations(const IRemoteCom //////////////// Remote command handlers -bool CTestPlatform::createExclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult) +bool CTestPlatform::createExclusiveSelectionCriterionFromStateList( + const string& strName, + const IRemoteCommand& remoteCommand, + string& strResult) { - assert (_pParameterMgrPlatformConnector != NULL); + assert(_pParameterMgrPlatformConnector != NULL); - ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(false); + ISelectionCriterionTypeInterface* pCriterionType = + _pParameterMgrPlatformConnector->createSelectionCriterionType(false); assert(pCriterionType != NULL); - uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1 ; + uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1; uint32_t uiState; for (uiState = 0; uiState < uiNbStates; uiState++) { @@ -320,15 +327,19 @@ bool CTestPlatform::createExclusiveSelectionCriterionFromStateList(const string& return true; } -bool CTestPlatform::createInclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult) +bool CTestPlatform::createInclusiveSelectionCriterionFromStateList( + const string& strName, + const IRemoteCommand& remoteCommand, + string& strResult) { - assert (_pParameterMgrPlatformConnector != NULL); + assert(_pParameterMgrPlatformConnector != NULL); - ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(true); + ISelectionCriterionTypeInterface* pCriterionType = + _pParameterMgrPlatformConnector->createSelectionCriterionType(true); assert(pCriterionType != NULL); - uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1 ; + uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1; if (uiNbStates > 32) { @@ -357,9 +368,12 @@ bool CTestPlatform::createInclusiveSelectionCriterionFromStateList(const string& } -bool CTestPlatform::createExclusiveSelectionCriterion(const string& strName, uint32_t uiNbStates, string& strResult) +bool CTestPlatform::createExclusiveSelectionCriterion(const string& strName, + uint32_t uiNbStates, + string& strResult) { - ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(false); + ISelectionCriterionTypeInterface* pCriterionType = + _pParameterMgrPlatformConnector->createSelectionCriterionType(false); uint32_t uistate; @@ -383,9 +397,12 @@ bool CTestPlatform::createExclusiveSelectionCriterion(const string& strName, uin return true; } -bool CTestPlatform::createInclusiveSelectionCriterion(const string& strName, uint32_t uiNbStates, string& strResult) +bool CTestPlatform::createInclusiveSelectionCriterion(const string& strName, + uint32_t uiNbStates, + string& strResult) { - ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(true); + ISelectionCriterionTypeInterface* pCriterionType = + _pParameterMgrPlatformConnector->createSelectionCriterionType(true); if (uiNbStates > 32) { @@ -418,7 +435,8 @@ bool CTestPlatform::createInclusiveSelectionCriterion(const string& strName, uin bool CTestPlatform::setCriterionState(const string& strName, uint32_t uiState, string& strResult) { - ISelectionCriterionInterface* pCriterion = _pParameterMgrPlatformConnector->getSelectionCriterion(strName); + ISelectionCriterionInterface* pCriterion = + _pParameterMgrPlatformConnector->getSelectionCriterion(strName); if (!pCriterion) { @@ -432,13 +450,15 @@ bool CTestPlatform::setCriterionState(const string& strName, uint32_t uiState, s return true; } -bool CTestPlatform::setCriterionStateByLexicalSpace(const IRemoteCommand& remoteCommand, string& strResult) +bool CTestPlatform::setCriterionStateByLexicalSpace(const IRemoteCommand& remoteCommand, + string& strResult) { // Get criterion name std::string strCriterionName = remoteCommand.getArgument(0); - ISelectionCriterionInterface* pCriterion = _pParameterMgrPlatformConnector->getSelectionCriterion(strCriterionName); + ISelectionCriterionInterface* pCriterion = + _pParameterMgrPlatformConnector->getSelectionCriterion(strCriterionName); if (!pCriterion) { @@ -462,30 +482,38 @@ bool CTestPlatform::setCriterionStateByLexicalSpace(const IRemoteCommand& remote } /// Translate lexical state to numerical state - uint32_t uiNumericalState = 0; + int iNumericalState = 0; uint32_t uiLexicalSubStateIndex; // Parse lexical substates - for (uiLexicalSubStateIndex = 1; uiLexicalSubStateIndex <= uiNbSubStates; uiLexicalSubStateIndex++) { - - int iNumericalSubState; - - const std::string& strLexicalSubState = remoteCommand.getArgument(uiLexicalSubStateIndex); - - // Translate lexical to numerical substate - if (!pCriterionType->getNumericalValue(strLexicalSubState, iNumericalSubState)) { + std::string strLexicalState = ""; + + for (uiLexicalSubStateIndex = 1; + uiLexicalSubStateIndex <= uiNbSubStates; + uiLexicalSubStateIndex++) { + /* + * getNumericalValue method from ISelectionCriterionTypeInterface strip his parameter + * first parameter based on | sign. In case that the user uses multiple parameters + * to set InclusiveCriterion value, we aggregate all desired values to be sure + * they will be handled correctly. + */ + if (uiLexicalSubStateIndex != 1) { + strLexicalState += "|"; + } + strLexicalState += remoteCommand.getArgument(uiLexicalSubStateIndex); + } - strResult = "Unable to find lexical state \"" + strLexicalSubState + "\" in criteria " + strCriterionName; + // Translate lexical to numerical substate + if (!pCriterionType->getNumericalValue(strLexicalState, iNumericalState)) { - return false; - } + strResult = "Unable to find lexical state \"" + + strLexicalState + "\" in criteria " + strCriterionName; - // Aggregate numerical substates - uiNumericalState |= iNumericalSubState; + return false; } // Set criterion new state - pCriterion->setCriterionState(uiNumericalState); + pCriterion->setCriterionState(iNumericalState); return true; } diff --git a/tools/xmlGenerator/hostDomainGenerator.sh b/tools/xmlGenerator/hostDomainGenerator.sh index 4222382..1a7d315 100755 --- a/tools/xmlGenerator/hostDomainGenerator.sh +++ b/tools/xmlGenerator/hostDomainGenerator.sh @@ -245,7 +245,7 @@ changeSocketsPorts() { # Start the pfw using different socket if it fails safeStartPFW () { local retry=0 - local nbRetry=10 + local nbRetry=1000 # Workaround to avoid build failure, it very very rarely fail this many time # Choose a new pair of socket ports changeSocketsPorts diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp index 106bfdc..d45f360 100644 --- a/xmlserializer/XmlElement.cpp +++ b/xmlserializer/XmlElement.cpp @@ -221,6 +221,13 @@ void CXmlElement::setAttributeInteger(const string& strAttributeName, uint32_t u setAttributeString(strAttributeName, strStream.str()); } +void CXmlElement::setAttributeSignedInteger(const string& strAttributeName, int32_t iValue) +{ + ostringstream strStream; + strStream << iValue; + setAttributeString(strAttributeName, strStream.str()); +} + void CXmlElement::setNameAttribute(const string& strValue) { setAttributeString("Name", strValue); diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h index 9c5ca0e..7c1d518 100644 --- a/xmlserializer/XmlElement.h +++ b/xmlserializer/XmlElement.h @@ -71,6 +71,14 @@ public: void setTextContent(const std::string& strContent); void setComment(const std::string& strComment); void setAttributeInteger(const std::string& strAttributeName, uint32_t uiValue); + /** + * Set attribute with signed integer + * + * @param[in] strAttributeName The attribute name + * @param[in] iValue The attribute value + * + */ + void setAttributeSignedInteger(const std::string& strAttributeName, int32_t iValue); // Child creation void createChild(CXmlElement& childElement, const std::string& strType); diff --git a/xmlserializer/XmlStringDocSink.cpp b/xmlserializer/XmlStringDocSink.cpp index 4b05d85..caec545 100644 --- a/xmlserializer/XmlStringDocSink.cpp +++ b/xmlserializer/XmlStringDocSink.cpp @@ -27,7 +27,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include "XmlStringDocSink.h" #include <libxml/parser.h> @@ -50,6 +49,8 @@ bool CXmlStringDocSink::doProcess(CXmlDocSource& xmlDocSource, if (!pcDumpedDoc) { + serializingContext.setError("Unable to encode XML document in memory"); + return false; } |