diff options
author | Georges-Henri Baron <georges-henrix.baron@intel.com> | 2012-06-28 12:05:09 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:03:13 +0100 |
commit | 326a31df0dd401283de6170ed09bcf605f61ef7d (patch) | |
tree | 8b41618325db75380a53df102e2f0e62451a3b2b /parameter/ParameterMgr.cpp | |
parent | dc32d63f2ed740af1bfc0b3f8fd2337cba46d895 (diff) | |
download | external_parameter-framework-326a31df0dd401283de6170ed09bcf605f61ef7d.zip external_parameter-framework-326a31df0dd401283de6170ed09bcf605f61ef7d.tar.gz external_parameter-framework-326a31df0dd401283de6170ed09bcf605f61ef7d.tar.bz2 |
PFW: Add two commands to print xml settings and structure
BZ: 44910
Creates two commands that can be called through the command
line of the parameter-framework. First command getDomainXML
returns a string containing the xml structure of the
domains, configurations and settings. Second command
getSystemClassXML returns a string containing the xml
structure of all the instantiated parameter with their
attributes.
Change-Id: I9a35333802049a2177b8fc416754fdb67e6efff0
Signed-off-by: Georges-Henri Baron <georges-henrix.baron@intel.com>
Reviewed-on: http://android.intel.com:8080/55155
Reviewed-by: Rocard, KevinX <kevinx.rocard@intel.com>
Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com>
Tested-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter/ParameterMgr.cpp')
-rw-r--r-- | parameter/ParameterMgr.cpp | 147 |
1 files changed, 104 insertions, 43 deletions
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index ddce610..9f1d160 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -23,7 +23,6 @@ * UPDATED: 2011-07-27 */ #include "ParameterMgr.h" -#include "XmlParser.h" #include "XmlParameterSerializingContext.h" #include "XmlElementSerializingContext.h" #include "SystemClass.h" @@ -54,7 +53,6 @@ #include "ConfigurableDomains.h" #include "ConfigurableDomain.h" #include "DomainConfiguration.h" -#include "XmlComposer.h" #include "XmlDomainSerializingContext.h" #include "BitParameterBlockType.h" #include "BitParameterType.h" @@ -74,6 +72,11 @@ #include "ParameterHandle.h" #include "LinearParameterAdaptation.h" #include "EnumValuePair.h" +#include "XmlFileDocSink.h" +#include "XmlFileDocSource.h" +#include "XmlStringDocSink.h" +#include "XmlMemoryDocSink.h" +#include "XmlMemoryDocSource.h" #define base CElement @@ -166,7 +169,10 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" }, { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" }, { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" }, - { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" } + { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }, + { "getDomainsXML", &CParameterMgr::getDomainsXMLCommmandProcess, 0 ,"", "Print domains including settings as XML" }, + /// Structure Export + { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,"", "Print parameter structure as XML" } }; // Remote command parsers array Size const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]); @@ -510,43 +516,20 @@ bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingCo // Get Schema file associated to root element string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd"; - // Parse Structure XML file - CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext); - - if (!parser.open()) { - - return false; - } - - // Check Root element name attribute (if any) - string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName); - - if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) { - - elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath); - elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName()); - - return false; - } + CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName); // Start clean pRootElement->clean(); - // Parse - if (!parser.parse(pRootElement)) { + CXmlMemoryDocSink memorySink(pRootElement); - // Cleanup + if (!memorySink.process(fileDocSource, elementSerializingContext)) { + //Cleanup pRootElement->clean(); return false; } - // Close parser - if (!parser.close()) { - - return false; - } - return true; } @@ -1274,6 +1257,32 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommm return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } +/// GUI commands + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getDomainsXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + if (!getDomainsXMLString(strResult, true)) { + + return CCommandHandler::EFailed; + } + // Succeeded + return CCommandHandler::ESucceeded; +} + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSystemClassXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + if (!getSystemClassXMLString(strResult)) { + + return CCommandHandler::EFailed; + } + // Succeeded + return CCommandHandler::ESucceeded; +} + // User set/get parameters bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bSet, string& strError) { @@ -1646,21 +1655,13 @@ bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettin // Output raw format xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); - // Instantiate composer - CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext); - - // Open composer - if (!xmlComposer.open()) { + // Use a doc source by loading data from instantiated Configurable Domains + CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion()); - return false; - } - - // Compose - xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion()); - - // Close composer - if (!xmlComposer.close()) { + // Use a doc sink to write the doc data in a file + CXmlFileDocSink fileSink(strFileName); + if (!fileSink.process(memorySource, xmlDomainSerializingContext)) { return false; } @@ -1891,3 +1892,63 @@ const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const { return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); } + +/// GUI commands functions + +bool CParameterMgr::getDomainsXMLString(string& strResult, bool bWithSettings) +{ + + // Root element + const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); + + // Get Schema file associated to root element + string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd"; + + string strError; + + // Context + CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); + + // Value space + xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); + + // Output raw format + xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); + + // Use a doc source by loading data from instantiated Configurable Domains + CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion()); + + // Use a doc sink the write the doc data in a string + CXmlStringDocSink stringSink(strResult); + + if (!stringSink.process(memorySource, xmlDomainSerializingContext)) { + strResult = strError; + + return false; + } + + return true; +} + +bool CParameterMgr::getSystemClassXMLString(string& strResult) +{ + // 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()); + + // Use a doc sink that write the doc data in a string + CXmlStringDocSink stringSink(strResult); + + if (!stringSink.process(memorySource, xmlSerializingContext)) { + strResult = strError; + return false; + } + + return true; +} |