Kevin Rocard | 93250d1 | 2012-07-19 17:48:30 +0200 | [diff] [blame] | 1 | /* |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2 | * INTEL CONFIDENTIAL |
| 3 | * Copyright © 2011 Intel |
| 4 | * Corporation All Rights Reserved. |
| 5 | * |
| 6 | * The source code contained or described herein and all documents related to |
| 7 | * the source code ("Material") are owned by Intel Corporation or its suppliers |
| 8 | * or licensors. Title to the Material remains with Intel Corporation or its |
| 9 | * suppliers and licensors. The Material contains trade secrets and proprietary |
| 10 | * and confidential information of Intel or its suppliers and licensors. The |
| 11 | * Material is protected by worldwide copyright and trade secret laws and |
| 12 | * treaty provisions. No part of the Material may be used, copied, reproduced, |
| 13 | * modified, published, uploaded, posted, transmitted, distributed, or |
| 14 | * disclosed in any way without Intel’s prior express written permission. |
| 15 | * |
| 16 | * No license under any patent, copyright, trade secret or other intellectual |
| 17 | * property right is granted to or conferred upon you by disclosure or delivery |
| 18 | * of the Materials, either expressly, by implication, inducement, estoppel or |
| 19 | * otherwise. Any license under such intellectual property rights must be |
| 20 | * express and approved by Intel in writing. |
| 21 | * |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 22 | * CREATED: 2011-06-01 |
| 23 | * UPDATED: 2011-07-27 |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 24 | */ |
| 25 | #include "ParameterMgr.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 26 | #include "XmlParameterSerializingContext.h" |
| 27 | #include "XmlElementSerializingContext.h" |
| 28 | #include "SystemClass.h" |
| 29 | #include "ElementLibrarySet.h" |
| 30 | #include "SubsystemLibrary.h" |
| 31 | #include "NamedElementBuilderTemplate.h" |
| 32 | #include "KindElementBuilderTemplate.h" |
| 33 | #include "ElementBuilderTemplate.h" |
| 34 | #include "SelectionCriterionType.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 35 | #include "SubsystemElementBuilder.h" |
| 36 | #include "SelectionCriteria.h" |
| 37 | #include "ComponentType.h" |
| 38 | #include "ComponentInstance.h" |
| 39 | #include "ParameterBlockType.h" |
| 40 | #include "BooleanParameterType.h" |
| 41 | #include "IntegerParameterType.h" |
| 42 | #include "FixedPointParameterType.h" |
| 43 | #include "ParameterBlackboard.h" |
| 44 | #include "Parameter.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 45 | #include "ParameterBlackboard.h" |
| 46 | #include "ParameterAccessContext.h" |
| 47 | #include "XmlFileIncluderElement.h" |
| 48 | #include "ParameterFrameworkConfiguration.h" |
| 49 | #include "FrameworkConfigurationGroup.h" |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 50 | #include "PluginLocation.h" |
| 51 | #include "SubsystemPlugins.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 52 | #include "FrameworkConfigurationLocation.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 53 | #include "ConfigurableDomains.h" |
| 54 | #include "ConfigurableDomain.h" |
| 55 | #include "DomainConfiguration.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 56 | #include "XmlDomainSerializingContext.h" |
| 57 | #include "BitParameterBlockType.h" |
| 58 | #include "BitParameterType.h" |
Patrick Benavoli | 1352ae5 | 2011-10-21 16:48:04 +0200 | [diff] [blame] | 59 | #include "StringParameterType.h" |
Patrick Benavoli | 9fc3c0d | 2011-10-27 14:27:27 +0200 | [diff] [blame] | 60 | #include "EnumParameterType.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 61 | #include "RemoteProcessorServerInterface.h" |
| 62 | #include "ElementLocator.h" |
| 63 | #include "AutoLog.h" |
| 64 | #include "CompoundRule.h" |
| 65 | #include "SelectionCriterionRule.h" |
| 66 | #include "SimulatedBackSynchronizer.h" |
| 67 | #include "HardwareBackSynchronizer.h" |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 68 | #include "AutoLock.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 69 | #include <strings.h> |
| 70 | #include <dlfcn.h> |
| 71 | #include <assert.h> |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 72 | #include "ParameterHandle.h" |
Patrick Benavoli | ee65e6d | 2011-11-20 18:52:24 +0100 | [diff] [blame] | 73 | #include "LinearParameterAdaptation.h" |
Patrick Benavoli | 68808c6 | 2012-02-02 17:12:41 +0100 | [diff] [blame] | 74 | #include "EnumValuePair.h" |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 75 | #include "XmlFileDocSink.h" |
| 76 | #include "XmlFileDocSource.h" |
| 77 | #include "XmlStringDocSink.h" |
| 78 | #include "XmlMemoryDocSink.h" |
| 79 | #include "XmlMemoryDocSource.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 80 | |
| 81 | #define base CElement |
| 82 | |
| 83 | // Used for remote processor server creation |
| 84 | typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler); |
| 85 | |
| 86 | // Global configuration file name (fixed) |
| 87 | const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml"; |
| 88 | const char* gacSystemSchemasSubFolder = "Schemas"; |
| 89 | |
| 90 | // Config File System looks normally like this: |
| 91 | // --------------------------------------------- |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 92 | //├── <ParameterFrameworkConfiguration>.xml |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 93 | //├── Schemas |
| 94 | //│ └── *.xsd |
| 95 | //├── Settings |
| 96 | //│ └── <SystemClassName folder>* |
| 97 | //│ ├── <ConfigurableDomains>.xml |
| 98 | //│ └── <Settings>.bin? |
| 99 | //└── Structure |
| 100 | // └── <SystemClassName folder>* |
| 101 | // ├── <SystemClassName>Class.xml |
| 102 | // └── <Subsystem>.xml* |
| 103 | // -------------------------------------------- |
| 104 | |
| 105 | |
| 106 | // Remote command parser array |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 107 | const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 108 | /// Version |
| 109 | { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 110 | /// Status |
| 111 | { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" }, |
| 112 | /// Tuning Mode |
| 113 | { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" }, |
| 114 | { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" }, |
| 115 | /// Value Space |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 116 | { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 117 | { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" }, |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 118 | /// Output Raw Format |
| 119 | { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" }, |
| 120 | { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 121 | /// Sync |
| 122 | { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" }, |
| 123 | { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" }, |
| 124 | { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" }, |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 125 | /// Criteria |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 126 | { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 127 | /// Domains |
| 128 | { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" }, |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 129 | { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, "", "Show all domains and configurations, including applicability conditions" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 130 | { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" }, |
| 131 | { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" }, |
Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 132 | { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0, "", "Delete all configurable domains" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 133 | { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" }, |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 134 | { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" }, |
| 135 | { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 136 | { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" }, |
| 137 | { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" }, |
| 138 | { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" }, |
| 139 | { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" }, |
| 140 | /// Configurations |
| 141 | { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" }, |
| 142 | { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" }, |
| 143 | { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" }, |
| 144 | { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" }, |
| 145 | { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" }, |
| 146 | { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" }, |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 147 | { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3, "<domain> <configuration> <elem path list>", "Set element application order for configuration" }, |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 148 | { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" }, |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 149 | { "setRule", &CParameterMgr::setRuleCommmandProcess, 3, "<domain> <configuration> <rule>", "Set configuration application rule" }, |
| 150 | { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2, "<domain> <configuration>", "Clear configuration application rule" }, |
| 151 | { "getRule", &CParameterMgr::getRuleCommmandProcess, 2, "<domain> <configuration>", "Get configuration application rule" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 152 | /// Elements/Parameters |
| 153 | { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" }, |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 154 | { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 155 | { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" }, |
| 156 | { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" }, |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 157 | { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" }, |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 158 | { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" }, |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 159 | { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" }, |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 160 | { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 161 | { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" }, |
| 162 | /// Browse |
| 163 | { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" }, |
| 164 | { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" }, |
| 165 | { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" }, |
| 166 | /// Settings Import/Export |
| 167 | { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" }, |
| 168 | { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" }, |
| 169 | { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" }, |
| 170 | { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" }, |
| 171 | { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" }, |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 172 | { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }, |
| 173 | { "getDomainsXML", &CParameterMgr::getDomainsXMLCommmandProcess, 0 ,"", "Print domains including settings as XML" }, |
| 174 | /// Structure Export |
| 175 | { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,"", "Print parameter structure as XML" } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 176 | }; |
| 177 | // Remote command parsers array Size |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 178 | const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 179 | |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 180 | CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) : |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 181 | _bTuningModeIsOn(false), |
| 182 | _bValueSpaceIsRaw(false), |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 183 | _bOutputRawFormatIsHex(false), |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 184 | _bAutoSyncOn(true), |
| 185 | _pMainParameterBlackboard(new CParameterBlackboard), |
| 186 | _pElementLibrarySet(new CElementLibrarySet), |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 187 | _strXmlConfigurationFilePath(strConfigurationFilePath), |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 188 | _pSubsystemPlugins(NULL), |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 189 | _uiStructureChecksum(0), |
| 190 | _pRemoteProcessorServer(NULL), |
| 191 | _uiMaxCommandUsageLength(0), |
| 192 | _pLogger(NULL), |
| 193 | _uiLogDepth(0) |
| 194 | { |
| 195 | // Tuning Mode Mutex |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 196 | bzero(&_blackboardMutex, sizeof(_blackboardMutex)); |
| 197 | pthread_mutex_init(&_blackboardMutex, NULL); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 198 | |
| 199 | // Deal with children |
| 200 | addChild(new CParameterFrameworkConfiguration); |
| 201 | addChild(new CSelectionCriteria); |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 202 | addChild(new CSystemClass); |
| 203 | addChild(new CConfigurableDomains); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 204 | |
| 205 | // Feed element library |
| 206 | feedElementLibraries(); |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 207 | |
| 208 | _pCommandHandler = new CCommandHandler(this); |
| 209 | |
| 210 | // Add command parsers |
| 211 | uint32_t uiRemoteCommandParserItem; |
| 212 | |
| 213 | for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { |
| 214 | |
| 215 | const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; |
| 216 | |
| 217 | _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName, |
| 218 | pRemoteCommandParserItem->_pfnParser, |
| 219 | pRemoteCommandParserItem->_uiMinArgumentCount, |
| 220 | pRemoteCommandParserItem->_pcHelp, |
| 221 | pRemoteCommandParserItem->_pcDescription); |
| 222 | } |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 223 | |
| 224 | // Configuration file folder |
| 225 | uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1); |
| 226 | |
| 227 | assert(uiSlashPos != (uint32_t)-1); |
| 228 | |
| 229 | _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos); |
| 230 | |
| 231 | // Schema absolute folder location |
| 232 | _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | CParameterMgr::~CParameterMgr() |
| 236 | { |
| 237 | // Children |
| 238 | delete _pRemoteProcessorServer; |
Frederic Boisnard | 3124230 | 2012-04-26 17:07:34 +0200 | [diff] [blame] | 239 | delete _pCommandHandler; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 240 | delete _pMainParameterBlackboard; |
| 241 | delete _pElementLibrarySet; |
| 242 | |
| 243 | // Tuning Mode Mutex |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 244 | pthread_mutex_destroy(&_blackboardMutex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | string CParameterMgr::getKind() const |
| 248 | { |
| 249 | return "ParameterMgr"; |
| 250 | } |
| 251 | |
| 252 | // Logging |
| 253 | void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger) |
| 254 | { |
| 255 | _pLogger = pLogger; |
| 256 | } |
| 257 | |
| 258 | // Logging |
| 259 | void CParameterMgr::doLog(const string& strLog) const |
| 260 | { |
| 261 | if (_pLogger) { |
| 262 | |
| 263 | // Nest |
| 264 | string strIndent; |
| 265 | |
| 266 | // Level |
| 267 | uint32_t uiNbIndents = _uiLogDepth; |
| 268 | |
| 269 | while (uiNbIndents--) { |
| 270 | |
| 271 | strIndent += " "; |
| 272 | } |
| 273 | |
| 274 | // Log |
| 275 | _pLogger->log(strIndent + strLog); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | void CParameterMgr::nestLog() const |
| 280 | { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 281 | _uiLogDepth++; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | void CParameterMgr::unnestLog() const |
| 285 | { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 286 | _uiLogDepth--; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 287 | } |
| 288 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 289 | // Version |
| 290 | string CParameterMgr::getVersion() const |
| 291 | { |
| 292 | string strVersion; |
| 293 | |
| 294 | // Major |
| 295 | strVersion = toString(guiEditionMajor) + "."; |
| 296 | // Minor |
| 297 | strVersion += toString(guiEditionMinor) + "."; |
| 298 | // Revision |
| 299 | strVersion += toString(guiRevision); |
| 300 | |
| 301 | return strVersion; |
| 302 | } |
| 303 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 304 | bool CParameterMgr::load(string& strError) |
| 305 | { |
| 306 | CAutoLog autoLog(this, "Loading"); |
| 307 | |
| 308 | // Load Framework configuration |
| 309 | if (!loadFrameworkConfiguration(strError)) { |
| 310 | |
| 311 | return false; |
| 312 | } |
| 313 | |
| 314 | // Load subsystems |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 315 | if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 316 | |
| 317 | return false; |
| 318 | } |
| 319 | |
| 320 | // Load structure |
| 321 | if (!loadStructure(strError)) { |
| 322 | |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | // Load settings |
| 327 | if (!loadSettings(strError)) { |
| 328 | |
| 329 | return false; |
| 330 | } |
| 331 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 332 | // Back synchronization for areas in parameter blackboard not covered by any domain |
| 333 | CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 334 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 335 | log("Main blackboard back synchronization"); |
| 336 | |
| 337 | // Back-synchronize |
| 338 | if (!pBackSynchronizer->sync()) { |
| 339 | // Get rid of back synchronizer |
| 340 | delete pBackSynchronizer; |
| 341 | |
| 342 | strError = "Main blackboard back synchronization failed: " + strError; |
| 343 | |
| 344 | return false; |
| 345 | } |
| 346 | // Get rif of back synchronizer |
| 347 | delete pBackSynchronizer; |
| 348 | |
| 349 | // We're done loading the settings and back synchronizing |
| 350 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 351 | |
| 352 | // We need to ensure all domains are valid |
| 353 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 354 | |
| 355 | // Ensure application of currently selected configurations |
| 356 | // Force-apply configurations |
| 357 | if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 358 | |
| 359 | return false; |
| 360 | } |
| 361 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 362 | // Start remote processor server if appropriate |
| 363 | return handleRemoteProcessingInterface(strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | bool CParameterMgr::loadFrameworkConfiguration(string& strError) |
| 367 | { |
| 368 | CAutoLog autoLog(this, "Loading framework configuration"); |
| 369 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 370 | // Parse Structure XML file |
| 371 | CXmlElementSerializingContext elementSerializingContext(strError); |
| 372 | |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 373 | if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 374 | |
| 375 | return false; |
| 376 | } |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 377 | // Set class name to system class and configurable domains |
| 378 | getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName()); |
| 379 | getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName()); |
| 380 | |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 381 | // Get subsystem plugins elements |
| 382 | _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 383 | |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 384 | if (!_pSubsystemPlugins) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 385 | |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 386 | strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element"; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 387 | |
| 388 | return false; |
| 389 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 390 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 391 | // Log tuning availability |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 392 | log("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 393 | |
| 394 | return true; |
| 395 | } |
| 396 | |
| 397 | bool CParameterMgr::loadStructure(string& strError) |
| 398 | { |
| 399 | // Retrieve system to load structure to |
| 400 | CSystemClass* pSystemClass = getSystemClass(); |
| 401 | |
| 402 | CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure"); |
| 403 | |
| 404 | // Get structure description element |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 405 | const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 406 | |
| 407 | if (!pStructureDescriptionFileLocation) { |
| 408 | |
| 409 | strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName(); |
| 410 | |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | // Get Xml structure folder |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 415 | string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 416 | |
| 417 | // Get Xml structure file name |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 418 | string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 419 | |
| 420 | // Parse Structure XML file |
| 421 | CXmlParameterSerializingContext parameterBuildContext(strError); |
| 422 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 423 | log("Importing system structure from file %s", strXmlStructureFilePath.c_str()); |
| 424 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 425 | if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { |
| 426 | |
| 427 | return false; |
| 428 | } |
| 429 | |
| 430 | // Initialize offsets |
| 431 | pSystemClass->setOffset(0); |
| 432 | |
| 433 | // Initialize main blackboard's size |
| 434 | _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint()); |
| 435 | |
| 436 | return true; |
| 437 | } |
| 438 | |
| 439 | bool CParameterMgr::loadSettings(string& strError) |
| 440 | { |
| 441 | CAutoLog autoLog(this, "Loading settings"); |
| 442 | |
| 443 | // Get settings configuration element |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 444 | const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 445 | |
| 446 | if (!pParameterConfigurationGroup) { |
| 447 | |
| 448 | // No settings to load |
| 449 | |
| 450 | return true; |
| 451 | } |
| 452 | // Get binary settings file location |
| 453 | const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation")); |
| 454 | |
| 455 | string strXmlBinarySettingsFilePath; |
| 456 | |
| 457 | if (pBinarySettingsFileLocation) { |
| 458 | |
| 459 | // Get Xml binary settings file name |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 460 | strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | // Get configurable domains element |
| 464 | const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation")); |
| 465 | |
| 466 | if (!pConfigurableDomainsFileLocation) { |
| 467 | |
| 468 | strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); |
| 469 | |
| 470 | return false; |
| 471 | } |
| 472 | // Get destination root element |
| 473 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 474 | |
| 475 | // Get Xml configuration domains file name |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 476 | string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 477 | |
| 478 | // Get Xml configuration domains folder |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 479 | string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 480 | |
| 481 | // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary) |
| 482 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation); |
| 483 | |
| 484 | // Selection criteria definition for rule creation |
| 485 | xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| 486 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 487 | // Auto validation of configurations if no binary settings provided |
| 488 | xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation); |
| 489 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 490 | log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with"); |
| 491 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 492 | // Do parse |
| 493 | if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { |
| 494 | |
| 495 | return false; |
| 496 | } |
| 497 | // We have loaded the whole system structure, compute checksum |
| 498 | const CSystemClass* pSystemClass = getConstSystemClass(); |
| 499 | _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum(); |
| 500 | |
| 501 | // Load binary settings if any provided |
| 502 | if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { |
| 503 | |
| 504 | return false; |
| 505 | } |
| 506 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 507 | return true; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | // XML parsing |
| 511 | bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName) |
| 512 | { |
| 513 | // Init serializing context |
| 514 | elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation); |
| 515 | |
| 516 | // Get Schema file associated to root element |
| 517 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd"; |
| 518 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 519 | CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 520 | |
| 521 | // Start clean |
| 522 | pRootElement->clean(); |
| 523 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 524 | CXmlMemoryDocSink memorySink(pRootElement); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 525 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 526 | if (!memorySink.process(fileDocSource, elementSerializingContext)) { |
| 527 | //Cleanup |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 528 | pRootElement->clean(); |
| 529 | |
| 530 | return false; |
| 531 | } |
| 532 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 533 | return true; |
| 534 | } |
| 535 | |
| 536 | // Init |
| 537 | bool CParameterMgr::init(string& strError) |
| 538 | { |
| 539 | return base::init(strError); |
| 540 | } |
| 541 | |
| 542 | // Selection criteria interface |
| 543 | CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) |
| 544 | { |
| 545 | // Propagate |
| 546 | return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive); |
| 547 | } |
| 548 | |
| 549 | CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) |
| 550 | { |
| 551 | // Propagate |
| 552 | return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType); |
| 553 | } |
| 554 | |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 555 | // Selection criterion retrieval |
| 556 | CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 557 | { |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 558 | // Propagate |
| 559 | return getSelectionCriteria()->getSelectionCriterion(strName); |
| 560 | } |
| 561 | |
| 562 | // Selection criteria changed event |
| 563 | bool CParameterMgr::applyConfigurations(string& strError) |
| 564 | { |
| 565 | CAutoLog autoLog(this, "Configuration application request"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 566 | |
| 567 | // Lock state |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 568 | CAutoLock autoLock(&_blackboardMutex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 569 | |
| 570 | if (!_bTuningModeIsOn) { |
| 571 | |
| 572 | // Apply configuration(s) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 573 | if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) { |
| 574 | |
| 575 | log("Failed to apply configurations!"); |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 576 | |
| 577 | return false; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 578 | } |
| 579 | } |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 580 | |
| 581 | return true; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 582 | } |
| 583 | |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 584 | // Dynamic parameter handling |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 585 | CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError) |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 586 | { |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 587 | CPathNavigator pathNavigator(strPath); |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 588 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 589 | // Nagivate through system class |
| 590 | if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { |
| 591 | |
Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 592 | return NULL; |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | // Find element |
| 596 | const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator); |
| 597 | |
| 598 | if (!pElement) { |
| 599 | |
| 600 | strError = "Path not found"; |
| 601 | |
Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 602 | return NULL; |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | // Check found element is a parameter |
| 606 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement); |
| 607 | |
| 608 | if (!pConfigurableElement->isParameter()) { |
| 609 | |
| 610 | // Element is not parameter |
| 611 | strError = "Not a parameter"; |
| 612 | |
Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 613 | return NULL; |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | // Convert as parameter and return new handle |
| 617 | return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this); |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 618 | } |
| 619 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 620 | /////////////////// Remote command parsers |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 621 | /// Version |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 622 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 623 | { |
| 624 | (void)remoteCommand; |
| 625 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 626 | // Show version |
| 627 | strResult = getVersion(); |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 628 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 629 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 630 | } |
| 631 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 632 | /// Status |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 633 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 634 | { |
| 635 | (void)remoteCommand; |
| 636 | // System class |
| 637 | const CSystemClass* pSystemClass = getSystemClass(); |
| 638 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 639 | // Show status |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 640 | /// General section |
| 641 | appendTitle(strResult, "General:"); |
| 642 | // System class |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 643 | strResult += "System Class: "; |
| 644 | strResult += pSystemClass->getName(); |
| 645 | strResult += "\n"; |
| 646 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 647 | // Tuning mode |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 648 | strResult += "Tuning Mode: "; |
| 649 | strResult += tuningModeOn() ? "on" : "off"; |
| 650 | strResult += "\n"; |
| 651 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 652 | // Value space |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 653 | strResult += "Value Space: "; |
| 654 | strResult += valueSpaceIsRaw() ? "raw" : "real"; |
| 655 | strResult += "\n"; |
| 656 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 657 | // Output raw format |
| 658 | strResult += "Output Raw Format: "; |
| 659 | strResult += outputRawFormatIsHex() ? "hex" : "dec"; |
| 660 | strResult += "\n"; |
| 661 | |
| 662 | // Auto Sync |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 663 | strResult += "Auto Sync: "; |
| 664 | strResult += autoSyncOn() ? "on" : "off"; |
| 665 | strResult += "\n"; |
| 666 | |
| 667 | /// Subsystem list |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 668 | appendTitle(strResult, "Subsystems:"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 669 | string strSubsystemList; |
| 670 | pSystemClass->listChildrenPaths(strSubsystemList); |
| 671 | strResult += strSubsystemList; |
| 672 | |
| 673 | /// Last applied configurations |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 674 | appendTitle(strResult, "Last applied configurations:"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 675 | string strLastAppliedConfigurations; |
| 676 | getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); |
| 677 | strResult += strLastAppliedConfigurations; |
| 678 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 679 | /// Criteria states |
| 680 | appendTitle(strResult, "Selection criteria:"); |
| 681 | string strSelectionCriteria; |
| 682 | getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false); |
| 683 | strResult += strSelectionCriteria; |
| 684 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 685 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | /// Tuning Mode |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 689 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 690 | { |
| 691 | if (remoteCommand.getArgument(0) == "on") { |
| 692 | |
| 693 | if (setTuningMode(true, strResult)) { |
| 694 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 695 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 696 | } |
| 697 | } else if (remoteCommand.getArgument(0) == "off") { |
| 698 | |
| 699 | if (setTuningMode(false, strResult)) { |
| 700 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 701 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 702 | } |
| 703 | } else { |
| 704 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 705 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 706 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 707 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 708 | } |
| 709 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 710 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 711 | { |
| 712 | (void)remoteCommand; |
| 713 | |
| 714 | strResult = tuningModeOn() ? "on" : "off"; |
| 715 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 716 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /// Value Space |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 720 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 721 | { |
| 722 | (void)strResult; |
| 723 | |
| 724 | if (remoteCommand.getArgument(0) == "raw") { |
| 725 | |
| 726 | setValueSpace(true); |
| 727 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 728 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 729 | |
| 730 | } else if (remoteCommand.getArgument(0) == "real") { |
| 731 | |
| 732 | setValueSpace(false); |
| 733 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 734 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 735 | |
| 736 | } else { |
| 737 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 738 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 739 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 740 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 741 | } |
| 742 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 743 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 744 | { |
| 745 | (void)remoteCommand; |
| 746 | |
| 747 | strResult = valueSpaceIsRaw() ? "raw" : "real"; |
| 748 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 749 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 750 | } |
| 751 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 752 | /// Output Raw Format |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 753 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 754 | { |
| 755 | (void)strResult; |
| 756 | |
| 757 | if (remoteCommand.getArgument(0) == "hex") { |
| 758 | |
| 759 | setOutputRawFormat(true); |
| 760 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 761 | return CCommandHandler::EDone; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 762 | |
| 763 | } else if (remoteCommand.getArgument(0) == "dec") { |
| 764 | |
| 765 | setOutputRawFormat(false); |
| 766 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 767 | return CCommandHandler::EDone; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 768 | |
| 769 | } else { |
| 770 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 771 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 772 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 773 | return CCommandHandler::EFailed; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 774 | } |
| 775 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 776 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 777 | { |
| 778 | (void)remoteCommand; |
| 779 | |
| 780 | strResult = outputRawFormatIsHex() ? "hex" : "dec"; |
| 781 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 782 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 783 | } |
| 784 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 785 | /// Sync |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 786 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 787 | { |
| 788 | if (remoteCommand.getArgument(0) == "on") { |
| 789 | |
| 790 | if (setAutoSync(true, strResult)) { |
| 791 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 792 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 793 | } |
| 794 | } else if (remoteCommand.getArgument(0) == "off") { |
| 795 | |
| 796 | if (setAutoSync(false, strResult)) { |
| 797 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 798 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 799 | } |
| 800 | } else { |
| 801 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 802 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 803 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 804 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 805 | } |
| 806 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 807 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 808 | { |
| 809 | (void)remoteCommand; |
| 810 | |
| 811 | strResult = autoSyncOn() ? "on" : "off"; |
| 812 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 813 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 814 | } |
| 815 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 816 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 817 | { |
| 818 | (void)remoteCommand; |
| 819 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 820 | return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 821 | } |
| 822 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 823 | /// Criteria |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 824 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 825 | { |
| 826 | (void)remoteCommand; |
| 827 | |
| 828 | getSelectionCriteria()->listSelectionCriteria(strResult, true); |
| 829 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 830 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 831 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 832 | |
| 833 | /// Domains |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 834 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 835 | { |
| 836 | (void)remoteCommand; |
| 837 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 838 | getConfigurableDomains()->listDomains(strResult); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 839 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 840 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 841 | } |
| 842 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 843 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 844 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 845 | return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 846 | } |
| 847 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 848 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 849 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 850 | return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 851 | } |
| 852 | |
Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 853 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 854 | { |
| 855 | (void)remoteCommand; |
| 856 | |
| 857 | return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 858 | } |
| 859 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 860 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 861 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 862 | return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 863 | } |
| 864 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 865 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 866 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 867 | // Check tuning mode |
| 868 | if (!checkTuningModeOn(strResult)) { |
| 869 | |
| 870 | return CCommandHandler::EFailed; |
| 871 | } |
| 872 | |
| 873 | // Set property |
| 874 | bool bSequenceAware; |
| 875 | |
| 876 | if (remoteCommand.getArgument(1) == "true") { |
| 877 | |
| 878 | bSequenceAware = true; |
| 879 | |
| 880 | } else if (remoteCommand.getArgument(1) == "false") { |
| 881 | |
| 882 | bSequenceAware = false; |
| 883 | |
| 884 | } else { |
| 885 | // Show usage |
| 886 | return CCommandHandler::EShowUsage; |
| 887 | } |
| 888 | |
| 889 | return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 890 | } |
| 891 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 892 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 893 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 894 | // Get property |
| 895 | bool bSequenceAware; |
| 896 | |
| 897 | if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) { |
| 898 | |
| 899 | return CCommandHandler::EFailed; |
| 900 | } |
| 901 | |
| 902 | strResult = bSequenceAware ? "true" : "false"; |
| 903 | |
| 904 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 905 | } |
| 906 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 907 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 908 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 909 | return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 910 | } |
| 911 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 912 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 913 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 914 | return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 915 | } |
| 916 | |
| 917 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 918 | { |
| 919 | return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 920 | } |
| 921 | |
| 922 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 923 | { |
| 924 | return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | /// Configurations |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 928 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 929 | { |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 930 | return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| 931 | } |
| 932 | |
| 933 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 934 | { |
| 935 | (void)remoteCommand; |
| 936 | |
| 937 | // Dummy error context |
| 938 | string strError; |
| 939 | CErrorContext errorContext(strError); |
| 940 | |
| 941 | // Dump |
| 942 | getConstConfigurableDomains()->dumpContent(strResult, errorContext); |
| 943 | |
| 944 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 945 | } |
| 946 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 947 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 948 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 949 | return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 950 | } |
| 951 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 952 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 953 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 954 | return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 955 | } |
| 956 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 957 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 958 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 959 | return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 960 | } |
| 961 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 962 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 963 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 964 | return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 965 | } |
| 966 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 967 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 968 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 969 | return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 970 | } |
| 971 | |
| 972 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 973 | { |
| 974 | // Check tuning mode |
| 975 | if (!checkTuningModeOn(strResult)) { |
| 976 | |
| 977 | return CCommandHandler::EFailed; |
| 978 | } |
| 979 | |
| 980 | // Build configurable element path list |
| 981 | vector<string> astrNewElementSequence; |
| 982 | |
| 983 | uint32_t uiArgument; |
| 984 | |
| 985 | for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) { |
| 986 | |
| 987 | astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument)); |
| 988 | } |
| 989 | |
| 990 | // Delegate to configurable domains |
| 991 | return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 992 | } |
| 993 | |
| 994 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 995 | { |
| 996 | // Delegate to configurable domains |
| 997 | return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 998 | } |
| 999 | |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 1000 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1001 | { |
| 1002 | // Delegate to configurable domains |
| 1003 | return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1004 | } |
| 1005 | |
| 1006 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1007 | { |
| 1008 | // Delegate to configurable domains |
| 1009 | return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1010 | } |
| 1011 | |
| 1012 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1013 | { |
| 1014 | // Delegate to configurable domains |
| 1015 | return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| 1016 | } |
| 1017 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1018 | /// Elements/Parameters |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1019 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1020 | { |
| 1021 | CElementLocator elementLocator(getSystemClass(), false); |
| 1022 | |
| 1023 | CElement* pLocatedElement = NULL; |
| 1024 | |
| 1025 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1026 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1027 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | strResult = string("\n"); |
| 1031 | |
| 1032 | if (!pLocatedElement) { |
| 1033 | |
| 1034 | // List from root folder |
| 1035 | |
| 1036 | // Return system class qualified name |
| 1037 | pLocatedElement = getSystemClass(); |
| 1038 | } |
| 1039 | |
| 1040 | // Return sub-elements |
| 1041 | strResult += pLocatedElement->listQualifiedPaths(false); |
| 1042 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1043 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | /// Elements/Parameters |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1047 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1048 | { |
| 1049 | CElementLocator elementLocator(getSystemClass(), false); |
| 1050 | |
| 1051 | CElement* pLocatedElement = NULL; |
| 1052 | |
| 1053 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1054 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1055 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | strResult = string("\n"); |
| 1059 | |
| 1060 | if (!pLocatedElement) { |
| 1061 | |
| 1062 | // List from root folder |
| 1063 | |
| 1064 | // Return system class qualified name |
| 1065 | pLocatedElement = getSystemClass(); |
| 1066 | } |
| 1067 | |
| 1068 | // Return sub-elements |
| 1069 | strResult += pLocatedElement->listQualifiedPaths(true); |
| 1070 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1071 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1072 | } |
| 1073 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1074 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1075 | { |
| 1076 | CElementLocator elementLocator(getSystemClass()); |
| 1077 | |
| 1078 | CElement* pLocatedElement = NULL; |
| 1079 | |
| 1080 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1081 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1082 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | string strError; |
| 1086 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1087 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1088 | |
| 1089 | // Dump elements |
| 1090 | pLocatedElement->dumpContent(strResult, parameterAccessContext); |
| 1091 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1092 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1093 | } |
| 1094 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1095 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1096 | { |
| 1097 | CElementLocator elementLocator(getSystemClass()); |
| 1098 | |
| 1099 | CElement* pLocatedElement = NULL; |
| 1100 | |
| 1101 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1102 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1103 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | // Converted to actual sizable element |
| 1107 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1108 | |
| 1109 | // Get size as string |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1110 | strResult = pConfigurableElement->getFootprintAsString(); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1111 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1112 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1113 | } |
| 1114 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1115 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1116 | { |
| 1117 | CElementLocator elementLocator(getSystemClass()); |
| 1118 | |
| 1119 | CElement* pLocatedElement = NULL; |
| 1120 | |
| 1121 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1122 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1123 | return CCommandHandler::EFailed; |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | // Convert element |
| 1127 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1128 | |
| 1129 | // Return element properties |
| 1130 | pConfigurableElement->showProperties(strResult); |
| 1131 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1132 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1133 | } |
| 1134 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1135 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1136 | { |
| 1137 | string strValue; |
| 1138 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1139 | if (!accessValue(remoteCommand.getArgument(0), strValue, false, strResult)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1140 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1141 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1142 | } |
| 1143 | // Succeeded |
| 1144 | strResult = strValue; |
| 1145 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1146 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1147 | } |
| 1148 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1149 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1150 | { |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1151 | // Check tuning mode |
| 1152 | if (!checkTuningModeOn(strResult)) { |
| 1153 | |
| 1154 | return CCommandHandler::EFailed; |
| 1155 | } |
| 1156 | // Get value to set |
| 1157 | string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1); |
| 1158 | |
| 1159 | return accessValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1160 | } |
| 1161 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1162 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1163 | { |
| 1164 | CElementLocator elementLocator(getSystemClass()); |
| 1165 | |
| 1166 | CElement* pLocatedElement = NULL; |
| 1167 | |
| 1168 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1169 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1170 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1171 | } |
| 1172 | |
| 1173 | // Convert element |
| 1174 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1175 | |
| 1176 | // Return element belonging domains |
| 1177 | pConfigurableElement->listBelongingDomains(strResult); |
| 1178 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1179 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1180 | } |
| 1181 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1182 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1183 | { |
| 1184 | CElementLocator elementLocator(getSystemClass()); |
| 1185 | |
| 1186 | CElement* pLocatedElement = NULL; |
| 1187 | |
| 1188 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1189 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1190 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | // Convert element |
| 1194 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1195 | |
| 1196 | // Return element belonging domains |
| 1197 | pConfigurableElement->listAssociatedDomains(strResult); |
| 1198 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1199 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1200 | } |
| 1201 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1202 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1203 | { |
| 1204 | (void)remoteCommand; |
| 1205 | |
| 1206 | getConfigurableDomains()->listAssociatedElements(strResult); |
| 1207 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1208 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1209 | } |
| 1210 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1211 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1212 | { |
| 1213 | (void)remoteCommand; |
| 1214 | |
| 1215 | getConfigurableDomains()->listConflictingElements(strResult); |
| 1216 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1217 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1218 | } |
| 1219 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1220 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1221 | { |
| 1222 | (void)remoteCommand; |
| 1223 | |
| 1224 | getSystemClass()->listRogueElements(strResult); |
| 1225 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1226 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | /// Settings Import/Export |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1230 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1231 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1232 | return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1233 | } |
| 1234 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1235 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1236 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1237 | return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1238 | } |
| 1239 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1240 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1241 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1242 | return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1243 | } |
| 1244 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1245 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1246 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1247 | return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1248 | } |
| 1249 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1250 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1251 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1252 | return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1253 | } |
| 1254 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1255 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1256 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1257 | return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1258 | } |
| 1259 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1260 | /// GUI commands |
| 1261 | |
| 1262 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getDomainsXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1263 | { |
| 1264 | (void)remoteCommand; |
| 1265 | |
| 1266 | if (!getDomainsXMLString(strResult, true)) { |
| 1267 | |
| 1268 | return CCommandHandler::EFailed; |
| 1269 | } |
| 1270 | // Succeeded |
| 1271 | return CCommandHandler::ESucceeded; |
| 1272 | } |
| 1273 | |
| 1274 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSystemClassXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1275 | { |
| 1276 | (void)remoteCommand; |
| 1277 | |
| 1278 | if (!getSystemClassXMLString(strResult)) { |
| 1279 | |
| 1280 | return CCommandHandler::EFailed; |
| 1281 | } |
| 1282 | // Succeeded |
| 1283 | return CCommandHandler::ESucceeded; |
| 1284 | } |
| 1285 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1286 | // User set/get parameters |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1287 | bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bSet, string& strError) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1288 | { |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1289 | // Lock state |
| 1290 | CAutoLock autoLock(&_blackboardMutex); |
| 1291 | |
| 1292 | CPathNavigator pathNavigator(strPath); |
| 1293 | |
| 1294 | // Nagivate through system class |
| 1295 | if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1296 | |
| 1297 | return false; |
| 1298 | } |
| 1299 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1300 | // Define context |
| 1301 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1302 | |
Patrick Benavoli | 68808c6 | 2012-02-02 17:12:41 +0100 | [diff] [blame] | 1303 | // Auto Sync |
| 1304 | if (bSet) { |
| 1305 | |
| 1306 | parameterAccessContext.setAutoSync(_bAutoSyncOn); |
| 1307 | } |
| 1308 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1309 | // Do the get |
| 1310 | return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | // Tuning mode |
| 1314 | bool CParameterMgr::setTuningMode(bool bOn, string& strError) |
| 1315 | { |
| 1316 | // Tuning allowed? |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 1317 | if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1318 | |
| 1319 | strError = "Tuning prohibited"; |
| 1320 | |
| 1321 | return false; |
| 1322 | } |
| 1323 | // Lock state |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1324 | CAutoLock autoLock(&_blackboardMutex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1325 | |
| 1326 | // Warn domains about exiting tuning mode |
| 1327 | if (!bOn && _bTuningModeIsOn) { |
| 1328 | |
| 1329 | // Ensure application of currently selected configurations |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1330 | // Force-apply configurations |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1331 | if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) { |
| 1332 | |
| 1333 | return false; |
| 1334 | } |
| 1335 | // Turn auto sync back on |
| 1336 | _bAutoSyncOn = true; |
| 1337 | } |
| 1338 | |
| 1339 | // Store |
| 1340 | _bTuningModeIsOn = bOn; |
| 1341 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1342 | return true; |
| 1343 | } |
| 1344 | |
| 1345 | bool CParameterMgr::tuningModeOn() const |
| 1346 | { |
| 1347 | return _bTuningModeIsOn; |
| 1348 | } |
| 1349 | |
| 1350 | // Current value space for user set/get value interpretation |
| 1351 | void CParameterMgr::setValueSpace(bool bIsRaw) |
| 1352 | { |
| 1353 | _bValueSpaceIsRaw = bIsRaw; |
| 1354 | } |
| 1355 | |
| 1356 | bool CParameterMgr::valueSpaceIsRaw() |
| 1357 | { |
| 1358 | return _bValueSpaceIsRaw; |
| 1359 | } |
| 1360 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1361 | // Current Output Raw Format for user get value interpretation |
| 1362 | void CParameterMgr::setOutputRawFormat(bool bIsHex) |
| 1363 | { |
| 1364 | _bOutputRawFormatIsHex = bIsHex; |
| 1365 | } |
| 1366 | |
| 1367 | bool CParameterMgr::outputRawFormatIsHex() |
| 1368 | { |
| 1369 | return _bOutputRawFormatIsHex; |
| 1370 | } |
| 1371 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1372 | /// Sync |
| 1373 | // Automatic hardware synchronization control (during tuning session) |
| 1374 | bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError) |
| 1375 | { |
| 1376 | // Check tuning mode |
| 1377 | if (!checkTuningModeOn(strError)) { |
| 1378 | |
| 1379 | return false; |
| 1380 | } |
| 1381 | // Warn domains about turning auto sync back on |
| 1382 | if (bAutoSyncOn && !_bAutoSyncOn) { |
| 1383 | |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 1384 | // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters) |
| 1385 | if (!sync(strError)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1386 | |
| 1387 | return false; |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | // Set Auto sync |
| 1392 | _bAutoSyncOn = bAutoSyncOn; |
| 1393 | |
| 1394 | return true; |
| 1395 | } |
| 1396 | |
| 1397 | bool CParameterMgr::autoSyncOn() const |
| 1398 | { |
| 1399 | return _bAutoSyncOn; |
| 1400 | } |
| 1401 | |
| 1402 | // Manual hardware synchronization control (during tuning session) |
| 1403 | bool CParameterMgr::sync(string& strError) |
| 1404 | { |
| 1405 | // Check tuning mode |
| 1406 | if (!checkTuningModeOn(strError)) { |
| 1407 | |
| 1408 | return false; |
| 1409 | } |
| 1410 | // Warn domains about turning auto sync back on |
| 1411 | if (_bAutoSyncOn) { |
| 1412 | |
| 1413 | strError = "Feature unavailable when Auto Sync is on"; |
| 1414 | |
| 1415 | return false; |
| 1416 | } |
| 1417 | |
| 1418 | // Get syncer set |
| 1419 | CSyncerSet syncerSet; |
| 1420 | // ... from system class |
| 1421 | getConstSystemClass()->fillSyncerSet(syncerSet); |
| 1422 | // Sync |
| 1423 | return syncerSet.sync(*_pMainParameterBlackboard, false, strError); |
| 1424 | } |
| 1425 | |
| 1426 | // Content dump |
| 1427 | void CParameterMgr::logStructureContent(string& strContent) const |
| 1428 | { |
| 1429 | string strError; |
| 1430 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1431 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1432 | |
| 1433 | dumpContent(strContent, parameterAccessContext); |
| 1434 | } |
| 1435 | |
| 1436 | // Configuration/Domains handling |
| 1437 | bool CParameterMgr::createDomain(const string& strName, string& strError) |
| 1438 | { |
| 1439 | // Check tuning mode |
| 1440 | if (!checkTuningModeOn(strError)) { |
| 1441 | |
| 1442 | return false; |
| 1443 | } |
| 1444 | |
| 1445 | // Delegate to configurable domains |
| 1446 | return getConfigurableDomains()->createDomain(strName, strError); |
| 1447 | } |
| 1448 | |
| 1449 | bool CParameterMgr::deleteDomain(const string& strName, string& strError) |
| 1450 | { |
| 1451 | // Check tuning mode |
| 1452 | if (!checkTuningModeOn(strError)) { |
| 1453 | |
| 1454 | return false; |
| 1455 | } |
| 1456 | |
| 1457 | // Delegate to configurable domains |
| 1458 | return getConfigurableDomains()->deleteDomain(strName, strError); |
| 1459 | } |
| 1460 | |
Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 1461 | bool CParameterMgr::deleteAllDomains(string& strError) |
| 1462 | { |
| 1463 | // Check tuning mode |
| 1464 | if (!checkTuningModeOn(strError)) { |
| 1465 | |
| 1466 | return false; |
| 1467 | } |
| 1468 | |
| 1469 | // Delegate to configurable domains |
| 1470 | getConfigurableDomains()->deleteAllDomains(); |
| 1471 | |
| 1472 | return true; |
| 1473 | } |
| 1474 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1475 | bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1476 | { |
| 1477 | // Check tuning mode |
| 1478 | if (!checkTuningModeOn(strError)) { |
| 1479 | |
| 1480 | return false; |
| 1481 | } |
| 1482 | |
| 1483 | // Delegate to configurable domains |
| 1484 | return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1485 | } |
| 1486 | |
| 1487 | bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1488 | { |
| 1489 | // Check tuning mode |
| 1490 | if (!checkTuningModeOn(strError)) { |
| 1491 | |
| 1492 | return false; |
| 1493 | } |
| 1494 | |
| 1495 | // Delegate to configurable domains |
| 1496 | return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError); |
| 1497 | } |
| 1498 | |
| 1499 | bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1500 | { |
| 1501 | // Check tuning mode |
| 1502 | if (!checkTuningModeOn(strError)) { |
| 1503 | |
| 1504 | return false; |
| 1505 | } |
| 1506 | |
| 1507 | // Delegate to configurable domains |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 1508 | return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1509 | } |
| 1510 | |
| 1511 | bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1512 | { |
| 1513 | // Check tuning mode |
| 1514 | if (!checkTuningModeOn(strError)) { |
| 1515 | |
| 1516 | return false; |
| 1517 | } |
| 1518 | |
| 1519 | // Delegate to configurable domains |
| 1520 | return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1521 | } |
| 1522 | |
| 1523 | // Configurable element - domain association |
| 1524 | bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1525 | { |
| 1526 | // Check tuning mode |
| 1527 | if (!checkTuningModeOn(strError)) { |
| 1528 | |
| 1529 | return false; |
| 1530 | } |
| 1531 | |
| 1532 | CElementLocator elementLocator(getSystemClass()); |
| 1533 | |
| 1534 | CElement* pLocatedElement = NULL; |
| 1535 | |
| 1536 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1537 | |
| 1538 | return false; |
| 1539 | } |
| 1540 | |
| 1541 | // Convert element |
Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1542 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1543 | |
| 1544 | // Delegate |
| 1545 | return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError); |
| 1546 | } |
| 1547 | |
| 1548 | bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1549 | { |
| 1550 | // Check tuning mode |
| 1551 | if (!checkTuningModeOn(strError)) { |
| 1552 | |
| 1553 | return false; |
| 1554 | } |
| 1555 | |
| 1556 | CElementLocator elementLocator(getSystemClass()); |
| 1557 | |
| 1558 | CElement* pLocatedElement = NULL; |
| 1559 | |
| 1560 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1561 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1562 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | // Convert element |
Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1566 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1567 | |
| 1568 | // Delegate |
| 1569 | return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError); |
| 1570 | } |
| 1571 | |
| 1572 | bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1573 | { |
| 1574 | // Check tuning mode |
| 1575 | if (!checkTuningModeOn(strError)) { |
| 1576 | |
| 1577 | return false; |
| 1578 | } |
| 1579 | |
| 1580 | CElementLocator elementLocator(getSystemClass()); |
| 1581 | |
| 1582 | CElement* pLocatedElement = NULL; |
| 1583 | |
| 1584 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1585 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1586 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | // Convert element |
Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1590 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1591 | |
| 1592 | // Delegate |
| 1593 | return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError); |
| 1594 | } |
| 1595 | |
| 1596 | // XML Import/Export |
| 1597 | bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError) |
| 1598 | { |
| 1599 | // Check tuning mode |
| 1600 | if (!checkTuningModeOn(strError)) { |
| 1601 | |
| 1602 | return false; |
| 1603 | } |
| 1604 | |
| 1605 | // check path is absolute |
| 1606 | if (strFileName[0] != '/') { |
| 1607 | |
| 1608 | strError = "Please provide absolute path"; |
| 1609 | |
| 1610 | return false; |
| 1611 | } |
| 1612 | // Root element |
| 1613 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1614 | |
| 1615 | // Context |
| 1616 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); |
| 1617 | |
| 1618 | // Secltion criteria definition for rule creation |
| 1619 | xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| 1620 | |
| 1621 | // Parse |
| 1622 | if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) { |
| 1623 | |
| 1624 | return false; |
| 1625 | } |
| 1626 | |
| 1627 | // Validate domains after XML import |
| 1628 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 1629 | |
| 1630 | return true; |
| 1631 | } |
| 1632 | |
| 1633 | bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const |
| 1634 | { |
| 1635 | // check path is absolute |
| 1636 | if (strFileName[0] != '/') { |
| 1637 | |
| 1638 | strError = "Please provide absolute path"; |
| 1639 | |
| 1640 | return false; |
| 1641 | } |
| 1642 | |
| 1643 | // Root element |
| 1644 | const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); |
| 1645 | |
| 1646 | // Get Schema file associated to root element |
| 1647 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd"; |
| 1648 | |
| 1649 | // Context |
| 1650 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); |
| 1651 | |
| 1652 | // Value space |
| 1653 | xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); |
| 1654 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1655 | // Output raw format |
| 1656 | xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); |
| 1657 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1658 | // Use a doc source by loading data from instantiated Configurable Domains |
| 1659 | CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion()); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1660 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1661 | // Use a doc sink to write the doc data in a file |
| 1662 | CXmlFileDocSink fileSink(strFileName); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1663 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1664 | if (!fileSink.process(memorySource, xmlDomainSerializingContext)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1665 | return false; |
| 1666 | } |
| 1667 | |
| 1668 | return true; |
| 1669 | } |
| 1670 | |
| 1671 | // Binary Import/Export |
| 1672 | bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError) |
| 1673 | { |
| 1674 | // Check tuning mode |
| 1675 | if (!checkTuningModeOn(strError)) { |
| 1676 | |
| 1677 | return false; |
| 1678 | } |
| 1679 | // check path is absolute |
| 1680 | if (strFileName[0] != '/') { |
| 1681 | |
| 1682 | strError = "Please provide absolute path"; |
| 1683 | |
| 1684 | return false; |
| 1685 | } |
| 1686 | // Root element |
| 1687 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1688 | |
| 1689 | // Serialize in |
| 1690 | return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError); |
| 1691 | } |
| 1692 | |
| 1693 | bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError) |
| 1694 | { |
| 1695 | // check path is absolute |
| 1696 | if (strFileName[0] != '/') { |
| 1697 | |
| 1698 | strError = "Please provide absolute path"; |
| 1699 | |
| 1700 | return false; |
| 1701 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1702 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1703 | // Root element |
| 1704 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1705 | |
| 1706 | // Serialize out |
| 1707 | return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError); |
| 1708 | } |
| 1709 | |
| 1710 | // For tuning, check we're in tuning mode |
| 1711 | bool CParameterMgr::checkTuningModeOn(string& strError) const |
| 1712 | { |
| 1713 | // Tuning Mode on? |
| 1714 | if (!_bTuningModeIsOn) { |
| 1715 | |
| 1716 | strError = "Tuning Mode must be on"; |
| 1717 | |
| 1718 | return false; |
| 1719 | } |
| 1720 | return true; |
| 1721 | } |
| 1722 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1723 | // Tuning mutex dynamic parameter handling |
| 1724 | pthread_mutex_t* CParameterMgr::getBlackboardMutex() |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1725 | { |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1726 | return &_blackboardMutex; |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1727 | } |
| 1728 | |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1729 | // Blackboard reference (dynamic parameter handling) |
| 1730 | CParameterBlackboard* CParameterMgr::getParameterBlackboard() |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1731 | { |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1732 | return _pMainParameterBlackboard; |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1733 | } |
| 1734 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1735 | // Dynamic creation library feeding |
| 1736 | void CParameterMgr::feedElementLibraries() |
| 1737 | { |
| 1738 | // Global Configuration handling |
| 1739 | CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary; |
| 1740 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1741 | pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration")); |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 1742 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins")); |
| 1743 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location")); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1744 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation")); |
| 1745 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration")); |
| 1746 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation")); |
| 1747 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1748 | |
| 1749 | _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary); |
| 1750 | |
| 1751 | // Parameter creation |
| 1752 | CElementLibrary* pParameterCreationLibrary = new CElementLibrary; |
| 1753 | |
| 1754 | pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1755 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType")); |
| 1756 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component")); |
| 1757 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter")); |
| 1758 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock")); |
Patrick Benavoli | 1352ae5 | 2011-10-21 16:48:04 +0200 | [diff] [blame] | 1759 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter")); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1760 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock")); |
| 1761 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter")); |
| 1762 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter")); |
Patrick Benavoli | ee65e6d | 2011-11-20 18:52:24 +0100 | [diff] [blame] | 1763 | pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation")); |
Patrick Benavoli | 9fc3c0d | 2011-10-27 14:27:27 +0200 | [diff] [blame] | 1764 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter")); |
Patrick Benavoli | 68808c6 | 2012-02-02 17:12:41 +0100 | [diff] [blame] | 1765 | pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair")); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1766 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter")); |
| 1767 | pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1768 | |
| 1769 | _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary); |
| 1770 | |
| 1771 | // Parameter Configuration Domains creation |
| 1772 | CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary; |
| 1773 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1774 | pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain")); |
| 1775 | pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration")); |
| 1776 | pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule")); |
| 1777 | pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1778 | |
| 1779 | _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary); |
| 1780 | } |
| 1781 | |
| 1782 | // Remote Processor Server connection handling |
| 1783 | bool CParameterMgr::handleRemoteProcessingInterface(string& strError) |
| 1784 | { |
| 1785 | CAutoLog autoLog(this, "Handling remote processing interface"); |
| 1786 | |
| 1787 | // Start server if tuning allowed |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 1788 | if (getConstFrameworkConfiguration()->isTuningAllowed()) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1789 | |
| 1790 | log("Loading remote processor library"); |
| 1791 | |
| 1792 | // Load library |
| 1793 | void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW); |
| 1794 | |
| 1795 | if (!lib_handle) { |
| 1796 | |
| 1797 | // Return error |
| 1798 | const char* pcError = dlerror(); |
| 1799 | |
| 1800 | if (pcError) { |
| 1801 | |
| 1802 | strError = pcError; |
| 1803 | } else { |
| 1804 | |
| 1805 | strError = "Unable to load libremote-processor.so library"; |
| 1806 | } |
| 1807 | |
| 1808 | return false; |
| 1809 | } |
| 1810 | |
| 1811 | CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer"); |
| 1812 | |
| 1813 | if (!pfnCreateRemoteProcessorServer) { |
| 1814 | |
| 1815 | strError = "libremote-process.so does not contain createRemoteProcessorServer symbol."; |
| 1816 | |
| 1817 | return false; |
| 1818 | } |
| 1819 | |
| 1820 | // Create server |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 1821 | _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1822 | |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 1823 | log("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort()); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1824 | // Start |
| 1825 | if (!_pRemoteProcessorServer->start()) { |
| 1826 | |
| 1827 | strError = "Unable to start remote processor server"; |
| 1828 | |
| 1829 | return false; |
| 1830 | } |
| 1831 | } |
| 1832 | |
| 1833 | return true; |
| 1834 | } |
| 1835 | |
| 1836 | // Back synchronization |
| 1837 | CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const |
| 1838 | { |
| 1839 | #ifdef SIMULATION |
| 1840 | // In simulation, back synchronization of the blackboard won't probably work |
| 1841 | // We need to ensure though the blackboard is initialized with valid data |
| 1842 | return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); |
| 1843 | #else |
| 1844 | // Real back synchronizer from subsystems |
| 1845 | return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); |
| 1846 | #endif |
| 1847 | } |
| 1848 | |
| 1849 | // Children typwise access |
| 1850 | CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration() |
| 1851 | { |
| 1852 | return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration)); |
| 1853 | } |
| 1854 | |
| 1855 | const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration() |
| 1856 | { |
| 1857 | return getFrameworkConfiguration(); |
| 1858 | } |
| 1859 | |
| 1860 | CSelectionCriteria* CParameterMgr::getSelectionCriteria() |
| 1861 | { |
| 1862 | return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 1863 | } |
| 1864 | |
| 1865 | const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria() |
| 1866 | { |
| 1867 | return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 1868 | } |
| 1869 | |
| 1870 | CSystemClass* CParameterMgr::getSystemClass() |
| 1871 | { |
| 1872 | return static_cast<CSystemClass*>(getChild(ESystemClass)); |
| 1873 | } |
| 1874 | |
| 1875 | const CSystemClass* CParameterMgr::getConstSystemClass() const |
| 1876 | { |
| 1877 | return static_cast<const CSystemClass*>(getChild(ESystemClass)); |
| 1878 | } |
| 1879 | |
| 1880 | // Configurable Domains |
| 1881 | CConfigurableDomains* CParameterMgr::getConfigurableDomains() |
| 1882 | { |
| 1883 | return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1884 | } |
| 1885 | |
| 1886 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() |
| 1887 | { |
| 1888 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1889 | } |
| 1890 | |
| 1891 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const |
| 1892 | { |
| 1893 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1894 | } |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1895 | |
| 1896 | /// GUI commands functions |
| 1897 | |
| 1898 | bool CParameterMgr::getDomainsXMLString(string& strResult, bool bWithSettings) |
| 1899 | { |
| 1900 | |
| 1901 | // Root element |
| 1902 | const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); |
| 1903 | |
| 1904 | // Get Schema file associated to root element |
| 1905 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd"; |
| 1906 | |
| 1907 | string strError; |
| 1908 | |
| 1909 | // Context |
| 1910 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); |
| 1911 | |
| 1912 | // Value space |
| 1913 | xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); |
| 1914 | |
| 1915 | // Output raw format |
| 1916 | xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); |
| 1917 | |
| 1918 | // Use a doc source by loading data from instantiated Configurable Domains |
| 1919 | CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion()); |
| 1920 | |
| 1921 | // Use a doc sink the write the doc data in a string |
| 1922 | CXmlStringDocSink stringSink(strResult); |
| 1923 | |
| 1924 | if (!stringSink.process(memorySource, xmlDomainSerializingContext)) { |
| 1925 | strResult = strError; |
| 1926 | |
| 1927 | return false; |
| 1928 | } |
| 1929 | |
| 1930 | return true; |
| 1931 | } |
| 1932 | |
| 1933 | bool CParameterMgr::getSystemClassXMLString(string& strResult) |
| 1934 | { |
| 1935 | // Root element |
| 1936 | const CSystemClass* pSystemClass = getSystemClass(); |
| 1937 | |
| 1938 | string strError; |
| 1939 | |
| 1940 | CXmlSerializingContext xmlSerializingContext(strError); |
| 1941 | |
| 1942 | // Use a doc source by loading data from instantiated Configurable Domains |
| 1943 | CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind()); |
| 1944 | |
| 1945 | // Use a doc sink that write the doc data in a string |
| 1946 | CXmlStringDocSink stringSink(strResult); |
| 1947 | |
| 1948 | if (!stringSink.process(memorySource, xmlSerializingContext)) { |
| 1949 | strResult = strError; |
| 1950 | return false; |
| 1951 | } |
| 1952 | |
| 1953 | return true; |
| 1954 | } |