blob: 4003753853dd87bff6435fd16277eaaab259f263 [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[] = {
Kevin Rocard3949b342013-05-24 18:43:53 +0200108
Patrick Benavoli592ae562011-09-05 16:53:58 +0200109 /// Version
Kevin Rocard3949b342013-05-24 18:43:53 +0200110 { "version", &CParameterMgr::versionCommandProcess, 0,
111 "", "Show version" },
112
Patrick Benavoli68a91282011-08-31 11:23:23 +0200113 /// Status
Kevin Rocard3949b342013-05-24 18:43:53 +0200114 { "status", &CParameterMgr::statusCommandProcess, 0, "",
115 "Show current status" },
116
Patrick Benavoli68a91282011-08-31 11:23:23 +0200117 /// Tuning Mode
Kevin Rocard3949b342013-05-24 18:43:53 +0200118 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1,
119 "on|off*", "Turn on or off Tuning Mode" },
120 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0,
121 "", "Show Tuning Mode" },
122
Patrick Benavoli68a91282011-08-31 11:23:23 +0200123 /// Value Space
Kevin Rocard3949b342013-05-24 18:43:53 +0200124 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1,
125 "raw|real*", "Assigns Value Space used for parameter value interpretation" },
126 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0,
127 "", "Show Value Space" },
128
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200129 /// Output Raw Format
Kevin Rocard3949b342013-05-24 18:43:53 +0200130 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1,
131 "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
132 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0,
133 "", "Show Output Raw Format" },
134
Patrick Benavoli68a91282011-08-31 11:23:23 +0200135 /// Sync
Kevin Rocard3949b342013-05-24 18:43:53 +0200136 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1,
137 "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
138 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0,
139 "", "Show Auto Sync state" },
140 { "sync", &CParameterMgr::syncCommmandProcess, 0,
141 "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
142
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200143 /// Criteria
Kevin Rocard3949b342013-05-24 18:43:53 +0200144 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0,
145 "[csv]", "List selection criteria" },
146
Patrick Benavoli68a91282011-08-31 11:23:23 +0200147 /// Domains
Kevin Rocard3949b342013-05-24 18:43:53 +0200148 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0,
149 "", "List configurable domains" },
150 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0,
151 "", "Show all domains and configurations, including applicability conditions" },
152 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1,
153 "<domain>", "Create new configurable domain" },
154 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1,
155 "<domain>", "Delete configurable domain" },
156 { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0,
157 "", "Delete all configurable domains" },
158 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2,
159 "<domain> <new name>", "Rename configurable domain" },
160 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1,
161 "<domain> true|false*", "Set configurable domain sequence awareness" },
162 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1,
163 "<domain>", "Get configurable domain sequence awareness" },
164 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1,
165 "<domain>", "List elements associated to configurable domain" },
166 { "addElement", &CParameterMgr::addElementCommmandProcess, 2,
167 "<domain> <elem path>", "Associate element at given path to configurable domain" },
168 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2,
169 "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
170 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2,
171 "<domain> <elem path>", "Split configurable domain at given associated element path" },
172
Patrick Benavoli68a91282011-08-31 11:23:23 +0200173 /// Configurations
Kevin Rocard3949b342013-05-24 18:43:53 +0200174 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1,
175 "<domain>", "List domain configurations" },
176 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2,
177 "<domain> <configuration>", "Create new domain configuration" },
178 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2,
179 "<domain> <configuration>", "Delete domain configuration" },
180 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3,
181 "<domain> <configuration> <new name>", "Rename domain configuration" },
182 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2,
183 "<domain> <configuration>", "Save current settings into configuration" },
184 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2,
185 "<domain> <configuration>", "Restore current settings from configuration" },
186 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3,
187 "<domain> <configuration> <elem path list>",
188 "Set element application order for configuration" },
189 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2,
190 "<domain> <configuration>", "Get element application order for configuration" },
191 { "setRule", &CParameterMgr::setRuleCommmandProcess, 3,
192 "<domain> <configuration> <rule>", "Set configuration application rule" },
193 { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2,
194 "<domain> <configuration>", "Clear configuration application rule" },
195 { "getRule", &CParameterMgr::getRuleCommmandProcess, 2,
196 "<domain> <configuration>", "Get configuration application rule" },
197
Patrick Benavoli68a91282011-08-31 11:23:23 +0200198 /// Elements/Parameters
Kevin Rocard3949b342013-05-24 18:43:53 +0200199 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1,
200 "<elem path>|/", "List elements under element at given path or root" },
201 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1,
202 "<elem path>|/", "List parameters under element at given path or root" },
203 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1,
204 "<elem path>", "Dump structure and content of element at given path" },
205 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1,
206 "<elem path>", "Show size of element at given path" },
207 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1,
208 "<elem path>", "Show properties of element at given path" },
209 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1,
210 "<param path>", "Get value for parameter at given path" },
211 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2,
212 "<param path> <value>", "Set value for parameter at given path" },
213 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1,
214 "<elem path>", "List domain(s) element at given path belongs to" },
215 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1,
216 "<elem path>", "List domain(s) element at given path is associated to" },
217 { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3,
218 "<domain> <configuration> <param path>",
219 "Get value for parameter at given path from configuration" },
220 { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4,
221 "<domain> <configuration> <param path> <value>",
222 "Set value for parameter at given path to configuration" },
223
Patrick Benavoli68a91282011-08-31 11:23:23 +0200224 /// Browse
Kevin Rocard3949b342013-05-24 18:43:53 +0200225 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0,
226 "", "List element sub-trees associated to at least one configurable domain" },
227 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0,
228 "", "List element sub-trees contained in more than one configurable domain" },
229 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0,
230 "", "List element sub-trees owned by no configurable domain" },
231
Patrick Benavoli68a91282011-08-31 11:23:23 +0200232 /// Settings Import/Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200233 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1,
234 "<file path> ", "Export domains to XML file" },
235 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1,
236 "<file path>", "Import domains from XML file" },
237 { "exportDomainsWithSettingsXML",
238 &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1,
239 "<file path> ", "Export domains including settings to XML file" },
240 { "importDomainsWithSettingsXML",
241 &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1,
242 "<file path>", "Import domains including settings from XML file" },
243 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1,
244 "<file path>", "Export settings to binary file" },
245 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1,
246 "<file path>", "Import settings from binary file" },
247 { "getDomainsXML", &CParameterMgr::getDomainsXMLCommmandProcess, 0 ,
248 "", "Print domains including settings as XML" },
249
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200250 /// Structure Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200251 { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,
252 "", "Print parameter structure as XML" }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200253};
Kevin Rocard3949b342013-05-24 18:43:53 +0200254
Patrick Benavoli68a91282011-08-31 11:23:23 +0200255// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200256const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200257
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100258CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200259 _bTuningModeIsOn(false),
260 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200261 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200262 _bAutoSyncOn(true),
263 _pMainParameterBlackboard(new CParameterBlackboard),
264 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100265 _strXmlConfigurationFilePath(strConfigurationFilePath),
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100266 _pSubsystemPlugins(NULL),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200267 _uiStructureChecksum(0),
268 _pRemoteProcessorServer(NULL),
269 _uiMaxCommandUsageLength(0),
270 _pLogger(NULL),
271 _uiLogDepth(0)
272{
273 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100274 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
275 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200276
277 // Deal with children
278 addChild(new CParameterFrameworkConfiguration);
279 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100280 addChild(new CSystemClass);
281 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200282
283 // Feed element library
284 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200285
286 _pCommandHandler = new CCommandHandler(this);
287
288 // Add command parsers
289 uint32_t uiRemoteCommandParserItem;
290
291 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
292
293 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
294
295 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
296 pRemoteCommandParserItem->_pfnParser,
297 pRemoteCommandParserItem->_uiMinArgumentCount,
298 pRemoteCommandParserItem->_pcHelp,
299 pRemoteCommandParserItem->_pcDescription);
300 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100301
302 // Configuration file folder
303 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
304
305 assert(uiSlashPos != (uint32_t)-1);
306
307 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
308
309 // Schema absolute folder location
310 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200311}
312
313CParameterMgr::~CParameterMgr()
314{
315 // Children
316 delete _pRemoteProcessorServer;
Frederic Boisnard31242302012-04-26 17:07:34 +0200317 delete _pCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200318 delete _pMainParameterBlackboard;
319 delete _pElementLibrarySet;
320
321 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100322 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200323}
324
325string CParameterMgr::getKind() const
326{
327 return "ParameterMgr";
328}
329
330// Logging
331void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
332{
333 _pLogger = pLogger;
334}
335
336// Logging
Kevin Rocardace81f82012-12-11 16:19:17 +0100337void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200338{
339 if (_pLogger) {
340
341 // Nest
342 string strIndent;
343
344 // Level
345 uint32_t uiNbIndents = _uiLogDepth;
346
347 while (uiNbIndents--) {
348
349 strIndent += " ";
350 }
351
352 // Log
Kevin Rocardace81f82012-12-11 16:19:17 +0100353 _pLogger->log(bIsWarning, strIndent + strLog);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200354 }
355}
356
357void CParameterMgr::nestLog() const
358{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200359 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200360}
361
362void CParameterMgr::unnestLog() const
363{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200364 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200365}
366
Patrick Benavoli63499d42011-10-24 18:50:03 +0200367// Version
368string CParameterMgr::getVersion() const
369{
370 string strVersion;
371
372 // Major
373 strVersion = toString(guiEditionMajor) + ".";
374 // Minor
375 strVersion += toString(guiEditionMinor) + ".";
376 // Revision
377 strVersion += toString(guiRevision);
378
379 return strVersion;
380}
381
Patrick Benavoli68a91282011-08-31 11:23:23 +0200382bool CParameterMgr::load(string& strError)
383{
384 CAutoLog autoLog(this, "Loading");
385
386 // Load Framework configuration
387 if (!loadFrameworkConfiguration(strError)) {
388
389 return false;
390 }
391
392 // Load subsystems
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100393 if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200394
395 return false;
396 }
397
398 // Load structure
399 if (!loadStructure(strError)) {
400
401 return false;
402 }
403
404 // Load settings
405 if (!loadSettings(strError)) {
406
407 return false;
408 }
409
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200410 // Back synchronization for areas in parameter blackboard not covered by any domain
Kevin Rocardace81f82012-12-11 16:19:17 +0100411 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200412
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200413 // Back-synchronize
Kevin Rocard57096bd2012-11-30 11:24:20 +0100414 {
415 CAutoLog autoLog(this, "Main blackboard back synchronization");
416
Kevin Rocard5d6e05a2013-01-21 15:57:45 +0100417 pBackSynchronizer->sync();
Kevin Rocard57096bd2012-11-30 11:24:20 +0100418
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200419 // Get rid of back synchronizer
420 delete pBackSynchronizer;
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200421 }
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200422
423 // We're done loading the settings and back synchronizing
424 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
425
426 // We need to ensure all domains are valid
427 pConfigurableDomains->validate(_pMainParameterBlackboard);
428
Kevin Rocard7f265822012-12-07 18:51:22 +0100429 // Log selection criterion states
430 {
431 CAutoLog autoLog(this, "Criterion states");
432
433 const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria();
434
435 list<string> lstrSelectionCriteron;
436 selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false);
437
Kevin Rocard36299362013-02-04 14:57:47 +0100438 log_table(false, lstrSelectionCriteron);
Kevin Rocard7f265822012-12-07 18:51:22 +0100439 }
440
Kevin Rocard2fbe6e82013-03-26 17:09:29 +0100441 // Subsystem can not ask for resync as they have not been synced yet
442 getSystemClass()->cleanSubsystemsNeedToResync();
443
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100444 // At initialization, check subsystems that need resync
445 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200446
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200447 // Start remote processor server if appropriate
448 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200449}
450
451bool CParameterMgr::loadFrameworkConfiguration(string& strError)
452{
453 CAutoLog autoLog(this, "Loading framework configuration");
454
Patrick Benavoli68a91282011-08-31 11:23:23 +0200455 // Parse Structure XML file
456 CXmlElementSerializingContext elementSerializingContext(strError);
457
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100458 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200459
460 return false;
461 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100462 // Set class name to system class and configurable domains
463 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
464 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
465
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100466 // Get subsystem plugins elements
467 _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200468
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100469 if (!_pSubsystemPlugins) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200470
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100471 strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
Patrick Benavoli68a91282011-08-31 11:23:23 +0200472
473 return false;
474 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200475
Patrick Benavoli68a91282011-08-31 11:23:23 +0200476 // Log tuning availability
Kevin Rocardace81f82012-12-11 16:19:17 +0100477 log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200478
479 return true;
480}
481
482bool CParameterMgr::loadStructure(string& strError)
483{
484 // Retrieve system to load structure to
485 CSystemClass* pSystemClass = getSystemClass();
486
Kevin Rocarde25ee792013-04-22 17:46:28 +0200487 log_info("Loading " + pSystemClass->getName() + " system class structure");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200488
489 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100490 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200491
492 if (!pStructureDescriptionFileLocation) {
493
494 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
495
496 return false;
497 }
498
499 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100500 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200501
502 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100503 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200504
505 // Parse Structure XML file
506 CXmlParameterSerializingContext parameterBuildContext(strError);
507
Kevin Rocard57096bd2012-11-30 11:24:20 +0100508 CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200509
Patrick Benavoli68a91282011-08-31 11:23:23 +0200510 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
511
512 return false;
513 }
514
515 // Initialize offsets
516 pSystemClass->setOffset(0);
517
518 // Initialize main blackboard's size
519 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
520
521 return true;
522}
523
524bool CParameterMgr::loadSettings(string& strError)
525{
526 CAutoLog autoLog(this, "Loading settings");
527
528 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100529 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200530
531 if (!pParameterConfigurationGroup) {
532
533 // No settings to load
534
535 return true;
536 }
537 // Get binary settings file location
538 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
539
540 string strXmlBinarySettingsFilePath;
541
542 if (pBinarySettingsFileLocation) {
543
544 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100545 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200546 }
547
548 // Get configurable domains element
549 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
550
551 if (!pConfigurableDomainsFileLocation) {
552
553 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
554
555 return false;
556 }
557 // Get destination root element
558 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
559
560 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100561 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200562
563 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100564 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200565
566 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
567 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
568
569 // Selection criteria definition for rule creation
570 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
571
Patrick Benavoli63499d42011-10-24 18:50:03 +0200572 // Auto validation of configurations if no binary settings provided
573 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
574
Kevin Rocardace81f82012-12-11 16:19:17 +0100575 log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200576
Patrick Benavoli68a91282011-08-31 11:23:23 +0200577 // Do parse
578 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
579
580 return false;
581 }
582 // We have loaded the whole system structure, compute checksum
583 const CSystemClass* pSystemClass = getConstSystemClass();
584 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
585
586 // Load binary settings if any provided
587 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
588
589 return false;
590 }
591
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200592 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200593}
594
595// XML parsing
596bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
597{
598 // Init serializing context
599 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
600
601 // Get Schema file associated to root element
602 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
603
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200604 CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200605
606 // Start clean
607 pRootElement->clean();
608
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200609 CXmlMemoryDocSink memorySink(pRootElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200610
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200611 if (!memorySink.process(fileDocSource, elementSerializingContext)) {
612 //Cleanup
Patrick Benavoli68a91282011-08-31 11:23:23 +0200613 pRootElement->clean();
614
615 return false;
616 }
617
Patrick Benavoli68a91282011-08-31 11:23:23 +0200618 return true;
619}
620
621// Init
622bool CParameterMgr::init(string& strError)
623{
624 return base::init(strError);
625}
626
627// Selection criteria interface
628CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
629{
630 // Propagate
631 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
632}
633
634CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
635{
636 // Propagate
637 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
638}
639
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200640// Selection criterion retrieval
641CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200642{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200643 // Propagate
644 return getSelectionCriteria()->getSelectionCriterion(strName);
645}
646
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100647// Configuration application
Kevin Rocardace81f82012-12-11 16:19:17 +0100648void CParameterMgr::applyConfigurations()
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200649{
650 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200651
652 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100653 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200654
655 if (!_bTuningModeIsOn) {
656
657 // Apply configuration(s)
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100658 doApplyConfigurations(false);
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +0200659 } else {
660
Kevin Rocardace81f82012-12-11 16:19:17 +0100661 log_warning("Configurations were not applied because the TuningMode is on");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200662 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200663}
664
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200665// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100666CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200667{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100668 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200669
Patrick Benavoli065264a2011-11-20 15:46:41 +0100670 // Nagivate through system class
671 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
672
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100673 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100674 }
675
676 // Find element
677 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
678
679 if (!pElement) {
680
681 strError = "Path not found";
682
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100683 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100684 }
685
686 // Check found element is a parameter
687 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
688
689 if (!pConfigurableElement->isParameter()) {
690
691 // Element is not parameter
692 strError = "Not a parameter";
693
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100694 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100695 }
696
697 // Convert as parameter and return new handle
698 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200699}
700
Patrick Benavoli68a91282011-08-31 11:23:23 +0200701/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200702/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200703CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200704{
705 (void)remoteCommand;
706
Patrick Benavoli63499d42011-10-24 18:50:03 +0200707 // Show version
708 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200709
Patrick Benavoli63499d42011-10-24 18:50:03 +0200710 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200711}
712
Patrick Benavoli68a91282011-08-31 11:23:23 +0200713/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200714CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200715{
716 (void)remoteCommand;
717 // System class
718 const CSystemClass* pSystemClass = getSystemClass();
719
Patrick Benavoli68a91282011-08-31 11:23:23 +0200720 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200721 /// General section
722 appendTitle(strResult, "General:");
723 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200724 strResult += "System Class: ";
725 strResult += pSystemClass->getName();
726 strResult += "\n";
727
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200728 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200729 strResult += "Tuning Mode: ";
730 strResult += tuningModeOn() ? "on" : "off";
731 strResult += "\n";
732
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200733 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200734 strResult += "Value Space: ";
735 strResult += valueSpaceIsRaw() ? "raw" : "real";
736 strResult += "\n";
737
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200738 // Output raw format
739 strResult += "Output Raw Format: ";
740 strResult += outputRawFormatIsHex() ? "hex" : "dec";
741 strResult += "\n";
742
743 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200744 strResult += "Auto Sync: ";
745 strResult += autoSyncOn() ? "on" : "off";
746 strResult += "\n";
747
748 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200749 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200750 string strSubsystemList;
751 pSystemClass->listChildrenPaths(strSubsystemList);
752 strResult += strSubsystemList;
753
754 /// Last applied configurations
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200755 appendTitle(strResult, "Last Applied [Pending] Configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200756 string strLastAppliedConfigurations;
757 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
758 strResult += strLastAppliedConfigurations;
759
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200760 /// Criteria states
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200761 appendTitle(strResult, "Selection Criteria:");
Kevin Rocard7f265822012-12-07 18:51:22 +0100762 list<string> lstrSelectionCriteria;
763 getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true);
764 // Concatenate the criterion list as the command result
765 CUtility::concatenate(lstrSelectionCriteria, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200766
Patrick Benavoli63499d42011-10-24 18:50:03 +0200767 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200768}
769
770/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200771CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200772{
773 if (remoteCommand.getArgument(0) == "on") {
774
775 if (setTuningMode(true, strResult)) {
776
Patrick Benavoli63499d42011-10-24 18:50:03 +0200777 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200778 }
779 } else if (remoteCommand.getArgument(0) == "off") {
780
781 if (setTuningMode(false, strResult)) {
782
Patrick Benavoli63499d42011-10-24 18:50:03 +0200783 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200784 }
785 } else {
786 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200787 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200788 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200789 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200790}
791
Patrick Benavoli63499d42011-10-24 18:50:03 +0200792CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200793{
794 (void)remoteCommand;
795
796 strResult = tuningModeOn() ? "on" : "off";
797
Patrick Benavoli63499d42011-10-24 18:50:03 +0200798 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200799}
800
801/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200802CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200803{
804 (void)strResult;
805
806 if (remoteCommand.getArgument(0) == "raw") {
807
808 setValueSpace(true);
809
Patrick Benavoli63499d42011-10-24 18:50:03 +0200810 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200811
812 } else if (remoteCommand.getArgument(0) == "real") {
813
814 setValueSpace(false);
815
Patrick Benavoli63499d42011-10-24 18:50:03 +0200816 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200817
818 } else {
819 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200820 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200821 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200822 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200823}
824
Patrick Benavoli63499d42011-10-24 18:50:03 +0200825CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200826{
827 (void)remoteCommand;
828
829 strResult = valueSpaceIsRaw() ? "raw" : "real";
830
Patrick Benavoli63499d42011-10-24 18:50:03 +0200831 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200832}
833
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200834/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200835CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200836{
837 (void)strResult;
838
839 if (remoteCommand.getArgument(0) == "hex") {
840
841 setOutputRawFormat(true);
842
Patrick Benavoli63499d42011-10-24 18:50:03 +0200843 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200844
845 } else if (remoteCommand.getArgument(0) == "dec") {
846
847 setOutputRawFormat(false);
848
Patrick Benavoli63499d42011-10-24 18:50:03 +0200849 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200850
851 } else {
852 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200853 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200854 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200855 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200856}
857
Patrick Benavoli63499d42011-10-24 18:50:03 +0200858CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200859{
860 (void)remoteCommand;
861
862 strResult = outputRawFormatIsHex() ? "hex" : "dec";
863
Patrick Benavoli63499d42011-10-24 18:50:03 +0200864 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200865}
866
Patrick Benavoli68a91282011-08-31 11:23:23 +0200867/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200868CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200869{
870 if (remoteCommand.getArgument(0) == "on") {
871
872 if (setAutoSync(true, strResult)) {
873
Patrick Benavoli63499d42011-10-24 18:50:03 +0200874 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200875 }
876 } else if (remoteCommand.getArgument(0) == "off") {
877
878 if (setAutoSync(false, strResult)) {
879
Patrick Benavoli63499d42011-10-24 18:50:03 +0200880 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200881 }
882 } else {
883 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200884 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200885 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200886 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200887}
888
Patrick Benavoli63499d42011-10-24 18:50:03 +0200889CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200890{
891 (void)remoteCommand;
892
893 strResult = autoSyncOn() ? "on" : "off";
894
Patrick Benavoli63499d42011-10-24 18:50:03 +0200895 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200896}
897
Patrick Benavoli63499d42011-10-24 18:50:03 +0200898CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200899{
900 (void)remoteCommand;
901
Patrick Benavoli63499d42011-10-24 18:50:03 +0200902 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200903}
904
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200905/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200906CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200907{
908 (void)remoteCommand;
909
Kevin Rocard4eae8272013-04-18 19:12:46 +0200910 bool humanReadable = true;
Kevin Rocard7f265822012-12-07 18:51:22 +0100911
Kevin Rocard4eae8272013-04-18 19:12:46 +0200912 // Look for optional arguments
913 if (remoteCommand.getArgumentCount() >= 1) {
914
915 // If csv is provided, format the criterion list in Commas Separated Value pairs
916 if (remoteCommand.getArgument(0) == "csv") {
917 humanReadable = false;
918 } else {
919 return CCommandHandler::EShowUsage;
920 }
921 }
922
923 list<string> lstrResult;
924 getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
Kevin Rocard7f265822012-12-07 18:51:22 +0100925
926 // Concatenate the criterion list as the command result
927 CUtility::concatenate(lstrResult, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200928
Patrick Benavoli63499d42011-10-24 18:50:03 +0200929 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200930}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200931
932/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200933CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200934{
935 (void)remoteCommand;
936
Patrick Benavoli63499d42011-10-24 18:50:03 +0200937 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200938
Patrick Benavoli63499d42011-10-24 18:50:03 +0200939 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200940}
941
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200943{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200944 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200945}
946
Patrick Benavoli63499d42011-10-24 18:50:03 +0200947CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200948{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200949 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200950}
951
Kevin Rocard170f0a42012-06-18 13:56:05 +0200952CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
953{
954 (void)remoteCommand;
955
956 return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
957}
958
Patrick Benavoli63499d42011-10-24 18:50:03 +0200959CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200960{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200961 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200962}
963
Patrick Benavoli63499d42011-10-24 18:50:03 +0200964CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200965{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200966 // Check tuning mode
967 if (!checkTuningModeOn(strResult)) {
968
969 return CCommandHandler::EFailed;
970 }
971
972 // Set property
973 bool bSequenceAware;
974
975 if (remoteCommand.getArgument(1) == "true") {
976
977 bSequenceAware = true;
978
979 } else if (remoteCommand.getArgument(1) == "false") {
980
981 bSequenceAware = false;
982
983 } else {
984 // Show usage
985 return CCommandHandler::EShowUsage;
986 }
987
988 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200989}
990
Patrick Benavoli63499d42011-10-24 18:50:03 +0200991CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200992{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200993 // Get property
994 bool bSequenceAware;
995
996 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
997
998 return CCommandHandler::EFailed;
999 }
1000
1001 strResult = bSequenceAware ? "true" : "false";
1002
1003 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001004}
1005
Patrick Benavoli63499d42011-10-24 18:50:03 +02001006CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001007{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001008 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001009}
1010
Patrick Benavoli63499d42011-10-24 18:50:03 +02001011CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001012{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001013 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1014}
1015
1016CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1017{
1018 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1019}
1020
1021CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1022{
1023 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001024}
1025
1026/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +02001027CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001028{
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001029 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1030}
1031
1032CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1033{
1034 (void)remoteCommand;
1035
1036 // Dummy error context
1037 string strError;
1038 CErrorContext errorContext(strError);
1039
1040 // Dump
1041 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
1042
1043 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001044}
1045
Patrick Benavoli63499d42011-10-24 18:50:03 +02001046CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001047{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001048 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001049}
1050
Patrick Benavoli63499d42011-10-24 18:50:03 +02001051CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001052{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001053 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001054}
1055
Patrick Benavoli63499d42011-10-24 18:50:03 +02001056CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001057{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001058 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001059}
1060
Patrick Benavoli63499d42011-10-24 18:50:03 +02001061CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001062{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001063 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001064}
1065
Patrick Benavoli63499d42011-10-24 18:50:03 +02001066CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001067{
Kevin Rocardace81f82012-12-11 16:19:17 +01001068 list<string> lstrResult;
1069 if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) {
1070 //Concatenate the error list as the command result
1071 CUtility::concatenate(lstrResult, strResult);
1072
1073 return CCommandHandler::EFailed;
1074 }
1075 return CCommandHandler::EDone;
Patrick Benavoli63499d42011-10-24 18:50:03 +02001076}
1077
1078CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1079{
1080 // Check tuning mode
1081 if (!checkTuningModeOn(strResult)) {
1082
1083 return CCommandHandler::EFailed;
1084 }
1085
1086 // Build configurable element path list
1087 vector<string> astrNewElementSequence;
1088
1089 uint32_t uiArgument;
1090
1091 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1092
1093 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1094 }
1095
1096 // Delegate to configurable domains
1097 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1098}
1099
1100CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1101{
1102 // Delegate to configurable domains
1103 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001104}
1105
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001106CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1107{
1108 // Delegate to configurable domains
1109 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1110}
1111
1112CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1113{
1114 // Delegate to configurable domains
1115 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1116}
1117
1118CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1119{
1120 // Delegate to configurable domains
1121 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1122}
1123
Patrick Benavoli68a91282011-08-31 11:23:23 +02001124/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001125CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001126{
1127 CElementLocator elementLocator(getSystemClass(), false);
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 strResult = string("\n");
1137
1138 if (!pLocatedElement) {
1139
1140 // List from root folder
1141
1142 // Return system class qualified name
1143 pLocatedElement = getSystemClass();
1144 }
1145
1146 // Return sub-elements
1147 strResult += pLocatedElement->listQualifiedPaths(false);
1148
Patrick Benavoli63499d42011-10-24 18:50:03 +02001149 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001150}
1151
1152/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001153CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001154{
1155 CElementLocator elementLocator(getSystemClass(), false);
1156
1157 CElement* pLocatedElement = NULL;
1158
1159 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1160
Patrick Benavoli63499d42011-10-24 18:50:03 +02001161 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001162 }
1163
1164 strResult = string("\n");
1165
1166 if (!pLocatedElement) {
1167
1168 // List from root folder
1169
1170 // Return system class qualified name
1171 pLocatedElement = getSystemClass();
1172 }
1173
1174 // Return sub-elements
1175 strResult += pLocatedElement->listQualifiedPaths(true);
1176
Patrick Benavoli63499d42011-10-24 18:50:03 +02001177 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001178}
1179
Patrick Benavoli63499d42011-10-24 18:50:03 +02001180CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001181{
1182 CElementLocator elementLocator(getSystemClass());
1183
1184 CElement* pLocatedElement = NULL;
1185
1186 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1187
Patrick Benavoli63499d42011-10-24 18:50:03 +02001188 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001189 }
1190
1191 string strError;
1192
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001193 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001194
1195 // Dump elements
1196 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1197
Patrick Benavoli63499d42011-10-24 18:50:03 +02001198 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001199}
1200
Patrick Benavoli63499d42011-10-24 18:50:03 +02001201CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001202{
1203 CElementLocator elementLocator(getSystemClass());
1204
1205 CElement* pLocatedElement = NULL;
1206
1207 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1208
Patrick Benavoli63499d42011-10-24 18:50:03 +02001209 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001210 }
1211
1212 // Converted to actual sizable element
1213 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1214
1215 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001216 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001217
Patrick Benavoli63499d42011-10-24 18:50:03 +02001218 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001219}
1220
Patrick Benavoli63499d42011-10-24 18:50:03 +02001221CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001222{
1223 CElementLocator elementLocator(getSystemClass());
1224
1225 CElement* pLocatedElement = NULL;
1226
1227 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1228
Patrick Benavoli63499d42011-10-24 18:50:03 +02001229 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001230 }
1231
1232 // Convert element
1233 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1234
1235 // Return element properties
1236 pConfigurableElement->showProperties(strResult);
1237
Patrick Benavoli63499d42011-10-24 18:50:03 +02001238 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001239}
1240
Patrick Benavoli63499d42011-10-24 18:50:03 +02001241CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001242{
1243 string strValue;
1244
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001245 if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001246
Patrick Benavoli63499d42011-10-24 18:50:03 +02001247 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001248 }
1249 // Succeeded
1250 strResult = strValue;
1251
Patrick Benavoli63499d42011-10-24 18:50:03 +02001252 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001253}
1254
Patrick Benavoli63499d42011-10-24 18:50:03 +02001255CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001256{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001257 // Check tuning mode
1258 if (!checkTuningModeOn(strResult)) {
1259
1260 return CCommandHandler::EFailed;
1261 }
1262 // Get value to set
1263 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1264
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001265 return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001266}
1267
Patrick Benavoli63499d42011-10-24 18:50:03 +02001268CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001269{
1270 CElementLocator elementLocator(getSystemClass());
1271
1272 CElement* pLocatedElement = NULL;
1273
1274 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1275
Patrick Benavoli63499d42011-10-24 18:50:03 +02001276 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001277 }
1278
1279 // Convert element
1280 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1281
1282 // Return element belonging domains
1283 pConfigurableElement->listBelongingDomains(strResult);
1284
Patrick Benavoli63499d42011-10-24 18:50:03 +02001285 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001286}
1287
Patrick Benavoli63499d42011-10-24 18:50:03 +02001288CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001289{
1290 CElementLocator elementLocator(getSystemClass());
1291
1292 CElement* pLocatedElement = NULL;
1293
1294 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1295
Patrick Benavoli63499d42011-10-24 18:50:03 +02001296 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001297 }
1298
1299 // Convert element
1300 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1301
1302 // Return element belonging domains
1303 pConfigurableElement->listAssociatedDomains(strResult);
1304
Patrick Benavoli63499d42011-10-24 18:50:03 +02001305 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001306}
1307
Patrick Benavoli63499d42011-10-24 18:50:03 +02001308CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001309{
1310 (void)remoteCommand;
1311
1312 getConfigurableDomains()->listAssociatedElements(strResult);
1313
Patrick Benavoli63499d42011-10-24 18:50:03 +02001314 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001315}
1316
Patrick Benavoli63499d42011-10-24 18:50:03 +02001317CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001318{
1319 (void)remoteCommand;
1320
1321 getConfigurableDomains()->listConflictingElements(strResult);
1322
Patrick Benavoli63499d42011-10-24 18:50:03 +02001323 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001324}
1325
Patrick Benavoli63499d42011-10-24 18:50:03 +02001326CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001327{
1328 (void)remoteCommand;
1329
1330 getSystemClass()->listRogueElements(strResult);
1331
Patrick Benavoli63499d42011-10-24 18:50:03 +02001332 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001333}
1334
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001335CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1336{
1337 string strOutputValue;
1338 string strError;
1339
1340 if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
1341
1342 strResult = strError;
1343 return CCommandHandler::EFailed;
1344 }
1345 // Succeeded
1346 strResult = strOutputValue;
1347
1348 return CCommandHandler::ESucceeded;
1349}
1350
1351CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1352{
1353 // Get value to set
1354 string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
1355
1356 bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
1357 remoteCommand.getArgument(1),
1358 remoteCommand.getArgument(2),
1359 strValue, true, strResult);
1360
1361 return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
1362}
1363
Patrick Benavoli68a91282011-08-31 11:23:23 +02001364/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001365CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001366{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001367 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001368}
1369
Patrick Benavoli63499d42011-10-24 18:50:03 +02001370CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001371{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001372 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001373}
1374
Patrick Benavoli63499d42011-10-24 18:50:03 +02001375CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001376{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001377 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001378}
1379
Patrick Benavoli63499d42011-10-24 18:50:03 +02001380CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001381{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001382 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001383}
1384
Patrick Benavoli63499d42011-10-24 18:50:03 +02001385CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001386{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001387 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001388}
1389
Patrick Benavoli63499d42011-10-24 18:50:03 +02001390CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001391{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001392 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001393}
1394
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001395/// GUI commands
1396
1397CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getDomainsXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1398{
1399 (void)remoteCommand;
1400
1401 if (!getDomainsXMLString(strResult, true)) {
1402
1403 return CCommandHandler::EFailed;
1404 }
1405 // Succeeded
1406 return CCommandHandler::ESucceeded;
1407}
1408
1409CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSystemClassXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1410{
1411 (void)remoteCommand;
1412
1413 if (!getSystemClassXMLString(strResult)) {
1414
1415 return CCommandHandler::EFailed;
1416 }
1417 // Succeeded
1418 return CCommandHandler::ESucceeded;
1419}
1420
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001421// User set/get parameters in main BlackBoard
1422bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
1423{
1424 // Define context
1425 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
1426
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001427 // Activate the auto synchronization with the hardware
1428 if (bSet) {
1429
1430 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1431 }
1432
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001433 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1434}
1435
1436// User set/get parameters in specific Configuration BlackBoard
1437bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
1438{
1439 CElementLocator elementLocator(getSystemClass());
1440
1441 CElement* pLocatedElement = NULL;
1442
1443 if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
1444
1445 return false;
1446 }
1447
1448 // Convert element
1449 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1450
1451 // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
1452 uint32_t uiBaseOffset;
1453 bool bIsLastApplied;
1454
1455 CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
1456
1457 if (!pConfigurationBlackboard) {
1458
1459 return false;
1460 }
1461
1462 log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
1463
1464 /// Update the Configuration Blackboard
1465
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001466 // 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 +01001467 CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
1468
1469 // Access Value in the Configuration Blackboard
1470 if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
1471
1472 return false;
1473 }
1474
1475 /// If the Configuration is the last one applied, update the Main Blackboard as well
1476
1477 if (bIsLastApplied) {
1478
1479 // Define Main context
1480 parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
1481
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001482 // Activate the auto synchronization with the hardware
1483 if (bSet) {
1484
1485 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1486 }
1487
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001488 // Access Value in the Main Blackboard
1489 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1490 }
1491
1492 return true;
1493}
1494
Patrick Benavoli68a91282011-08-31 11:23:23 +02001495// User set/get parameters
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001496bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001497{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001498 // Lock state
1499 CAutoLock autoLock(&_blackboardMutex);
1500
1501 CPathNavigator pathNavigator(strPath);
1502
1503 // Nagivate through system class
1504 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001505
1506 return false;
1507 }
1508
Patrick Benavoli065264a2011-11-20 15:46:41 +01001509 // Do the get
1510 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001511}
1512
1513// Tuning mode
1514bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1515{
1516 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001517 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001518
1519 strError = "Tuning prohibited";
1520
1521 return false;
1522 }
1523 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001524 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001525
1526 // Warn domains about exiting tuning mode
1527 if (!bOn && _bTuningModeIsOn) {
1528
1529 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001530 // Force-apply configurations
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01001531 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001532
Patrick Benavoli68a91282011-08-31 11:23:23 +02001533 // Turn auto sync back on
1534 _bAutoSyncOn = true;
1535 }
1536
1537 // Store
1538 _bTuningModeIsOn = bOn;
1539
Patrick Benavoli68a91282011-08-31 11:23:23 +02001540 return true;
1541}
1542
1543bool CParameterMgr::tuningModeOn() const
1544{
1545 return _bTuningModeIsOn;
1546}
1547
1548// Current value space for user set/get value interpretation
1549void CParameterMgr::setValueSpace(bool bIsRaw)
1550{
1551 _bValueSpaceIsRaw = bIsRaw;
1552}
1553
1554bool CParameterMgr::valueSpaceIsRaw()
1555{
1556 return _bValueSpaceIsRaw;
1557}
1558
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001559// Current Output Raw Format for user get value interpretation
1560void CParameterMgr::setOutputRawFormat(bool bIsHex)
1561{
1562 _bOutputRawFormatIsHex = bIsHex;
1563}
1564
1565bool CParameterMgr::outputRawFormatIsHex()
1566{
1567 return _bOutputRawFormatIsHex;
1568}
1569
Patrick Benavoli68a91282011-08-31 11:23:23 +02001570/// Sync
1571// Automatic hardware synchronization control (during tuning session)
1572bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1573{
1574 // Check tuning mode
1575 if (!checkTuningModeOn(strError)) {
1576
1577 return false;
1578 }
1579 // Warn domains about turning auto sync back on
1580 if (bAutoSyncOn && !_bAutoSyncOn) {
1581
Patrick Benavoli592ae562011-09-05 16:53:58 +02001582 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1583 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001584
1585 return false;
1586 }
1587 }
1588
1589 // Set Auto sync
1590 _bAutoSyncOn = bAutoSyncOn;
1591
1592 return true;
1593}
1594
1595bool CParameterMgr::autoSyncOn() const
1596{
1597 return _bAutoSyncOn;
1598}
1599
1600// Manual hardware synchronization control (during tuning session)
1601bool CParameterMgr::sync(string& strError)
1602{
1603 // Check tuning mode
1604 if (!checkTuningModeOn(strError)) {
1605
1606 return false;
1607 }
1608 // Warn domains about turning auto sync back on
1609 if (_bAutoSyncOn) {
1610
1611 strError = "Feature unavailable when Auto Sync is on";
1612
1613 return false;
1614 }
1615
1616 // Get syncer set
1617 CSyncerSet syncerSet;
1618 // ... from system class
1619 getConstSystemClass()->fillSyncerSet(syncerSet);
Kevin Rocardace81f82012-12-11 16:19:17 +01001620
Patrick Benavoli68a91282011-08-31 11:23:23 +02001621 // Sync
Kevin Rocardace81f82012-12-11 16:19:17 +01001622 list<string> lstrError;
1623 if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){
1624
1625 CUtility::concatenate(lstrError, strError);
1626 return false;
1627 };
1628
1629 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001630}
1631
1632// Content dump
1633void CParameterMgr::logStructureContent(string& strContent) const
1634{
1635 string strError;
1636
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001637 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001638
1639 dumpContent(strContent, parameterAccessContext);
1640}
1641
1642// Configuration/Domains handling
1643bool CParameterMgr::createDomain(const string& strName, 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()->createDomain(strName, strError);
1653}
1654
1655bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1656{
1657 // Check tuning mode
1658 if (!checkTuningModeOn(strError)) {
1659
1660 return false;
1661 }
1662
1663 // Delegate to configurable domains
1664 return getConfigurableDomains()->deleteDomain(strName, strError);
1665}
1666
Kevin Rocard170f0a42012-06-18 13:56:05 +02001667bool CParameterMgr::deleteAllDomains(string& strError)
1668{
1669 // Check tuning mode
1670 if (!checkTuningModeOn(strError)) {
1671
1672 return false;
1673 }
1674
1675 // Delegate to configurable domains
1676 getConfigurableDomains()->deleteAllDomains();
1677
1678 return true;
1679}
1680
Patrick Benavoli68a91282011-08-31 11:23:23 +02001681bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1682{
1683 // Check tuning mode
1684 if (!checkTuningModeOn(strError)) {
1685
1686 return false;
1687 }
1688
1689 // Delegate to configurable domains
1690 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1691}
1692
1693bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1694{
1695 // Check tuning mode
1696 if (!checkTuningModeOn(strError)) {
1697
1698 return false;
1699 }
1700
1701 // Delegate to configurable domains
1702 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1703}
1704
Kevin Rocardace81f82012-12-11 16:19:17 +01001705bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001706{
Kevin Rocardace81f82012-12-11 16:19:17 +01001707 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001708 // Check tuning mode
1709 if (!checkTuningModeOn(strError)) {
1710
Kevin Rocardace81f82012-12-11 16:19:17 +01001711 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001712 return false;
1713 }
1714
1715 // Delegate to configurable domains
Kevin Rocardace81f82012-12-11 16:19:17 +01001716 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001717}
1718
1719bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1720{
1721 // Check tuning mode
1722 if (!checkTuningModeOn(strError)) {
1723
1724 return false;
1725 }
1726
1727 // Delegate to configurable domains
1728 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1729}
1730
1731// Configurable element - domain association
1732bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1733{
1734 // Check tuning mode
1735 if (!checkTuningModeOn(strError)) {
1736
1737 return false;
1738 }
1739
1740 CElementLocator elementLocator(getSystemClass());
1741
1742 CElement* pLocatedElement = NULL;
1743
1744 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1745
1746 return false;
1747 }
1748
1749 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001750 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001751
1752 // Delegate
1753 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1754}
1755
1756bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1757{
1758 // Check tuning mode
1759 if (!checkTuningModeOn(strError)) {
1760
1761 return false;
1762 }
1763
1764 CElementLocator elementLocator(getSystemClass());
1765
1766 CElement* pLocatedElement = NULL;
1767
1768 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1769
Patrick Benavoli63499d42011-10-24 18:50:03 +02001770 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001771 }
1772
1773 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001774 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001775
1776 // Delegate
1777 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1778}
1779
1780bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1781{
1782 // Check tuning mode
1783 if (!checkTuningModeOn(strError)) {
1784
1785 return false;
1786 }
1787
1788 CElementLocator elementLocator(getSystemClass());
1789
1790 CElement* pLocatedElement = NULL;
1791
1792 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1793
Patrick Benavoli63499d42011-10-24 18:50:03 +02001794 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001795 }
1796
1797 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001798 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001799
1800 // Delegate
1801 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1802}
1803
1804// XML Import/Export
1805bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1806{
1807 // Check tuning mode
1808 if (!checkTuningModeOn(strError)) {
1809
1810 return false;
1811 }
1812
1813 // check path is absolute
1814 if (strFileName[0] != '/') {
1815
1816 strError = "Please provide absolute path";
1817
1818 return false;
1819 }
1820 // Root element
1821 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1822
1823 // Context
1824 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1825
1826 // Secltion criteria definition for rule creation
1827 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1828
1829 // Parse
1830 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1831
1832 return false;
1833 }
1834
1835 // Validate domains after XML import
1836 pConfigurableDomains->validate(_pMainParameterBlackboard);
1837
1838 return true;
1839}
1840
1841bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1842{
1843 // check path is absolute
1844 if (strFileName[0] != '/') {
1845
1846 strError = "Please provide absolute path";
1847
1848 return false;
1849 }
1850
1851 // Root element
1852 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1853
1854 // Get Schema file associated to root element
1855 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1856
1857 // Context
1858 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1859
1860 // Value space
1861 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1862
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001863 // Output raw format
1864 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1865
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001866 // Use a doc source by loading data from instantiated Configurable Domains
1867 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001868
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001869 // Use a doc sink to write the doc data in a file
1870 CXmlFileDocSink fileSink(strFileName);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001871
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001872 if (!fileSink.process(memorySource, xmlDomainSerializingContext)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001873 return false;
1874 }
1875
1876 return true;
1877}
1878
1879// Binary Import/Export
1880bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1881{
1882 // Check tuning mode
1883 if (!checkTuningModeOn(strError)) {
1884
1885 return false;
1886 }
1887 // check path is absolute
1888 if (strFileName[0] != '/') {
1889
1890 strError = "Please provide absolute path";
1891
1892 return false;
1893 }
1894 // Root element
1895 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1896
1897 // Serialize in
1898 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1899}
1900
1901bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1902{
1903 // check path is absolute
1904 if (strFileName[0] != '/') {
1905
1906 strError = "Please provide absolute path";
1907
1908 return false;
1909 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001910
Patrick Benavoli68a91282011-08-31 11:23:23 +02001911 // Root element
1912 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1913
1914 // Serialize out
1915 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1916}
1917
1918// For tuning, check we're in tuning mode
1919bool CParameterMgr::checkTuningModeOn(string& strError) const
1920{
1921 // Tuning Mode on?
1922 if (!_bTuningModeIsOn) {
1923
1924 strError = "Tuning Mode must be on";
1925
1926 return false;
1927 }
1928 return true;
1929}
1930
Patrick Benavoli065264a2011-11-20 15:46:41 +01001931// Tuning mutex dynamic parameter handling
1932pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001933{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001934 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001935}
1936
Patrick Benavoli065264a2011-11-20 15:46:41 +01001937// Blackboard reference (dynamic parameter handling)
1938CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001939{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001940 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001941}
1942
Patrick Benavoli68a91282011-08-31 11:23:23 +02001943// Dynamic creation library feeding
1944void CParameterMgr::feedElementLibraries()
1945{
1946 // Global Configuration handling
1947 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1948
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001949 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +01001950 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins"));
1951 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001952 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1953 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1954 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1955 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001956
1957 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1958
1959 // Parameter creation
1960 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1961
1962 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001963 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1964 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1965 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1966 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001967 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001968 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1969 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1970 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01001971 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02001972 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli68808c62012-02-02 17:12:41 +01001973 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001974 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1975 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001976
1977 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1978
1979 // Parameter Configuration Domains creation
1980 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1981
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001982 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1983 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1984 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1985 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001986
1987 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1988}
1989
1990// Remote Processor Server connection handling
1991bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1992{
1993 CAutoLog autoLog(this, "Handling remote processing interface");
1994
1995 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001996 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001997
Kevin Rocardace81f82012-12-11 16:19:17 +01001998 log_info("Loading remote processor library");
Patrick Benavoli68a91282011-08-31 11:23:23 +02001999
2000 // Load library
2001 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
2002
2003 if (!lib_handle) {
2004
2005 // Return error
2006 const char* pcError = dlerror();
2007
2008 if (pcError) {
2009
2010 strError = pcError;
2011 } else {
2012
2013 strError = "Unable to load libremote-processor.so library";
2014 }
2015
2016 return false;
2017 }
2018
2019 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
2020
2021 if (!pfnCreateRemoteProcessorServer) {
2022
2023 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
2024
2025 return false;
2026 }
2027
2028 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002029 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002030
Kevin Rocardace81f82012-12-11 16:19:17 +01002031 log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002032 // Start
2033 if (!_pRemoteProcessorServer->start()) {
2034
2035 strError = "Unable to start remote processor server";
2036
2037 return false;
2038 }
2039 }
2040
2041 return true;
2042}
2043
2044// Back synchronization
Kevin Rocardace81f82012-12-11 16:19:17 +01002045CBackSynchronizer* CParameterMgr::createBackSynchronizer() const
Patrick Benavoli68a91282011-08-31 11:23:23 +02002046{
2047#ifdef SIMULATION
2048 // In simulation, back synchronization of the blackboard won't probably work
2049 // We need to ensure though the blackboard is initialized with valid data
Kevin Rocardace81f82012-12-11 16:19:17 +01002050 return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002051#else
2052 // Real back synchronizer from subsystems
Kevin Rocardace81f82012-12-11 16:19:17 +01002053 return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002054#endif
2055}
2056
2057// Children typwise access
2058CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
2059{
2060 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
2061}
2062
2063const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
2064{
2065 return getFrameworkConfiguration();
2066}
2067
2068CSelectionCriteria* CParameterMgr::getSelectionCriteria()
2069{
2070 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
2071}
2072
2073const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
2074{
2075 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
2076}
2077
2078CSystemClass* CParameterMgr::getSystemClass()
2079{
2080 return static_cast<CSystemClass*>(getChild(ESystemClass));
2081}
2082
2083const CSystemClass* CParameterMgr::getConstSystemClass() const
2084{
2085 return static_cast<const CSystemClass*>(getChild(ESystemClass));
2086}
2087
2088// Configurable Domains
2089CConfigurableDomains* CParameterMgr::getConfigurableDomains()
2090{
2091 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
2092}
2093
2094const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
2095{
2096 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2097}
2098
2099const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
2100{
2101 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2102}
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002103
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002104// Apply configurations
2105void CParameterMgr::doApplyConfigurations(bool bForce)
2106{
2107 CSyncerSet syncerSet;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002108
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002109 // Check subsystems that need resync
2110 getSystemClass()->checkForSubsystemsToResync(syncerSet);
2111
2112 // Ensure application of currently selected configurations
2113 getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
2114
2115 // Reset the modified status of the current criteria to indicate that a new configuration has been applied
2116 getSelectionCriteria()->resetModifiedStatus();
2117}
2118
2119/// GUI commands functions
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002120bool CParameterMgr::getDomainsXMLString(string& strResult, bool bWithSettings)
2121{
2122
2123 // Root element
2124 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
2125
2126 // Get Schema file associated to root element
2127 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
2128
2129 string strError;
2130
2131 // Context
2132 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
2133
2134 // Value space
2135 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
2136
2137 // Output raw format
2138 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
2139
2140 // Use a doc source by loading data from instantiated Configurable Domains
2141 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), strXmlSchemaFilePath, "parameter-framework", getVersion());
2142
2143 // Use a doc sink the write the doc data in a string
2144 CXmlStringDocSink stringSink(strResult);
2145
2146 if (!stringSink.process(memorySource, xmlDomainSerializingContext)) {
2147 strResult = strError;
2148
2149 return false;
2150 }
2151
2152 return true;
2153}
2154
2155bool CParameterMgr::getSystemClassXMLString(string& strResult)
2156{
2157 // Root element
2158 const CSystemClass* pSystemClass = getSystemClass();
2159
2160 string strError;
2161
2162 CXmlSerializingContext xmlSerializingContext(strError);
2163
2164 // Use a doc source by loading data from instantiated Configurable Domains
2165 CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind());
2166
2167 // Use a doc sink that write the doc data in a string
2168 CXmlStringDocSink stringSink(strResult);
2169
2170 if (!stringSink.process(memorySource, xmlSerializingContext)) {
2171 strResult = strError;
2172 return false;
2173 }
2174
2175 return true;
2176}