From 3adb785eb097028750fc1b4c5ecab3bebf1a9ae3 Mon Sep 17 00:00:00 2001 From: Guillaume Denneulin Date: Tue, 8 Jul 2014 09:11:22 +0200 Subject: Move element tree initialisation to load function BZ: 207091 The parameter platform manager used to initialize the element tree. However, this is too early for plugins, since they need information from the core which have not been initialized yet. This patch delays the initialization of the element tree by adding it to the load() function of the ParameterMgr. Change-Id: I98e0e3a20ac0af2736eddc4c8349911eb1d1a691 Signed-off-by: Guillaume Denneulin Signed-off-by: Mattijs Korpershoek Reviewed-on: https://android.intel.com/215426 Reviewed-by: De Chivre, Renaud Reviewed-by: Benavoli, Patrick Reviewed-by: Rocard, KevinX Tested-by: Rocard, KevinX --- parameter/ParameterMgr.cpp | 6 ++++++ parameter/ParameterMgrPlatformConnector.cpp | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'parameter') diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 4b8bdf6..d112461 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -454,6 +454,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(); 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; -- cgit v1.1 From d2d73c11c90ddde1730506566c20bd3d315305ef Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 3 Jul 2014 21:40:17 +0200 Subject: Adding a missing const in a get type method BZ: 208504 CParameterAccessContext::outRawFormatIsHex() was missing the const modifier. Change-Id: I3120a231d2dff8f4274b95cd2d3c8ff0817bf8ac Signed-off-by: Patrick Benavoli --- parameter/ParameterAccessContext.cpp | 2 +- parameter/ParameterAccessContext.h | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'parameter') 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); -- cgit v1.1 From 86e19e3063dd2558802ba2fe51d140d25f931e82 Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 3 Jul 2014 21:56:18 +0200 Subject: Removed spurious execution mode on source files BZ: 208504 Some source files were mistakenly assigned the executable flag. Change-Id: Iad85123c331d2599126ed46f070fe10614f7c360 Signed-off-by: Patrick Benavoli --- parameter/IntegerParameterType.cpp | 0 parameter/IntegerParameterType.h | 0 parameter/ParameterType.cpp | 0 parameter/ParameterType.h | 0 parameter/SubsystemObject.cpp | 0 parameter/SubsystemObject.h | 0 parameter/TypeElement.cpp | 0 parameter/TypeElement.h | 0 8 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 parameter/IntegerParameterType.cpp mode change 100755 => 100644 parameter/IntegerParameterType.h mode change 100755 => 100644 parameter/ParameterType.cpp mode change 100755 => 100644 parameter/ParameterType.h mode change 100755 => 100644 parameter/SubsystemObject.cpp mode change 100755 => 100644 parameter/SubsystemObject.h mode change 100755 => 100644 parameter/TypeElement.cpp mode change 100755 => 100644 parameter/TypeElement.h (limited to 'parameter') diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp old mode 100755 new mode 100644 diff --git a/parameter/IntegerParameterType.h b/parameter/IntegerParameterType.h old mode 100755 new mode 100644 diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp old mode 100755 new mode 100644 diff --git a/parameter/ParameterType.h b/parameter/ParameterType.h old mode 100755 new mode 100644 diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp old mode 100755 new mode 100644 diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h old mode 100755 new mode 100644 diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp old mode 100755 new mode 100644 diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h old mode 100755 new mode 100644 -- cgit v1.1 From 822d0a70b3a2a4f862d01fa6c0194a406708bf63 Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 3 Jul 2014 22:03:23 +0200 Subject: Coding style correction BZ: 208504 Concerns the handle to remote processor library. In PFW coding style, the variables are named like in english language: The actual nature of the object needs to lie at the end of the name. Change-Id: If41218c3456d07c81a953182488c6ae71e31b6d8 Signed-off-by: Patrick Benavoli --- parameter/ParameterMgr.cpp | 13 +++++++------ parameter/ParameterMgr.h | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'parameter') diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index d112461..47abd0d 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -300,7 +300,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 +358,9 @@ CParameterMgr::~CParameterMgr() delete _pElementLibrarySet; // Close remote processor library - if (_handleLibRemoteProcessor != NULL) { - dlclose(_handleLibRemoteProcessor); + if (_pvLibRemoteProcessorHandle) { + + dlclose(_pvLibRemoteProcessorHandle); } // Tuning Mode Mutex @@ -2459,9 +2460,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(); @@ -2477,7 +2478,7 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) return false; } - CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_handleLibRemoteProcessor, "createRemoteProcessorServer"); + CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_pvLibRemoteProcessorHandle, "createRemoteProcessorServer"); if (!pfnCreateRemoteProcessorServer) { diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index c6a2fd5..7edace1 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -597,8 +597,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; -- cgit v1.1 From 79694d5d0a632ed4ca04ea42f19fb09c3fba0cdb Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 3 Jul 2014 22:30:44 +0200 Subject: Delete subsystem instances *before* plugin unload BZ: 208504 Before this patch there was a crash in CElement destructor in Ubuntu upon destuction of parameter framework instance. The crash was caused by the attempt to call unmapped code: The subsystem plugin libraries were getting unloaded before the execution of the subsystem destructors. Note: In Android the issue is not seen since library unload is not implemented. This patch ensures SystemClass destructor destroys the subsystems explicitely unloading the plugins. Change-Id: I19dad262b384bdbd63c7c319a41a5d547d0e75e9 Signed-off-by: Patrick Benavoli --- parameter/SystemClass.cpp | 17 +++++++++++------ parameter/SystemClass.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'parameter') diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index effc573..6169223 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::const_iterator it; + + for (it = _subsystemLibraryHandleList.begin(); it != _subsystemLibraryHandleList.end(); ++it) { + + dlclose(*it); } } @@ -238,7 +243,7 @@ bool CSystemClass::loadPlugins(list& lstrPluginFiles, list& lstr } // Store libraries handles - _subsystemLibraries.push_back(lib_handle); + _subsystemLibraryHandleList.push_back(lib_handle); // Get plugin symbol string strPluginSymbol = getPluginSymbol(strPluginFileName); diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h index 3ffbf25..b5bce45 100644 --- a/parameter/SystemClass.h +++ b/parameter/SystemClass.h @@ -111,6 +111,6 @@ private: // Subsystem factory CSubsystemLibrary* _pSubsystemLibrary; - std::list _subsystemLibraries; /**< Contains the list of all open plugin libs. */ + std::list _subsystemLibraryHandleList; /**< Contains the list of all open plugin libs. */ }; -- cgit v1.1 From 0548523ab6bbca766dcce4be97a0c50efd529d90 Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Tue, 8 Jul 2014 14:09:09 +0200 Subject: Adding XML format to Criteria export tuning I/F BZ: 209937 The "listCriteria" command returns the list of criteria in a human readable way. However, external tools that require to know this list of criteria have trouble parsing this output. An XML output would solve the issue. Changed "listCriteria" command to accept "XML" as first and only argument. In the end, listCriteria command accepts the 3 following forms: - listCriteria => will list the criteria states and type content in a human readable format - listCriteria csv|CSV => will list the criteria states and type content in a CSV format - listCriteria xml|XML => will list the criteria states and type content in an XML format Removed python binding accordingly. Change-Id: Ib060ec0a5d1ff87ba6c25caf4e0d5839a7927715 Signed-off-by: Patrick Benavoli Signed-off-by: Sebastien Gonzalve --- parameter/ParameterMgr.cpp | 70 +++++++++++++++++++-------- parameter/ParameterMgr.h | 14 +++--- parameter/ParameterMgrFullConnector.cpp | 5 -- parameter/SelectionCriterion.cpp | 13 +++++ parameter/SelectionCriterion.h | 9 ++++ parameter/SelectionCriterionType.cpp | 23 +++++++++ parameter/SelectionCriterionType.h | 9 ++++ parameter/include/ParameterMgrFullConnector.h | 10 ---- 8 files changed, 111 insertions(+), 42 deletions(-) (limited to 'parameter') diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 47abd0d..a1f2087 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -87,8 +87,11 @@ #include "XmlStringDocSource.h" #include "XmlMemoryDocSink.h" #include "XmlMemoryDocSource.h" +#include "SelectionCriteriaDefinition.h" #include "Utility.h" #include +#include +#include #include #define base CElement @@ -160,7 +163,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, @@ -1083,28 +1086,52 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess /// Criteria CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - (void)remoteCommand; + if (remoteCommand.getArgumentCount() > 1) { - bool humanReadable = true; + return CCommandHandler::EShowUsage; + } + + 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 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", false, 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 lstrResult; + getSelectionCriteria()->listSelectionCriteria(lstrResult, true, bHumanReadable); + + // Concatenate the criterion list as the command result + CUtility::asString(lstrResult, strResult); + + return CCommandHandler::ESucceeded; + } } /// Domains @@ -1646,7 +1673,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(), false, strResult)) { return CCommandHandler::EFailed; } @@ -2581,28 +2611,26 @@ 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, bool bValidateWithSchema, 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, + bValidateWithSchema); // 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 7edace1..03a1e92 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,16 @@ 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[in] bValidateWithSchema true if source XML document requires validation against schema + * @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, bool bValidateWithSchema, std::string& strResult) const; // CElement virtual std::string getKind() const; 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/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/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&); -- cgit v1.1 From 8ff3e0fed53fb64b27b01ab69acee60fbf4e4013 Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 24 Jul 2014 18:46:25 +0200 Subject: Cleaned up XML export feature BZ: 209937 This patch solves 1 issue regarding XML export feature: - ParameterMgr.cpp::exportElementToXMLString(): This method was receiving a useless bValidateWithSchema argument. Indeed, elements in memory are necessarily valid (unlike documents coming from external sources). Change-Id: I55bf84c8ff53c37c9fc55e60f7f64e8776a43dc7 Signed-off-by: Patrick Benavoli --- parameter/ParameterMgr.cpp | 12 +++++++----- parameter/ParameterMgr.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'parameter') diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index a1f2087..e11b1ad 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -1112,7 +1112,8 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommman // Get Root element where to export from const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition = getConstSelectionCriteria()->getSelectionCriteriaDefinition(); - if (!exportElementToXMLString(pSelectionCriteriaDefinition, "SelectionCriteria", false, strResult)) { + if (!exportElementToXMLString(pSelectionCriteriaDefinition, "SelectionCriteria", + strResult)) { return CCommandHandler::EFailed; } @@ -1676,7 +1677,7 @@ CParameterMgr::CCommandHandler::CommandStatus // Get Root element where to export from const CSystemClass* pSystemClass = getSystemClass(); - if (!exportElementToXMLString(pSystemClass, pSystemClass->getKind(), false, strResult)) { + if (!exportElementToXMLString(pSystemClass, pSystemClass->getKind(), strResult)) { return CCommandHandler::EFailed; } @@ -2612,15 +2613,16 @@ void CParameterMgr::doApplyConfigurations(bool bForce) } // Export to XML string -bool CParameterMgr::exportElementToXMLString(const IXmlSource *pXmlSource, const string& strRootElementType, bool bValidateWithSchema, string& strResult) const +bool CParameterMgr::exportElementToXMLString(const IXmlSource* pXmlSource, + const string& strRootElementType, + string& strResult) const { string strError; CXmlSerializingContext xmlSerializingContext(strError); // Use a doc source by loading data from instantiated Configurable Domains - CXmlMemoryDocSource memorySource(pXmlSource, strRootElementType, - bValidateWithSchema); + CXmlMemoryDocSource memorySource(pXmlSource, strRootElementType, false); // Use a doc sink that write the doc data in a string CXmlStringDocSink stringSink(strResult); diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 03a1e92..6a3ecb8 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -344,12 +344,13 @@ public: * * @param[in] pXmlSource The source element to export * @param[in] strRootElementType The XML root element name of the exported instance document - * @param[in] bValidateWithSchema true if source XML document requires validation against schema * @param[out] strResult contains the xml description or the error description in case false is returned * * @return true for success, false if any error occurs during the creation of the xml description (validation or encoding) */ - bool exportElementToXMLString(const IXmlSource* pXmlSource, const std::string& strRootElementType, bool bValidateWithSchema, std::string& strResult) const; + bool exportElementToXMLString(const IXmlSource* pXmlSource, + const std::string& strRootElementType, + std::string& strResult) const; // CElement virtual std::string getKind() const; -- cgit v1.1 From a1fdb2965956d3cbc62e6f8b29405bdeef79dca3 Mon Sep 17 00:00:00 2001 From: Piotr Diop Date: Fri, 16 Jan 2015 17:52:45 +0100 Subject: Create a Logarithm Adaptation parameter type Some parameters need to be converted to logarithm. This can be the case for volumes that come from HAL as mere decimal values. This patch adds the LogarithmAdaptationParameter type. Change-Id: Ic64232816a82c56a6ddffa5fdccda356eb4ec9c7 Tracked-On: https://jira01.devtools.intel.com/browse/IMINAN-16954 Signed-off-by: Piotr Diop Reviewed-on: https://android.intel.com:443/320371 --- parameter/Android.mk | 1 + parameter/CMakeLists.txt | 1 + parameter/LinearParameterAdaptation.cpp | 7 ++- parameter/LinearParameterAdaptation.h | 3 +- parameter/LogarithmicParameterAdaptation.cpp | 89 ++++++++++++++++++++++++++++ parameter/LogarithmicParameterAdaptation.h | 71 ++++++++++++++++++++++ parameter/ParameterMgr.cpp | 4 +- 7 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 parameter/LogarithmicParameterAdaptation.cpp create mode 100644 parameter/LogarithmicParameterAdaptation.h (limited to 'parameter') diff --git a/parameter/Android.mk b/parameter/Android.mk index 8592c52..6f1f61d 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 \ 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/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 + +#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/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index e11b1ad..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 #include "ParameterHandle.h" #include "LinearParameterAdaptation.h" +#include "LogarithmicParameterAdaptation.h" #include "EnumValuePair.h" #include "Subsystem.h" #include "XmlFileDocSink.h" @@ -2447,6 +2448,7 @@ void CParameterMgr::feedElementLibraries() pParameterCreationLibrary->addElementBuilder("BooleanParameter", new TNamedElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("IntegerParameter", new TNamedElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("LinearAdaptation", new TElementBuilderTemplate()); + pParameterCreationLibrary->addElementBuilder("LogarithmicAdaptation", new TElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("EnumParameter", new TNamedElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("ValuePair", new TElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("FixedPointParameter", new TNamedElementBuilderTemplate()); -- cgit v1.1 From 3eeafab805b5d82b168361f05b9ec372d41a0614 Mon Sep 17 00:00:00 2001 From: Philippe Afonso Date: Mon, 9 Feb 2015 17:53:47 +0100 Subject: Add libremote-processor as dependency libremote-processor headers are needed by the parameter core. This patch adds explicitily the dependency to this module. Change-Id: I7a223a0abd35f9524a047ca92e1029c5cef38e38 Tracked-On: https://jira01.devtools.intel.com/browse/IMINAN-19676 Signed-off-by: Philippe Afonso --- parameter/Android.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'parameter') diff --git a/parameter/Android.mk b/parameter/Android.mk index 6f1f61d..90e33f0 100644 --- a/parameter/Android.mk +++ b/parameter/Android.mk @@ -156,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) -- cgit v1.1 From 36423a49fdde5755faea5914e554b64363034b0c Mon Sep 17 00:00:00 2001 From: David Wagner Date: Wed, 4 Feb 2015 14:47:14 +0100 Subject: Fix SystemClass duplicate 'Name' attribute in xml export When refactoring Element::toXml, we forgot to make the necessary adaptation in SystemClass::toXml. The latter does not need to set the Name attribute anymore because this is taken care of by the base toXml method. SystemClass::toXml now only calls the base and can therefore be completely removed. Change-Id: Ibd12feaac2c101dcc22e8716e332cb02f03ba99a Tracked-On: https://jira01.devtools.intel.com/browse/IMINAN-19676 Signed-off-by: David Wagner --- parameter/SystemClass.cpp | 9 --------- parameter/SystemClass.h | 3 --- 2 files changed, 12 deletions(-) (limited to 'parameter') diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index 6169223..334772a 100644 --- a/parameter/SystemClass.cpp +++ b/parameter/SystemClass.cpp @@ -314,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 b5bce45..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&); -- cgit v1.1