blob: 3af4c39a20ceebb2aa1de35deca1c098a1f0eefa [file] [log] [blame]
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +02001/*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * 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 Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#include "ParameterMgr.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020026#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 Benavoli68a91282011-08-31 11:23:23 +020035#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 Benavoli68a91282011-08-31 11:23:23 +020045#include "ParameterAccessContext.h"
46#include "XmlFileIncluderElement.h"
47#include "ParameterFrameworkConfiguration.h"
48#include "FrameworkConfigurationGroup.h"
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +010049#include "PluginLocation.h"
50#include "SubsystemPlugins.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020051#include "FrameworkConfigurationLocation.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020052#include "ConfigurableDomains.h"
53#include "ConfigurableDomain.h"
54#include "DomainConfiguration.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020055#include "XmlDomainSerializingContext.h"
56#include "BitParameterBlockType.h"
57#include "BitParameterType.h"
Patrick Benavoli1352ae52011-10-21 16:48:04 +020058#include "StringParameterType.h"
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +020059#include "EnumParameterType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020060#include "RemoteProcessorServerInterface.h"
61#include "ElementLocator.h"
62#include "AutoLog.h"
63#include "CompoundRule.h"
64#include "SelectionCriterionRule.h"
65#include "SimulatedBackSynchronizer.h"
66#include "HardwareBackSynchronizer.h"
Patrick Benavoli1387bda2011-08-31 11:23:24 +020067#include "AutoLock.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020068#include <strings.h>
69#include <dlfcn.h>
70#include <assert.h>
Patrick Benavoli065264a2011-11-20 15:46:41 +010071#include "ParameterHandle.h"
Patrick Benavoliee65e6d2011-11-20 18:52:24 +010072#include "LinearParameterAdaptation.h"
Patrick Benavoli68808c62012-02-02 17:12:41 +010073#include "EnumValuePair.h"
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020074#include "XmlFileDocSink.h"
75#include "XmlFileDocSource.h"
76#include "XmlStringDocSink.h"
77#include "XmlMemoryDocSink.h"
78#include "XmlMemoryDocSource.h"
Kevin Rocardace81f82012-12-11 16:19:17 +010079#include "Utility.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020080
81#define base CElement
82
83// Used for remote processor server creation
84typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
85
86// Global configuration file name (fixed)
87const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
88const char* gacSystemSchemasSubFolder = "Schemas";
89
90// Config File System looks normally like this:
91// ---------------------------------------------
Patrick Benavoli95ac0342011-11-07 20:32:51 +010092//├── <ParameterFrameworkConfiguration>.xml
Patrick Benavoli68a91282011-08-31 11:23:23 +020093//├── 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 Benavoli592ae562011-09-05 16:53:58 +0200107const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Patrick Benavoli592ae562011-09-05 16:53:58 +0200108 /// Version
109 { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200110 /// 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 Benavoli6ba361d2011-08-31 11:23:24 +0200116 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200117 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200118 /// 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 Benavoli68a91282011-08-31 11:23:23 +0200121 /// 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 Benavoli6ba361d2011-08-31 11:23:24 +0200125 /// Criteria
Kevin Rocard4eae8272013-04-18 19:12:46 +0200126 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "[csv]", "List selection criteria" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200127 /// Domains
128 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100129 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, "", "Show all domains and configurations, including applicability conditions" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200130 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" },
131 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" },
Kevin Rocard170f0a42012-06-18 13:56:05 +0200132 { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0, "", "Delete all configurable domains" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200133 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200134 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" },
135 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200136 { "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 Benavoli0bd50542011-11-29 11:10:27 +0100147 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3, "<domain> <configuration> <elem path list>", "Set element application order for configuration" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200148 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100149 { "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 Benavoli68a91282011-08-31 11:23:23 +0200152 /// Elements/Parameters
153 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
Patrick Benavoli592ae562011-09-05 16:53:58 +0200154 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200155 { "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 Benavoli2ecf9002011-08-31 11:23:24 +0200157 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200158 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200159 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200160 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200161 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +0100162 { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3, "<domain> <configuration> <param path>", "Get value for parameter at given path from configuration" },
163 { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4, "<domain> <configuration> <param path> <value>", "Set value for parameter at given path to configuration" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200164 /// Browse
165 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" },
166 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" },
167 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" },
168 /// Settings Import/Export
169 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" },
170 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" },
171 { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" },
172 { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" },
173 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" },
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200174 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" },
175 { "getDomainsXML", &CParameterMgr::getDomainsXMLCommmandProcess, 0 ,"", "Print domains including settings as XML" },
176 /// Structure Export
177 { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,"", "Print parameter structure as XML" }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200178};
179// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200180const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200181
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100182CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200183 _bTuningModeIsOn(false),
184 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200185 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200186 _bAutoSyncOn(true),
187 _pMainParameterBlackboard(new CParameterBlackboard),
188 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100189 _strXmlConfigurationFilePath(strConfigurationFilePath),
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100190 _pSubsystemPlugins(NULL),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200191 _uiStructureChecksum(0),
192 _pRemoteProcessorServer(NULL),
193 _uiMaxCommandUsageLength(0),
194 _pLogger(NULL),
195 _uiLogDepth(0)
196{
197 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100198 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
199 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200200
201 // Deal with children
202 addChild(new CParameterFrameworkConfiguration);
203 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100204 addChild(new CSystemClass);
205 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200206
207 // Feed element library
208 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200209
210 _pCommandHandler = new CCommandHandler(this);
211
212 // Add command parsers
213 uint32_t uiRemoteCommandParserItem;
214
215 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
216
217 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
218
219 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
220 pRemoteCommandParserItem->_pfnParser,
221 pRemoteCommandParserItem->_uiMinArgumentCount,
222 pRemoteCommandParserItem->_pcHelp,
223 pRemoteCommandParserItem->_pcDescription);
224 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100225
226 // Configuration file folder
227 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
228
229 assert(uiSlashPos != (uint32_t)-1);
230
231 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
232
233 // Schema absolute folder location
234 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200235}
236
237CParameterMgr::~CParameterMgr()
238{
239 // Children
240 delete _pRemoteProcessorServer;
Frederic Boisnard31242302012-04-26 17:07:34 +0200241 delete _pCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200242 delete _pMainParameterBlackboard;
243 delete _pElementLibrarySet;
244
245 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100246 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200247}
248
249string CParameterMgr::getKind() const
250{
251 return "ParameterMgr";
252}
253
254// Logging
255void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
256{
257 _pLogger = pLogger;
258}
259
260// Logging
Kevin Rocardace81f82012-12-11 16:19:17 +0100261void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200262{
263 if (_pLogger) {
264
265 // Nest
266 string strIndent;
267
268 // Level
269 uint32_t uiNbIndents = _uiLogDepth;
270
271 while (uiNbIndents--) {
272
273 strIndent += " ";
274 }
275
276 // Log
Kevin Rocardace81f82012-12-11 16:19:17 +0100277 _pLogger->log(bIsWarning, strIndent + strLog);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200278 }
279}
280
281void CParameterMgr::nestLog() const
282{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200283 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200284}
285
286void CParameterMgr::unnestLog() const
287{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200288 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200289}
290
Patrick Benavoli63499d42011-10-24 18:50:03 +0200291// Version
292string CParameterMgr::getVersion() const
293{
294 string strVersion;
295
296 // Major
297 strVersion = toString(guiEditionMajor) + ".";
298 // Minor
299 strVersion += toString(guiEditionMinor) + ".";
300 // Revision
301 strVersion += toString(guiRevision);
302
303 return strVersion;
304}
305
Patrick Benavoli68a91282011-08-31 11:23:23 +0200306bool CParameterMgr::load(string& strError)
307{
308 CAutoLog autoLog(this, "Loading");
309
310 // Load Framework configuration
311 if (!loadFrameworkConfiguration(strError)) {
312
313 return false;
314 }
315
316 // Load subsystems
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100317 if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200318
319 return false;
320 }
321
322 // Load structure
323 if (!loadStructure(strError)) {
324
325 return false;
326 }
327
328 // Load settings
329 if (!loadSettings(strError)) {
330
331 return false;
332 }
333
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200334 // Back synchronization for areas in parameter blackboard not covered by any domain
Kevin Rocardace81f82012-12-11 16:19:17 +0100335 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200336
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200337 // Back-synchronize
Kevin Rocard57096bd2012-11-30 11:24:20 +0100338 {
339 CAutoLog autoLog(this, "Main blackboard back synchronization");
340
Kevin Rocard5d6e05a2013-01-21 15:57:45 +0100341 pBackSynchronizer->sync();
Kevin Rocard57096bd2012-11-30 11:24:20 +0100342
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200343 // Get rid of back synchronizer
344 delete pBackSynchronizer;
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200345 }
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200346
347 // We're done loading the settings and back synchronizing
348 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
349
350 // We need to ensure all domains are valid
351 pConfigurableDomains->validate(_pMainParameterBlackboard);
352
Kevin Rocard7f265822012-12-07 18:51:22 +0100353 // Log selection criterion states
354 {
355 CAutoLog autoLog(this, "Criterion states");
356
357 const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria();
358
359 list<string> lstrSelectionCriteron;
360 selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false);
361
Kevin Rocard36299362013-02-04 14:57:47 +0100362 log_table(false, lstrSelectionCriteron);
Kevin Rocard7f265822012-12-07 18:51:22 +0100363 }
364
Kevin Rocard2fbe6e82013-03-26 17:09:29 +0100365 // Subsystem can not ask for resync as they have not been synced yet
366 getSystemClass()->cleanSubsystemsNeedToResync();
367
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100368 // At initialization, check subsystems that need resync
369 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200370
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200371 // Start remote processor server if appropriate
372 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200373}
374
375bool CParameterMgr::loadFrameworkConfiguration(string& strError)
376{
377 CAutoLog autoLog(this, "Loading framework configuration");
378
Patrick Benavoli68a91282011-08-31 11:23:23 +0200379 // Parse Structure XML file
380 CXmlElementSerializingContext elementSerializingContext(strError);
381
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100382 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200383
384 return false;
385 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100386 // Set class name to system class and configurable domains
387 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
388 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
389
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100390 // Get subsystem plugins elements
391 _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200392
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100393 if (!_pSubsystemPlugins) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200394
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100395 strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
Patrick Benavoli68a91282011-08-31 11:23:23 +0200396
397 return false;
398 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200399
Patrick Benavoli68a91282011-08-31 11:23:23 +0200400 // Log tuning availability
Kevin Rocardace81f82012-12-11 16:19:17 +0100401 log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200402
403 return true;
404}
405
406bool CParameterMgr::loadStructure(string& strError)
407{
408 // Retrieve system to load structure to
409 CSystemClass* pSystemClass = getSystemClass();
410
Kevin Rocarde25ee792013-04-22 17:46:28 +0200411 log_info("Loading " + pSystemClass->getName() + " system class structure");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200412
413 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100414 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200415
416 if (!pStructureDescriptionFileLocation) {
417
418 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
419
420 return false;
421 }
422
423 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100424 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200425
426 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100427 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200428
429 // Parse Structure XML file
430 CXmlParameterSerializingContext parameterBuildContext(strError);
431
Kevin Rocard57096bd2012-11-30 11:24:20 +0100432 CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200433
Patrick Benavoli68a91282011-08-31 11:23:23 +0200434 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
435
436 return false;
437 }
438
439 // Initialize offsets
440 pSystemClass->setOffset(0);
441
442 // Initialize main blackboard's size
443 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
444
445 return true;
446}
447
448bool CParameterMgr::loadSettings(string& strError)
449{
450 CAutoLog autoLog(this, "Loading settings");
451
452 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100453 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200454
455 if (!pParameterConfigurationGroup) {
456
457 // No settings to load
458
459 return true;
460 }
461 // Get binary settings file location
462 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
463
464 string strXmlBinarySettingsFilePath;
465
466 if (pBinarySettingsFileLocation) {
467
468 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100469 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200470 }
471
472 // Get configurable domains element
473 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
474
475 if (!pConfigurableDomainsFileLocation) {
476
477 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
478
479 return false;
480 }
481 // Get destination root element
482 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
483
484 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100485 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200486
487 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100488 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200489
490 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
491 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
492
493 // Selection criteria definition for rule creation
494 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
495
Patrick Benavoli63499d42011-10-24 18:50:03 +0200496 // Auto validation of configurations if no binary settings provided
497 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
498
Kevin Rocardace81f82012-12-11 16:19:17 +0100499 log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200500
Patrick Benavoli68a91282011-08-31 11:23:23 +0200501 // Do parse
502 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
503
504 return false;
505 }
506 // We have loaded the whole system structure, compute checksum
507 const CSystemClass* pSystemClass = getConstSystemClass();
508 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
509
510 // Load binary settings if any provided
511 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
512
513 return false;
514 }
515
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200516 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200517}
518
519// XML parsing
520bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
521{
522 // Init serializing context
523 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
524
525 // Get Schema file associated to root element
526 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
527
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200528 CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200529
530 // Start clean
531 pRootElement->clean();
532
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200533 CXmlMemoryDocSink memorySink(pRootElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200534
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200535 if (!memorySink.process(fileDocSource, elementSerializingContext)) {
536 //Cleanup
Patrick Benavoli68a91282011-08-31 11:23:23 +0200537 pRootElement->clean();
538
539 return false;
540 }
541
Patrick Benavoli68a91282011-08-31 11:23:23 +0200542 return true;
543}
544
545// Init
546bool CParameterMgr::init(string& strError)
547{
548 return base::init(strError);
549}
550
551// Selection criteria interface
552CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
553{
554 // Propagate
555 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
556}
557
558CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
559{
560 // Propagate
561 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
562}
563
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200564// Selection criterion retrieval
565CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200566{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200567 // Propagate
568 return getSelectionCriteria()->getSelectionCriterion(strName);
569}
570
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100571// Configuration application
Kevin Rocardace81f82012-12-11 16:19:17 +0100572void CParameterMgr::applyConfigurations()
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200573{
574 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200575
576 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100577 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200578
579 if (!_bTuningModeIsOn) {
580
581 // Apply configuration(s)
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100582 doApplyConfigurations(false);
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +0200583 } else {
584
Kevin Rocardace81f82012-12-11 16:19:17 +0100585 log_warning("Configurations were not applied because the TuningMode is on");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200586 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200587}
588
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200589// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100590CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200591{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100592 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200593
Patrick Benavoli065264a2011-11-20 15:46:41 +0100594 // Nagivate through system class
595 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
596
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100597 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100598 }
599
600 // Find element
601 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
602
603 if (!pElement) {
604
605 strError = "Path not found";
606
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100607 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100608 }
609
610 // Check found element is a parameter
611 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
612
613 if (!pConfigurableElement->isParameter()) {
614
615 // Element is not parameter
616 strError = "Not a parameter";
617
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100618 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100619 }
620
621 // Convert as parameter and return new handle
622 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200623}
624
Patrick Benavoli68a91282011-08-31 11:23:23 +0200625/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200626/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200627CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200628{
629 (void)remoteCommand;
630
Patrick Benavoli63499d42011-10-24 18:50:03 +0200631 // Show version
632 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200633
Patrick Benavoli63499d42011-10-24 18:50:03 +0200634 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200635}
636
Patrick Benavoli68a91282011-08-31 11:23:23 +0200637/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200638CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200639{
640 (void)remoteCommand;
641 // System class
642 const CSystemClass* pSystemClass = getSystemClass();
643
Patrick Benavoli68a91282011-08-31 11:23:23 +0200644 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200645 /// General section
646 appendTitle(strResult, "General:");
647 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200648 strResult += "System Class: ";
649 strResult += pSystemClass->getName();
650 strResult += "\n";
651
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200652 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200653 strResult += "Tuning Mode: ";
654 strResult += tuningModeOn() ? "on" : "off";
655 strResult += "\n";
656
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200657 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200658 strResult += "Value Space: ";
659 strResult += valueSpaceIsRaw() ? "raw" : "real";
660 strResult += "\n";
661
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200662 // Output raw format
663 strResult += "Output Raw Format: ";
664 strResult += outputRawFormatIsHex() ? "hex" : "dec";
665 strResult += "\n";
666
667 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200668 strResult += "Auto Sync: ";
669 strResult += autoSyncOn() ? "on" : "off";
670 strResult += "\n";
671
672 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200673 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200674 string strSubsystemList;
675 pSystemClass->listChildrenPaths(strSubsystemList);
676 strResult += strSubsystemList;
677
678 /// Last applied configurations
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200679 appendTitle(strResult, "Last Applied [Pending] Configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200680 string strLastAppliedConfigurations;
681 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
682 strResult += strLastAppliedConfigurations;
683
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200684 /// Criteria states
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200685 appendTitle(strResult, "Selection Criteria:");
Kevin Rocard7f265822012-12-07 18:51:22 +0100686 list<string> lstrSelectionCriteria;
687 getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true);
688 // Concatenate the criterion list as the command result
689 CUtility::concatenate(lstrSelectionCriteria, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200690
Patrick Benavoli63499d42011-10-24 18:50:03 +0200691 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200692}
693
694/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200695CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200696{
697 if (remoteCommand.getArgument(0) == "on") {
698
699 if (setTuningMode(true, strResult)) {
700
Patrick Benavoli63499d42011-10-24 18:50:03 +0200701 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200702 }
703 } else if (remoteCommand.getArgument(0) == "off") {
704
705 if (setTuningMode(false, strResult)) {
706
Patrick Benavoli63499d42011-10-24 18:50:03 +0200707 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200708 }
709 } else {
710 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200711 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200712 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200713 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200714}
715
Patrick Benavoli63499d42011-10-24 18:50:03 +0200716CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200717{
718 (void)remoteCommand;
719
720 strResult = tuningModeOn() ? "on" : "off";
721
Patrick Benavoli63499d42011-10-24 18:50:03 +0200722 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200723}
724
725/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200726CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200727{
728 (void)strResult;
729
730 if (remoteCommand.getArgument(0) == "raw") {
731
732 setValueSpace(true);
733
Patrick Benavoli63499d42011-10-24 18:50:03 +0200734 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200735
736 } else if (remoteCommand.getArgument(0) == "real") {
737
738 setValueSpace(false);
739
Patrick Benavoli63499d42011-10-24 18:50:03 +0200740 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200741
742 } else {
743 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200744 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200745 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200746 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200747}
748
Patrick Benavoli63499d42011-10-24 18:50:03 +0200749CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200750{
751 (void)remoteCommand;
752
753 strResult = valueSpaceIsRaw() ? "raw" : "real";
754
Patrick Benavoli63499d42011-10-24 18:50:03 +0200755 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200756}
757
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200758/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200759CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200760{
761 (void)strResult;
762
763 if (remoteCommand.getArgument(0) == "hex") {
764
765 setOutputRawFormat(true);
766
Patrick Benavoli63499d42011-10-24 18:50:03 +0200767 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200768
769 } else if (remoteCommand.getArgument(0) == "dec") {
770
771 setOutputRawFormat(false);
772
Patrick Benavoli63499d42011-10-24 18:50:03 +0200773 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200774
775 } else {
776 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200777 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200778 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200779 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200780}
781
Patrick Benavoli63499d42011-10-24 18:50:03 +0200782CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200783{
784 (void)remoteCommand;
785
786 strResult = outputRawFormatIsHex() ? "hex" : "dec";
787
Patrick Benavoli63499d42011-10-24 18:50:03 +0200788 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200789}
790
Patrick Benavoli68a91282011-08-31 11:23:23 +0200791/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200792CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200793{
794 if (remoteCommand.getArgument(0) == "on") {
795
796 if (setAutoSync(true, strResult)) {
797
Patrick Benavoli63499d42011-10-24 18:50:03 +0200798 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200799 }
800 } else if (remoteCommand.getArgument(0) == "off") {
801
802 if (setAutoSync(false, strResult)) {
803
Patrick Benavoli63499d42011-10-24 18:50:03 +0200804 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200805 }
806 } else {
807 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200808 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200809 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200810 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200811}
812
Patrick Benavoli63499d42011-10-24 18:50:03 +0200813CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200814{
815 (void)remoteCommand;
816
817 strResult = autoSyncOn() ? "on" : "off";
818
Patrick Benavoli63499d42011-10-24 18:50:03 +0200819 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200820}
821
Patrick Benavoli63499d42011-10-24 18:50:03 +0200822CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200823{
824 (void)remoteCommand;
825
Patrick Benavoli63499d42011-10-24 18:50:03 +0200826 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200827}
828
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200829/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200830CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200831{
832 (void)remoteCommand;
833
Kevin Rocard4eae8272013-04-18 19:12:46 +0200834 bool humanReadable = true;
Kevin Rocard7f265822012-12-07 18:51:22 +0100835
Kevin Rocard4eae8272013-04-18 19:12:46 +0200836 // Look for optional arguments
837 if (remoteCommand.getArgumentCount() >= 1) {
838
839 // If csv is provided, format the criterion list in Commas Separated Value pairs
840 if (remoteCommand.getArgument(0) == "csv") {
841 humanReadable = false;
842 } else {
843 return CCommandHandler::EShowUsage;
844 }
845 }
846
847 list<string> lstrResult;
848 getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
Kevin Rocard7f265822012-12-07 18:51:22 +0100849
850 // Concatenate the criterion list as the command result
851 CUtility::concatenate(lstrResult, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200852
Patrick Benavoli63499d42011-10-24 18:50:03 +0200853 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200854}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200855
856/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200857CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200858{
859 (void)remoteCommand;
860
Patrick Benavoli63499d42011-10-24 18:50:03 +0200861 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200862
Patrick Benavoli63499d42011-10-24 18:50:03 +0200863 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200864}
865
Patrick Benavoli63499d42011-10-24 18:50:03 +0200866CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200867{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200868 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200869}
870
Patrick Benavoli63499d42011-10-24 18:50:03 +0200871CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200872{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200873 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200874}
875
Kevin Rocard170f0a42012-06-18 13:56:05 +0200876CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
877{
878 (void)remoteCommand;
879
880 return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
881}
882
Patrick Benavoli63499d42011-10-24 18:50:03 +0200883CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200884{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200885 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200886}
887
Patrick Benavoli63499d42011-10-24 18:50:03 +0200888CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200889{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200890 // Check tuning mode
891 if (!checkTuningModeOn(strResult)) {
892
893 return CCommandHandler::EFailed;
894 }
895
896 // Set property
897 bool bSequenceAware;
898
899 if (remoteCommand.getArgument(1) == "true") {
900
901 bSequenceAware = true;
902
903 } else if (remoteCommand.getArgument(1) == "false") {
904
905 bSequenceAware = false;
906
907 } else {
908 // Show usage
909 return CCommandHandler::EShowUsage;
910 }
911
912 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200913}
914
Patrick Benavoli63499d42011-10-24 18:50:03 +0200915CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200916{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200917 // Get property
918 bool bSequenceAware;
919
920 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
921
922 return CCommandHandler::EFailed;
923 }
924
925 strResult = bSequenceAware ? "true" : "false";
926
927 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200928}
929
Patrick Benavoli63499d42011-10-24 18:50:03 +0200930CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200931{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200932 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200933}
934
Patrick Benavoli63499d42011-10-24 18:50:03 +0200935CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200936{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200937 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
938}
939
940CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
941{
942 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
943}
944
945CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
946{
947 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200948}
949
950/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200951CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200952{
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100953 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
954}
955
956CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
957{
958 (void)remoteCommand;
959
960 // Dummy error context
961 string strError;
962 CErrorContext errorContext(strError);
963
964 // Dump
965 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
966
967 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200968}
969
Patrick Benavoli63499d42011-10-24 18:50:03 +0200970CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200971{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200972 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200973}
974
Patrick Benavoli63499d42011-10-24 18:50:03 +0200975CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200976{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200977 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200978}
979
Patrick Benavoli63499d42011-10-24 18:50:03 +0200980CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200981{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200982 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200983}
984
Patrick Benavoli63499d42011-10-24 18:50:03 +0200985CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200986{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200987 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200988}
989
Patrick Benavoli63499d42011-10-24 18:50:03 +0200990CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200991{
Kevin Rocardace81f82012-12-11 16:19:17 +0100992 list<string> lstrResult;
993 if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) {
994 //Concatenate the error list as the command result
995 CUtility::concatenate(lstrResult, strResult);
996
997 return CCommandHandler::EFailed;
998 }
999 return CCommandHandler::EDone;
Patrick Benavoli63499d42011-10-24 18:50:03 +02001000}
1001
1002CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1003{
1004 // Check tuning mode
1005 if (!checkTuningModeOn(strResult)) {
1006
1007 return CCommandHandler::EFailed;
1008 }
1009
1010 // Build configurable element path list
1011 vector<string> astrNewElementSequence;
1012
1013 uint32_t uiArgument;
1014
1015 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1016
1017 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1018 }
1019
1020 // Delegate to configurable domains
1021 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1022}
1023
1024CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1025{
1026 // Delegate to configurable domains
1027 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001028}
1029
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001030CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1031{
1032 // Delegate to configurable domains
1033 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1034}
1035
1036CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1037{
1038 // Delegate to configurable domains
1039 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1040}
1041
1042CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1043{
1044 // Delegate to configurable domains
1045 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1046}
1047
Patrick Benavoli68a91282011-08-31 11:23:23 +02001048/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001049CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001050{
1051 CElementLocator elementLocator(getSystemClass(), false);
1052
1053 CElement* pLocatedElement = NULL;
1054
1055 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1056
Patrick Benavoli63499d42011-10-24 18:50:03 +02001057 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001058 }
1059
1060 strResult = string("\n");
1061
1062 if (!pLocatedElement) {
1063
1064 // List from root folder
1065
1066 // Return system class qualified name
1067 pLocatedElement = getSystemClass();
1068 }
1069
1070 // Return sub-elements
1071 strResult += pLocatedElement->listQualifiedPaths(false);
1072
Patrick Benavoli63499d42011-10-24 18:50:03 +02001073 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001074}
1075
1076/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001077CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001078{
1079 CElementLocator elementLocator(getSystemClass(), false);
1080
1081 CElement* pLocatedElement = NULL;
1082
1083 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1084
Patrick Benavoli63499d42011-10-24 18:50:03 +02001085 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001086 }
1087
1088 strResult = string("\n");
1089
1090 if (!pLocatedElement) {
1091
1092 // List from root folder
1093
1094 // Return system class qualified name
1095 pLocatedElement = getSystemClass();
1096 }
1097
1098 // Return sub-elements
1099 strResult += pLocatedElement->listQualifiedPaths(true);
1100
Patrick Benavoli63499d42011-10-24 18:50:03 +02001101 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001102}
1103
Patrick Benavoli63499d42011-10-24 18:50:03 +02001104CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001105{
1106 CElementLocator elementLocator(getSystemClass());
1107
1108 CElement* pLocatedElement = NULL;
1109
1110 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1111
Patrick Benavoli63499d42011-10-24 18:50:03 +02001112 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001113 }
1114
1115 string strError;
1116
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001117 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001118
1119 // Dump elements
1120 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1121
Patrick Benavoli63499d42011-10-24 18:50:03 +02001122 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001123}
1124
Patrick Benavoli63499d42011-10-24 18:50:03 +02001125CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001126{
1127 CElementLocator elementLocator(getSystemClass());
1128
1129 CElement* pLocatedElement = NULL;
1130
1131 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1132
Patrick Benavoli63499d42011-10-24 18:50:03 +02001133 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001134 }
1135
1136 // Converted to actual sizable element
1137 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1138
1139 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001140 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001141
Patrick Benavoli63499d42011-10-24 18:50:03 +02001142 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001143}
1144
Patrick Benavoli63499d42011-10-24 18:50:03 +02001145CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001146{
1147 CElementLocator elementLocator(getSystemClass());
1148
1149 CElement* pLocatedElement = NULL;
1150
1151 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1152
Patrick Benavoli63499d42011-10-24 18:50:03 +02001153 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001154 }
1155
1156 // Convert element
1157 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1158
1159 // Return element properties
1160 pConfigurableElement->showProperties(strResult);
1161
Patrick Benavoli63499d42011-10-24 18:50:03 +02001162 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001163}
1164
Patrick Benavoli63499d42011-10-24 18:50:03 +02001165CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001166{
1167 string strValue;
1168
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001169 if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001170
Patrick Benavoli63499d42011-10-24 18:50:03 +02001171 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001172 }
1173 // Succeeded
1174 strResult = strValue;
1175
Patrick Benavoli63499d42011-10-24 18:50:03 +02001176 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001177}
1178
Patrick Benavoli63499d42011-10-24 18:50:03 +02001179CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001180{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001181 // Check tuning mode
1182 if (!checkTuningModeOn(strResult)) {
1183
1184 return CCommandHandler::EFailed;
1185 }
1186 // Get value to set
1187 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1188
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001189 return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001190}
1191
Patrick Benavoli63499d42011-10-24 18:50:03 +02001192CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001193{
1194 CElementLocator elementLocator(getSystemClass());
1195
1196 CElement* pLocatedElement = NULL;
1197
1198 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1199
Patrick Benavoli63499d42011-10-24 18:50:03 +02001200 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001201 }
1202
1203 // Convert element
1204 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1205
1206 // Return element belonging domains
1207 pConfigurableElement->listBelongingDomains(strResult);
1208
Patrick Benavoli63499d42011-10-24 18:50:03 +02001209 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001210}
1211
Patrick Benavoli63499d42011-10-24 18:50:03 +02001212CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001213{
1214 CElementLocator elementLocator(getSystemClass());
1215
1216 CElement* pLocatedElement = NULL;
1217
1218 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1219
Patrick Benavoli63499d42011-10-24 18:50:03 +02001220 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001221 }
1222
1223 // Convert element
1224 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1225
1226 // Return element belonging domains
1227 pConfigurableElement->listAssociatedDomains(strResult);
1228
Patrick Benavoli63499d42011-10-24 18:50:03 +02001229 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001230}
1231
Patrick Benavoli63499d42011-10-24 18:50:03 +02001232CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001233{
1234 (void)remoteCommand;
1235
1236 getConfigurableDomains()->listAssociatedElements(strResult);
1237
Patrick Benavoli63499d42011-10-24 18:50:03 +02001238 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001239}
1240
Patrick Benavoli63499d42011-10-24 18:50:03 +02001241CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001242{
1243 (void)remoteCommand;
1244
1245 getConfigurableDomains()->listConflictingElements(strResult);
1246
Patrick Benavoli63499d42011-10-24 18:50:03 +02001247 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001248}
1249
Patrick Benavoli63499d42011-10-24 18:50:03 +02001250CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001251{
1252 (void)remoteCommand;
1253
1254 getSystemClass()->listRogueElements(strResult);
1255
Patrick Benavoli63499d42011-10-24 18:50:03 +02001256 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001257}
1258
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001259CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1260{
1261 string strOutputValue;
1262 string strError;
1263
1264 if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
1265
1266 strResult = strError;
1267 return CCommandHandler::EFailed;
1268 }
1269 // Succeeded
1270 strResult = strOutputValue;
1271
1272 return CCommandHandler::ESucceeded;
1273}
1274
1275CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1276{
1277 // Get value to set
1278 string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
1279
1280 bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
1281 remoteCommand.getArgument(1),
1282 remoteCommand.getArgument(2),
1283 strValue, true, strResult);
1284
1285 return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
1286}
1287
Patrick Benavoli68a91282011-08-31 11:23:23 +02001288/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001289CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001290{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001291 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001292}
1293
Patrick Benavoli63499d42011-10-24 18:50:03 +02001294CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001295{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001296 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001297}
1298
Patrick Benavoli63499d42011-10-24 18:50:03 +02001299CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001300{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001301 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001302}
1303
Patrick Benavoli63499d42011-10-24 18:50:03 +02001304CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001305{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001306 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001307}
1308
Patrick Benavoli63499d42011-10-24 18:50:03 +02001309CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001310{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001311 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001312}
1313
Patrick Benavoli63499d42011-10-24 18:50:03 +02001314CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001315{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001316 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001317}
1318
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001319/// GUI commands
1320
1321CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getDomainsXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1322{
1323 (void)remoteCommand;
1324
1325 if (!getDomainsXMLString(strResult, true)) {
1326
1327 return CCommandHandler::EFailed;
1328 }
1329 // Succeeded
1330 return CCommandHandler::ESucceeded;
1331}
1332
1333CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSystemClassXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1334{
1335 (void)remoteCommand;
1336
1337 if (!getSystemClassXMLString(strResult)) {
1338
1339 return CCommandHandler::EFailed;
1340 }
1341 // Succeeded
1342 return CCommandHandler::ESucceeded;
1343}
1344
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001345// User set/get parameters in main BlackBoard
1346bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
1347{
1348 // Define context
1349 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
1350
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001351 // Activate the auto synchronization with the hardware
1352 if (bSet) {
1353
1354 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1355 }
1356
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001357 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1358}
1359
1360// User set/get parameters in specific Configuration BlackBoard
1361bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
1362{
1363 CElementLocator elementLocator(getSystemClass());
1364
1365 CElement* pLocatedElement = NULL;
1366
1367 if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
1368
1369 return false;
1370 }
1371
1372 // Convert element
1373 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1374
1375 // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
1376 uint32_t uiBaseOffset;
1377 bool bIsLastApplied;
1378
1379 CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
1380
1381 if (!pConfigurationBlackboard) {
1382
1383 return false;
1384 }
1385
1386 log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
1387
1388 /// Update the Configuration Blackboard
1389
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001390 // Define Configuration context using Base Offset and keep Auto Sync off to prevent access to HW
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001391 CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
1392
1393 // Access Value in the Configuration Blackboard
1394 if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
1395
1396 return false;
1397 }
1398
1399 /// If the Configuration is the last one applied, update the Main Blackboard as well
1400
1401 if (bIsLastApplied) {
1402
1403 // Define Main context
1404 parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
1405
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001406 // Activate the auto synchronization with the hardware
1407 if (bSet) {
1408
1409 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1410 }
1411
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001412 // Access Value in the Main Blackboard
1413 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1414 }
1415
1416 return true;
1417}
1418
Patrick Benavoli68a91282011-08-31 11:23:23 +02001419// User set/get parameters
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001420bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001421{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001422 // Lock state
1423 CAutoLock autoLock(&_blackboardMutex);
1424
1425 CPathNavigator pathNavigator(strPath);
1426
1427 // Nagivate through system class
1428 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001429
1430 return false;
1431 }
1432
Patrick Benavoli065264a2011-11-20 15:46:41 +01001433 // Do the get
1434 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001435}
1436
1437// Tuning mode
1438bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1439{
1440 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001441 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001442
1443 strError = "Tuning prohibited";
1444
1445 return false;
1446 }
1447 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001448 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001449
1450 // Warn domains about exiting tuning mode
1451 if (!bOn && _bTuningModeIsOn) {
1452
1453 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001454 // Force-apply configurations
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01001455 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001456
Patrick Benavoli68a91282011-08-31 11:23:23 +02001457 // Turn auto sync back on
1458 _bAutoSyncOn = true;
1459 }
1460
1461 // Store
1462 _bTuningModeIsOn = bOn;
1463
Patrick Benavoli68a91282011-08-31 11:23:23 +02001464 return true;
1465}
1466
1467bool CParameterMgr::tuningModeOn() const
1468{
1469 return _bTuningModeIsOn;
1470}
1471
1472// Current value space for user set/get value interpretation
1473void CParameterMgr::setValueSpace(bool bIsRaw)
1474{
1475 _bValueSpaceIsRaw = bIsRaw;
1476}
1477
1478bool CParameterMgr::valueSpaceIsRaw()
1479{
1480 return _bValueSpaceIsRaw;
1481}
1482
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001483// Current Output Raw Format for user get value interpretation
1484void CParameterMgr::setOutputRawFormat(bool bIsHex)
1485{
1486 _bOutputRawFormatIsHex = bIsHex;
1487}
1488
1489bool CParameterMgr::outputRawFormatIsHex()
1490{
1491 return _bOutputRawFormatIsHex;
1492}
1493
Patrick Benavoli68a91282011-08-31 11:23:23 +02001494/// Sync
1495// Automatic hardware synchronization control (during tuning session)
1496bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1497{
1498 // Check tuning mode
1499 if (!checkTuningModeOn(strError)) {
1500
1501 return false;
1502 }
1503 // Warn domains about turning auto sync back on
1504 if (bAutoSyncOn && !_bAutoSyncOn) {
1505
Patrick Benavoli592ae562011-09-05 16:53:58 +02001506 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1507 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001508
1509 return false;
1510 }
1511 }
1512
1513 // Set Auto sync
1514 _bAutoSyncOn = bAutoSyncOn;
1515
1516 return true;
1517}
1518
1519bool CParameterMgr::autoSyncOn() const
1520{
1521 return _bAutoSyncOn;
1522}
1523
1524// Manual hardware synchronization control (during tuning session)
1525bool CParameterMgr::sync(string& strError)
1526{
1527 // Check tuning mode
1528 if (!checkTuningModeOn(strError)) {
1529
1530 return false;
1531 }
1532 // Warn domains about turning auto sync back on
1533 if (_bAutoSyncOn) {
1534
1535 strError = "Feature unavailable when Auto Sync is on";
1536
1537 return false;
1538 }
1539
1540 // Get syncer set
1541 CSyncerSet syncerSet;
1542 // ... from system class
1543 getConstSystemClass()->fillSyncerSet(syncerSet);
Kevin Rocardace81f82012-12-11 16:19:17 +01001544
Patrick Benavoli68a91282011-08-31 11:23:23 +02001545 // Sync
Kevin Rocardace81f82012-12-11 16:19:17 +01001546 list<string> lstrError;
1547 if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){
1548
1549 CUtility::concatenate(lstrError, strError);
1550 return false;
1551 };
1552
1553 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001554}
1555
1556// Content dump
1557void CParameterMgr::logStructureContent(string& strContent) const
1558{
1559 string strError;
1560
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001561 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001562
1563 dumpContent(strContent, parameterAccessContext);
1564}
1565
1566// Configuration/Domains handling
1567bool CParameterMgr::createDomain(const string& strName, string& strError)
1568{
1569 // Check tuning mode
1570 if (!checkTuningModeOn(strError)) {
1571
1572 return false;
1573 }
1574
1575 // Delegate to configurable domains
1576 return getConfigurableDomains()->createDomain(strName, strError);
1577}
1578
1579bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1580{
1581 // Check tuning mode
1582 if (!checkTuningModeOn(strError)) {
1583
1584 return false;
1585 }
1586
1587 // Delegate to configurable domains
1588 return getConfigurableDomains()->deleteDomain(strName, strError);
1589}
1590
Kevin Rocard170f0a42012-06-18 13:56:05 +02001591bool CParameterMgr::deleteAllDomains(string& strError)
1592{
1593 // Check tuning mode
1594 if (!checkTuningModeOn(strError)) {
1595
1596 return false;
1597 }
1598
1599 // Delegate to configurable domains
1600 getConfigurableDomains()->deleteAllDomains();
1601
1602 return true;
1603}
1604
Patrick Benavoli68a91282011-08-31 11:23:23 +02001605bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1606{
1607 // Check tuning mode
1608 if (!checkTuningModeOn(strError)) {
1609
1610 return false;
1611 }
1612
1613 // Delegate to configurable domains
1614 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1615}
1616
1617bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1618{
1619 // Check tuning mode
1620 if (!checkTuningModeOn(strError)) {
1621
1622 return false;
1623 }
1624
1625 // Delegate to configurable domains
1626 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1627}
1628
Kevin Rocardace81f82012-12-11 16:19:17 +01001629bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001630{
Kevin Rocardace81f82012-12-11 16:19:17 +01001631 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001632 // Check tuning mode
1633 if (!checkTuningModeOn(strError)) {
1634
Kevin Rocardace81f82012-12-11 16:19:17 +01001635 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001636 return false;
1637 }
1638
1639 // Delegate to configurable domains
Kevin Rocardace81f82012-12-11 16:19:17 +01001640 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001641}
1642
1643bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1644{
1645 // Check tuning mode
1646 if (!checkTuningModeOn(strError)) {
1647
1648 return false;
1649 }
1650
1651 // Delegate to configurable domains
1652 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1653}
1654
1655// Configurable element - domain association
1656bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1657{
1658 // Check tuning mode
1659 if (!checkTuningModeOn(strError)) {
1660
1661 return false;
1662 }
1663
1664 CElementLocator elementLocator(getSystemClass());
1665
1666 CElement* pLocatedElement = NULL;
1667
1668 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1669
1670 return false;
1671 }
1672
1673 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001674 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001675
1676 // Delegate
1677 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1678}
1679
1680bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1681{
1682 // Check tuning mode
1683 if (!checkTuningModeOn(strError)) {
1684
1685 return false;
1686 }
1687
1688 CElementLocator elementLocator(getSystemClass());
1689
1690 CElement* pLocatedElement = NULL;
1691
1692 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1693
Patrick Benavoli63499d42011-10-24 18:50:03 +02001694 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001695 }
1696
1697 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001698 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001699
1700 // Delegate
1701 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1702}
1703
1704bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1705{
1706 // Check tuning mode
1707 if (!checkTuningModeOn(strError)) {
1708
1709 return false;
1710 }
1711
1712 CElementLocator elementLocator(getSystemClass());
1713
1714 CElement* pLocatedElement = NULL;
1715
1716 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1717
Patrick Benavoli63499d42011-10-24 18:50:03 +02001718 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001719 }
1720
1721 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001722 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001723
1724 // Delegate
1725 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1726}
1727
1728// XML Import/Export
1729bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1730{
1731 // Check tuning mode
1732 if (!checkTuningModeOn(strError)) {
1733
1734 return false;
1735 }
1736
1737 // check path is absolute
1738 if (strFileName[0] != '/') {
1739
1740 strError = "Please provide absolute path";
1741
1742 return false;
1743 }
1744 // Root element
1745 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1746
1747 // Context
1748 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1749
1750 // Secltion criteria definition for rule creation
1751 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1752
1753 // Parse
1754 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1755
1756 return false;
1757 }
1758
1759 // Validate domains after XML import
1760 pConfigurableDomains->validate(_pMainParameterBlackboard);
1761
1762 return true;
1763}
1764
1765bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1766{
1767 // check path is absolute
1768 if (strFileName[0] != '/') {
1769
1770 strError = "Please provide absolute path";
1771
1772 return false;
1773 }
1774
1775 // Root element
1776 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1777
1778 // Get Schema file associated to root element
1779 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1780
1781 // Context
1782 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1783
1784 // Value space
1785 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1786
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001787 // Output raw format
1788 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1789
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001790 // Use a doc source by loading data from instantiated Configurable Domains
1791 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001792
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001793 // Use a doc sink to write the doc data in a file
1794 CXmlFileDocSink fileSink(strFileName);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001795
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001796 if (!fileSink.process(memorySource, xmlDomainSerializingContext)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001797 return false;
1798 }
1799
1800 return true;
1801}
1802
1803// Binary Import/Export
1804bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1805{
1806 // Check tuning mode
1807 if (!checkTuningModeOn(strError)) {
1808
1809 return false;
1810 }
1811 // check path is absolute
1812 if (strFileName[0] != '/') {
1813
1814 strError = "Please provide absolute path";
1815
1816 return false;
1817 }
1818 // Root element
1819 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1820
1821 // Serialize in
1822 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1823}
1824
1825bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1826{
1827 // check path is absolute
1828 if (strFileName[0] != '/') {
1829
1830 strError = "Please provide absolute path";
1831
1832 return false;
1833 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001834
Patrick Benavoli68a91282011-08-31 11:23:23 +02001835 // Root element
1836 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1837
1838 // Serialize out
1839 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1840}
1841
1842// For tuning, check we're in tuning mode
1843bool CParameterMgr::checkTuningModeOn(string& strError) const
1844{
1845 // Tuning Mode on?
1846 if (!_bTuningModeIsOn) {
1847
1848 strError = "Tuning Mode must be on";
1849
1850 return false;
1851 }
1852 return true;
1853}
1854
Patrick Benavoli065264a2011-11-20 15:46:41 +01001855// Tuning mutex dynamic parameter handling
1856pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001857{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001858 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001859}
1860
Patrick Benavoli065264a2011-11-20 15:46:41 +01001861// Blackboard reference (dynamic parameter handling)
1862CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001863{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001864 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001865}
1866
Patrick Benavoli68a91282011-08-31 11:23:23 +02001867// Dynamic creation library feeding
1868void CParameterMgr::feedElementLibraries()
1869{
1870 // Global Configuration handling
1871 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1872
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001873 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +01001874 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins"));
1875 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001876 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1877 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1878 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1879 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001880
1881 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1882
1883 // Parameter creation
1884 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1885
1886 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001887 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1888 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1889 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1890 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001891 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001892 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1893 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1894 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01001895 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02001896 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli68808c62012-02-02 17:12:41 +01001897 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001898 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1899 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001900
1901 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1902
1903 // Parameter Configuration Domains creation
1904 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1905
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001906 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1907 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1908 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1909 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001910
1911 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1912}
1913
1914// Remote Processor Server connection handling
1915bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1916{
1917 CAutoLog autoLog(this, "Handling remote processing interface");
1918
1919 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001920 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001921
Kevin Rocardace81f82012-12-11 16:19:17 +01001922 log_info("Loading remote processor library");
Patrick Benavoli68a91282011-08-31 11:23:23 +02001923
1924 // Load library
1925 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
1926
1927 if (!lib_handle) {
1928
1929 // Return error
1930 const char* pcError = dlerror();
1931
1932 if (pcError) {
1933
1934 strError = pcError;
1935 } else {
1936
1937 strError = "Unable to load libremote-processor.so library";
1938 }
1939
1940 return false;
1941 }
1942
1943 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
1944
1945 if (!pfnCreateRemoteProcessorServer) {
1946
1947 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
1948
1949 return false;
1950 }
1951
1952 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001953 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001954
Kevin Rocardace81f82012-12-11 16:19:17 +01001955 log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001956 // Start
1957 if (!_pRemoteProcessorServer->start()) {
1958
1959 strError = "Unable to start remote processor server";
1960
1961 return false;
1962 }
1963 }
1964
1965 return true;
1966}
1967
1968// Back synchronization
Kevin Rocardace81f82012-12-11 16:19:17 +01001969CBackSynchronizer* CParameterMgr::createBackSynchronizer() const
Patrick Benavoli68a91282011-08-31 11:23:23 +02001970{
1971#ifdef SIMULATION
1972 // In simulation, back synchronization of the blackboard won't probably work
1973 // We need to ensure though the blackboard is initialized with valid data
Kevin Rocardace81f82012-12-11 16:19:17 +01001974 return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001975#else
1976 // Real back synchronizer from subsystems
Kevin Rocardace81f82012-12-11 16:19:17 +01001977 return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001978#endif
1979}
1980
1981// Children typwise access
1982CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
1983{
1984 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
1985}
1986
1987const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
1988{
1989 return getFrameworkConfiguration();
1990}
1991
1992CSelectionCriteria* CParameterMgr::getSelectionCriteria()
1993{
1994 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
1995}
1996
1997const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
1998{
1999 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
2000}
2001
2002CSystemClass* CParameterMgr::getSystemClass()
2003{
2004 return static_cast<CSystemClass*>(getChild(ESystemClass));
2005}
2006
2007const CSystemClass* CParameterMgr::getConstSystemClass() const
2008{
2009 return static_cast<const CSystemClass*>(getChild(ESystemClass));
2010}
2011
2012// Configurable Domains
2013CConfigurableDomains* CParameterMgr::getConfigurableDomains()
2014{
2015 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
2016}
2017
2018const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
2019{
2020 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2021}
2022
2023const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
2024{
2025 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2026}
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002027
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002028// Apply configurations
2029void CParameterMgr::doApplyConfigurations(bool bForce)
2030{
2031 CSyncerSet syncerSet;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002032
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002033 // Check subsystems that need resync
2034 getSystemClass()->checkForSubsystemsToResync(syncerSet);
2035
2036 // Ensure application of currently selected configurations
2037 getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
2038
2039 // Reset the modified status of the current criteria to indicate that a new configuration has been applied
2040 getSelectionCriteria()->resetModifiedStatus();
2041}
2042
2043/// GUI commands functions
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002044bool CParameterMgr::getDomainsXMLString(string& strResult, bool bWithSettings)
2045{
2046
2047 // Root element
2048 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
2049
2050 // Get Schema file associated to root element
2051 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
2052
2053 string strError;
2054
2055 // Context
2056 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
2057
2058 // Value space
2059 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
2060
2061 // Output raw format
2062 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
2063
2064 // Use a doc source by loading data from instantiated Configurable Domains
2065 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion());
2066
2067 // Use a doc sink the write the doc data in a string
2068 CXmlStringDocSink stringSink(strResult);
2069
2070 if (!stringSink.process(memorySource, xmlDomainSerializingContext)) {
2071 strResult = strError;
2072
2073 return false;
2074 }
2075
2076 return true;
2077}
2078
2079bool CParameterMgr::getSystemClassXMLString(string& strResult)
2080{
2081 // Root element
2082 const CSystemClass* pSystemClass = getSystemClass();
2083
2084 string strError;
2085
2086 CXmlSerializingContext xmlSerializingContext(strError);
2087
2088 // Use a doc source by loading data from instantiated Configurable Domains
2089 CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind());
2090
2091 // Use a doc sink that write the doc data in a string
2092 CXmlStringDocSink stringSink(strResult);
2093
2094 if (!stringSink.process(memorySource, xmlSerializingContext)) {
2095 strResult = strError;
2096 return false;
2097 }
2098
2099 return true;
2100}