blob: 7393dbe848b545a0c61805d342ef7372cfb0eb46 [file] [log] [blame]
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001/*
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 "ConfigurableDomain.h"
26#include "DomainConfiguration.h"
27#include "ConfigurableElement.h"
28#include "ConfigurationAccessContext.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020029#include "XmlDomainSerializingContext.h"
30#include <assert.h>
31
32#define base CBinarySerializableElement
33
Patrick Benavoli63499d42011-10-24 18:50:03 +020034CConfigurableDomain::CConfigurableDomain(const string& strName) : base(strName), _bSequenceAware(false), _pLastAppliedConfiguration(NULL)
Patrick Benavoli68a91282011-08-31 11:23:23 +020035{
36}
37
38CConfigurableDomain::~CConfigurableDomain()
39{
Patrick Benavoli63499d42011-10-24 18:50:03 +020040 // Remove all configurable elements
Patrick Benavoli68a91282011-08-31 11:23:23 +020041 ConfigurableElementListIterator it;
42
Patrick Benavoli68a91282011-08-31 11:23:23 +020043 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
44
45 CConfigurableElement* pConfigurableElement = *it;
46
47 // Remove from configurable element
48 pConfigurableElement->removeAttachedConfigurableDomain(this);
49 }
Patrick Benavoli63499d42011-10-24 18:50:03 +020050
51 // Remove all associated syncer sets
52 ConfigurableElementToSyncerSetMapIterator mapIt;
53
54 for (mapIt = _configurableElementToSyncerSetMap.begin(); mapIt != _configurableElementToSyncerSetMap.end(); ++mapIt) {
55
56 delete mapIt->second;
57 }
Patrick Benavoli68a91282011-08-31 11:23:23 +020058}
59
60string CConfigurableDomain::getKind() const
61{
62 return "ConfigurableDomain";
63}
64
65bool CConfigurableDomain::childrenAreDynamic() const
66{
67 return true;
68}
69
Patrick Benavoli0bd50542011-11-29 11:10:27 +010070// Content dumping
71void CConfigurableDomain::logValue(string& strValue, CErrorContext& errorContext) const
72{
73 (void)errorContext;
74
75 strValue = "{";
76
77 // Sequence awareness
78 strValue += "Sequence aware: ";
79 strValue += _bSequenceAware ? "yes" : "no";
80
81 // Last applied configuration
82 strValue += ", Last applied configuration: ";
83 strValue += _pLastAppliedConfiguration ? _pLastAppliedConfiguration->getName() : "<none>";
84
85 strValue += "}";
86}
87
Patrick Benavoli63499d42011-10-24 18:50:03 +020088// Sequence awareness
89void CConfigurableDomain::setSequenceAwareness(bool bSequenceAware)
90{
91 if (_bSequenceAware != bSequenceAware) {
92
Kevin Rocardace81f82012-12-11 16:19:17 +010093 log_info("Making domain \"%s\" sequence %s", getName().c_str(), bSequenceAware ? "aware" : "unaware");
Patrick Benavoli63499d42011-10-24 18:50:03 +020094
95 _bSequenceAware = bSequenceAware;
96 }
97}
98
99bool CConfigurableDomain::getSequenceAwareness() const
100{
101 return _bSequenceAware;
102}
103
Patrick Benavoli68a91282011-08-31 11:23:23 +0200104// From IXmlSource
105void CConfigurableDomain::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
106{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200107 // Sequence awareness
108 xmlElement.setAttributeBoolean("SequenceAware", _bSequenceAware);
109
Patrick Benavoli68a91282011-08-31 11:23:23 +0200110 // Configurations
111 composeDomainConfigurations(xmlElement, serializingContext);
112
113 // Configurable Elements
Patrick Benavoli63499d42011-10-24 18:50:03 +0200114 composeConfigurableElements(xmlElement);
115
116 // Settings
117 composeSettings(xmlElement, serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200118}
119
120// XML composing
121void CConfigurableDomain::composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
122{
123 // Create Configurations element
124 CXmlElement xmlConfigurationsElement;
125
126 xmlElement.createChild(xmlConfigurationsElement, "Configurations");
127
128 // Delegate to base
129 base::toXml(xmlConfigurationsElement, serializingContext);
130}
131
Patrick Benavoli63499d42011-10-24 18:50:03 +0200132void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200133{
Patrick Benavoli68a91282011-08-31 11:23:23 +0200134 // Create ConfigurableElements element
135 CXmlElement xmlConfigurableElementsElement;
136
137 xmlElement.createChild(xmlConfigurableElementsElement, "ConfigurableElements");
138
139 // Serialize out all configurable elements settings
140 ConfigurableElementListIterator it;
141
142 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
143
144 const CConfigurableElement* pConfigurableElement = *it;
145
146 // Create corresponding XML child element
147 CXmlElement xmlChildConfigurableElement;
148
149 xmlConfigurableElementsElement.createChild(xmlChildConfigurableElement, "ConfigurableElement");
150
151 // Set Path attribute
152 xmlChildConfigurableElement.setAttributeString("Path", pConfigurableElement->getPath());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200153 }
154}
155
Patrick Benavoli63499d42011-10-24 18:50:03 +0200156void CConfigurableDomain::composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200157{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200158 // Context
159 const CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<const CXmlDomainSerializingContext&>(serializingContext);
160
161 if (!xmlDomainSerializingContext.withSettings()) {
162
163 return;
164 }
165
166 // Create Settings element
167 CXmlElement xmlSettingsElement;
168
169 xmlElement.createChild(xmlSettingsElement, "Settings");
170
171 // Serialize out all configurations settings
Patrick Benavoli68a91282011-08-31 11:23:23 +0200172 uint32_t uiNbConfigurations = getNbChildren();
173 uint32_t uiChildConfiguration;
174
175 for (uiChildConfiguration = 0; uiChildConfiguration < uiNbConfigurations; uiChildConfiguration++) {
176
177 const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChildConfiguration));
178
179 // Create child xml element for that configuration
180 CXmlElement xmlConfigurationSettingsElement;
181
Patrick Benavoli63499d42011-10-24 18:50:03 +0200182 xmlSettingsElement.createChild(xmlConfigurationSettingsElement, pDomainConfiguration->getKind());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200183
184 // Set its name attribute
185 xmlConfigurationSettingsElement.setNameAttribute(pDomainConfiguration->getName());
186
Patrick Benavoli63499d42011-10-24 18:50:03 +0200187 // Serialize out configuration settings
188 pDomainConfiguration->composeSettings(xmlConfigurationSettingsElement, serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200189 }
190}
191
192// From IXmlSink
193bool CConfigurableDomain::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
194{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200195 // Context
196 CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext);
197
198 // Sequence awareness (optional)
199 _bSequenceAware = xmlElement.hasAttribute("SequenceAware") && xmlElement.getAttributeBoolean("SequenceAware");
200
Patrick Benavoli68a91282011-08-31 11:23:23 +0200201 // Local parsing. Do not dig
Patrick Benavoli63499d42011-10-24 18:50:03 +0200202 if (!parseDomainConfigurations(xmlElement, serializingContext) || !parseConfigurableElements(xmlElement, serializingContext) || !parseSettings(xmlElement, serializingContext)) {
203
204 return false;
205 }
206
207 // All provided configurations are parsed
208 // Attempt validation on areas of non provided configurations for all configurable elements if required
209 if (xmlDomainSerializingContext.autoValidationRequired()) {
210
211 autoValidateAll();
212 }
213
214 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200215}
216
217// XML parsing
218bool CConfigurableDomain::parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
219{
220 // We're supposedly clean
221 assert(_configurableElementList.empty());
222
223 // Get Configurations element
224 CXmlElement xmlConfigurationsElement;
225
226 xmlElement.getChildElement("Configurations", xmlConfigurationsElement);
227
228 // Parse it and create domain configuration objects
229 return base::fromXml(xmlConfigurationsElement, serializingContext);
230}
231
232// Parse configurable elements
233bool CConfigurableDomain::parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
234{
Patrick Benavoli68a91282011-08-31 11:23:23 +0200235 // Get System Class Element
236 CElement* pRootElement = getRoot();
237
238 CElement* pSystemClassElement = pRootElement->findChildOfKind("SystemClass");
239
240 assert(pSystemClassElement);
241
242 // Get ConfigurableElements element
243 CXmlElement xmlConfigurableElementsElement;
244 xmlElement.getChildElement("ConfigurableElements", xmlConfigurableElementsElement);
245
246 // Parse it and associate found configurable elements to it
247 CXmlElement::CChildIterator it(xmlConfigurableElementsElement);
248
249 CXmlElement xmlConfigurableElementElement;
250
251 while (it.next(xmlConfigurableElementElement)) {
252
253 // Locate configurable element
254 string strConfigurableElementPath = xmlConfigurableElementElement.getAttributeString("Path");
255
256 CPathNavigator pathNavigator(strConfigurableElementPath);
Patrick Benavoli065264a2011-11-20 15:46:41 +0100257 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200258
259 // Is there an element and does it match system class name?
Patrick Benavoli065264a2011-11-20 15:46:41 +0100260 if (!pathNavigator.navigateThrough(pSystemClassElement->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200261
Patrick Benavoli065264a2011-11-20 15:46:41 +0100262 serializingContext.setError("Could not find configurable element of path " + strConfigurableElementPath + " from ConfigurableDomain description " + getName() + " (" + strError + ")");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200263
264 return false;
265 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200266 // Browse system class for configurable element
267 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pSystemClassElement->findDescendant(pathNavigator));
268
269 if (!pConfigurableElement) {
270
271 serializingContext.setError("Could not find configurable element of path " + strConfigurableElementPath + " from ConfigurableDomain description " + getName());
272
273 return false;
274 }
275 // Add found element to domain
Patrick Benavoli68a91282011-08-31 11:23:23 +0200276 if (!addConfigurableElement(pConfigurableElement, NULL, strError)) {
277
278 serializingContext.setError(strError);
279
280 return false;
281 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200282 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200283
284 return true;
285}
286
Patrick Benavoli63499d42011-10-24 18:50:03 +0200287// Parse settings
288bool CConfigurableDomain::parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200289{
290 // Context
291 CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext);
292
Patrick Benavoli63499d42011-10-24 18:50:03 +0200293 // Check we actually need to parse configuration settings
294 if (!xmlDomainSerializingContext.withSettings()) {
295
296 // No parsing required
297 return true;
298 }
299
300 // Get Settings element
301 CXmlElement xmlSettingsElement;
302 if (!xmlElement.getChildElement("Settings", xmlSettingsElement)) {
303
304 // No settings, bail out successfully
305 return true;
306 }
307
308 // Parse configuration settings
309 CXmlElement::CChildIterator it(xmlSettingsElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200310
311 CXmlElement xmlConfigurationSettingsElement;
312
313 while (it.next(xmlConfigurationSettingsElement)) {
314 // Get domain configuration
315 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(xmlConfigurationSettingsElement.getNameAttribute()));
316
317 if (!pDomainConfiguration) {
318
Patrick Benavoli63499d42011-10-24 18:50:03 +0200319 xmlDomainSerializingContext.setError("Could not find domain configuration referred to by configurable domain " + getName());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200320
321 return false;
322 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200323 // Have domain configuration parse settings for all configurable elements
324 if (!pDomainConfiguration->parseSettings(xmlConfigurationSettingsElement, xmlDomainSerializingContext)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200325
326 return false;
327 }
328 }
329
330 return true;
331}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200332// Configurable elements association
333bool CConfigurableDomain::addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError)
334{
335 // Already associated?
336 if (containsConfigurableElement(pConfigurableElement)) {
337
338 strError = "Configurable element " + pConfigurableElement->getPath() + " already associated to configuration domain " + getName();
339
340 return false;
341 }
342
343 // Already owned?
344 if (pConfigurableElement->belongsTo(this)) {
345
346 strError = "Configurable element " + pConfigurableElement->getPath() + " already owned by configuration domain " + getName();
347
348 return false;
349 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200350
351 // Do add
Frédéric Boisnard9620e442012-05-30 16:15:02 +0200352 doAddConfigurableElement(pConfigurableElement, pMainBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200353
354 return true;
355}
356
357bool CConfigurableDomain::removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError)
358{
359 // Not associated?
360 if (!containsConfigurableElement(pConfigurableElement)) {
361
362 strError = "Configurable element " + pConfigurableElement->getPath() + " not associated to configuration domain " + getName();
363
364 return false;
365 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100366 log_info("Removing configurable element \"%s\" from domain \"%s\"", pConfigurableElement->getPath().c_str(), getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200367
368 // Do remove
369 doRemoveConfigurableElement(pConfigurableElement, true);
370
371 return true;
372}
373
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +0100374/**
375* Blackboard Configuration and Base Offset retrieval.
376*
377* This method fetches the Blackboard associated to the ConfigurableElement
378* given in parameter, for a specific Configuration. The ConfigurableElement
379* must belong to the Domain. If a Blackboard is found, the base offset of
380* the ConfigurableElement is returned as well. This base offset corresponds to
381* the offset of the ancestor of the ConfigurableElement associated to the Configuration.
382*
383* @param[in] strConfiguration Name of the Configuration.
384* @param[in] pCandidateDescendantConfigurableElement Pointer to a CConfigurableElement that
385* belongs to the Domain.
386* @param[out] uiBaseOffset The base offset of the CConfigurableElement.
387* @param[out] bIsLastApplied Boolean indicating that the Configuration is
388* the last one applied of the Domain.
389* @param[out] strError Error message
390*
391* return Pointer to the Blackboard of the Configuration.
392*/
393CParameterBlackboard* CConfigurableDomain::findConfigurationBlackboard(const string& strConfiguration,
394 const CConfigurableElement* pCandidateDescendantConfigurableElement,
395 uint32_t& uiBaseOffset,
396 bool& bIsLastApplied,
397 string& strError) const
398{
399 // Find Configuration
400 const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strConfiguration));
401
402 if (!pDomainConfiguration) {
403
404 strError = "Domain configuration " + strConfiguration + " not found";
405
406 return NULL;
407 }
408
409 // Parse all configurable elements
410 ConfigurableElementListIterator it;
411
412 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
413
414 const CConfigurableElement* pAssociatedConfigurableElement = *it;
415
416 // Check if the the associated element is the configurable element or one of its ancestors
417 if ((pCandidateDescendantConfigurableElement == pAssociatedConfigurableElement) ||
418 (pCandidateDescendantConfigurableElement->isDescendantOf(pAssociatedConfigurableElement))) {
419
420 uiBaseOffset = pAssociatedConfigurableElement->getOffset();
421 bIsLastApplied = (pDomainConfiguration == _pLastAppliedConfiguration);
422
423 return pDomainConfiguration->getBlackboard(pAssociatedConfigurableElement);
424 }
425 }
426
427 strError = "Element not associated to the Domain";
428
429 return NULL;
430}
431
Patrick Benavoli68a91282011-08-31 11:23:23 +0200432// Domain splitting
433bool CConfigurableDomain::split(CConfigurableElement* pConfigurableElement, string& strError)
434{
435 // Not associated?
436 if (!containsConfigurableElement(pConfigurableElement)) {
437
438 strError = "Configurable element " + pConfigurableElement->getPath() + " not associated to configuration domain " + getName();
439
440 return false;
441 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100442 log_info("Splitting configurable element \"%s\" domain \"%s\"", pConfigurableElement->getPath().c_str(), getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200443
444 // Create sub domain areas for all configurable element's children
445 uint32_t uiNbConfigurableElementChildren = pConfigurableElement->getNbChildren();
446
447 if (!uiNbConfigurableElementChildren) {
448
449 strError = "Configurable element " + pConfigurableElement->getPath() + " has no children to split configurable domain to";
450
451 return false;
452 }
453
454 uint32_t uiChild;
455
456 for (uiChild = 0; uiChild < uiNbConfigurableElementChildren; uiChild++) {
457
458 CConfigurableElement* pChildConfigurableElement = static_cast<CConfigurableElement*>(pConfigurableElement->getChild(uiChild));
459
460 doAddConfigurableElement(pChildConfigurableElement);
461 }
462
463 // Delegate to configurations
464 uint32_t uiNbConfigurations = getNbChildren();
465
466 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
467
468 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
469
470 pDomainConfiguration->split(pConfigurableElement);
471 }
472
473 // Remove given configurable element from this domain
474 // Note: we shouldn't need to recompute the sync set in that case, as the splitted element should include the syncers of its children elements
475 doRemoveConfigurableElement(pConfigurableElement, false);
476
477 return true;
478}
479
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200480// Check if there is a pending configuration for this domain: i.e. an applicable configuration different from the last applied configuration
481const CDomainConfiguration* CConfigurableDomain::getPendingConfiguration() const
482{
483 const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();
484
485 if (pApplicableDomainConfiguration) {
486
487 // Check not the last one before applying
488 if (!_pLastAppliedConfiguration || (_pLastAppliedConfiguration != pApplicableDomainConfiguration)) {
489
490 return pApplicableDomainConfiguration;
491 }
492 }
493
494 return NULL;
495}
496
Patrick Benavoli68a91282011-08-31 11:23:23 +0200497// Configuration application if required
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100498void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForce) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200499{
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100500 // Apply configuration only if the blackboard will
501 // be synchronized either now or by syncerSet.
502 if(!pSyncerSet ^ _bSequenceAware) {
503 // The configuration can not be syncronised
504 return;
505 }
506
Patrick Benavoli68a91282011-08-31 11:23:23 +0200507 if (bForce) {
508 // Force a configuration restore by forgetting about last applied configuration
509 _pLastAppliedConfiguration = NULL;
510 }
511 const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();
512
513 if (pApplicableDomainConfiguration) {
514
515 // Check not the last one before applying
516 if (!_pLastAppliedConfiguration || _pLastAppliedConfiguration != pApplicableDomainConfiguration) {
517
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100518 log_info("Applying configuration \"%s\" from domain \"%s\"",
519 pApplicableDomainConfiguration->getName().c_str(),
520 getName().c_str());
521
522 // Check if we need to synchronize during restore
523 bool bSync = !pSyncerSet && _bSequenceAware;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200524
525 // Do the restore
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100526 pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200527
528 // Record last applied configuration
529 _pLastAppliedConfiguration = pApplicableDomainConfiguration;
530
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100531 // Check we need to provide syncer set to caller
532 if (pSyncerSet && !_bSequenceAware) {
Patrick Benavoli63499d42011-10-24 18:50:03 +0200533
534 // Since we applied changes, add our own sync set to the given one
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100535 *pSyncerSet += _syncerSet;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200536 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200537 }
538 }
539}
540
541// Return applicable configuration validity for given configurable element
542bool CConfigurableDomain::isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const
543{
544 const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();
545
546 return pApplicableDomainConfiguration && pApplicableDomainConfiguration->isValid(pConfigurableElement);
547}
548
Patrick Benavoli68a91282011-08-31 11:23:23 +0200549// In case configurable element was removed
550void CConfigurableDomain::computeSyncSet()
551{
552 // Clean sync set first
Patrick Benavoli63499d42011-10-24 18:50:03 +0200553 _syncerSet.clear();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200554
Patrick Benavoli63499d42011-10-24 18:50:03 +0200555 // Add syncer sets for all associated configurable elements
556 ConfigurableElementToSyncerSetMapIterator mapIt;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200557
Patrick Benavoli63499d42011-10-24 18:50:03 +0200558 for (mapIt = _configurableElementToSyncerSetMap.begin(); mapIt != _configurableElementToSyncerSetMap.end(); ++mapIt) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200559
Patrick Benavoli63499d42011-10-24 18:50:03 +0200560 const CSyncerSet* pSyncerSet = mapIt->second;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200561
Patrick Benavoli63499d42011-10-24 18:50:03 +0200562 _syncerSet += *pSyncerSet;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200563 }
564}
565
566// Configuration Management
567bool CConfigurableDomain::createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError)
568{
569 // Already exists?
570 if (findChild(strName)) {
571
572 strError = "Already existing configuration";
573
574 return false;
575 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100576 log_info("Creating domain configuration \"%s\" into domain \"%s\"", strName.c_str(), getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200577
578 // Creation
579 CDomainConfiguration* pDomainConfiguration = new CDomainConfiguration(strName);
580
581 // Configurable elements association
582 ConfigurableElementListIterator it;
583
584 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
585
Patrick Benavoli63499d42011-10-24 18:50:03 +0200586 const CConfigurableElement* pConfigurableElement = *it;;
587
588 // Retrieve associated syncer set
589 CSyncerSet* pSyncerSet = getSyncerSet(pConfigurableElement);
590
591 // Associate to configuration
592 pDomainConfiguration->addConfigurableElement(pConfigurableElement, pSyncerSet);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200593 }
594
595 // Hierarchy
596 addChild(pDomainConfiguration);
597
598 // Ensure validity of fresh new domain configuration
599 // Attempt auto validation, so that the user gets his/her own settings by defaults
600 if (!autoValidateConfiguration(pDomainConfiguration)) {
601
602 // No valid configuration found to copy in from, validate againt main blackboard (will concerned remaining invalid parts)
603 pDomainConfiguration->validate(pMainBlackboard);
604 }
605
606 return true;
607}
608
609bool CConfigurableDomain::deleteConfiguration(const string& strName, string& strError)
610{
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100611 CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200612
613 if (!pDomainConfiguration) {
614
Patrick Benavoli68a91282011-08-31 11:23:23 +0200615 return false;
616 }
617
Kevin Rocardace81f82012-12-11 16:19:17 +0100618 log_info("Deleting configuration \"%s\" from domain \"%s\"", strName.c_str(), getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200619
620 // Was the last applied?
621 if (pDomainConfiguration == _pLastAppliedConfiguration) {
622
623 // Forget about it
624 _pLastAppliedConfiguration = NULL;
625 }
626
627 // Hierarchy
628 removeChild(pDomainConfiguration);
629
630 // Destroy
631 delete pDomainConfiguration;
632
633 return true;
634}
635
636void CConfigurableDomain::listAssociatedToElements(string& strResult) const
637{
638 strResult = "\n";
639
640 ConfigurableElementListIterator it;
641
642 // Browse all configurable elements
643 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
644
645 const CConfigurableElement* pConfigurableElement = *it;
646
647 strResult += pConfigurableElement->getPath() + "\n";
648 }
649}
650
651bool CConfigurableDomain::renameConfiguration(const string& strName, const string& strNewName, string& strError)
652{
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100653 CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200654
655 if (!pDomainConfiguration) {
656
Patrick Benavoli68a91282011-08-31 11:23:23 +0200657 return false;
658 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100659 log_info("Renaming domain \"%s\"'s configuration \"%s\" to \"%s\"", getName().c_str(), strName.c_str(), strNewName.c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200660
661 // Rename
662 return pDomainConfiguration->rename(strNewName, strError);
663}
664
Kevin Rocardace81f82012-12-11 16:19:17 +0100665bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, list<string>& lstrError) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200666{
Kevin Rocardace81f82012-12-11 16:19:17 +0100667 string strError;
668
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100669 const CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200670
671 if (!pDomainConfiguration) {
672
Kevin Rocardace81f82012-12-11 16:19:17 +0100673 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200674 return false;
675 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100676 log_info("Restoring domain \"%s\"'s configuration \"%s\" to parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200677
678 // Delegate
Kevin Rocardace81f82012-12-11 16:19:17 +0100679 bool bSuccess = pDomainConfiguration->restore(pMainBlackboard, bAutoSync && _bSequenceAware, &lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200680
681 // Record last applied configuration
682 _pLastAppliedConfiguration = pDomainConfiguration;
683
684 // Synchronize
Kevin Rocardace81f82012-12-11 16:19:17 +0100685 if (bAutoSync && !_bSequenceAware) {
686
687 bSuccess &= _syncerSet.sync(*pMainBlackboard, false, &lstrError);
688 }
689 return bSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200690}
691
692bool CConfigurableDomain::saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError)
693{
694 // Find Domain configuration
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100695 CDomainConfiguration* pDomainConfiguration = findConfiguration(strName, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200696
697 if (!pDomainConfiguration) {
698
Patrick Benavoli68a91282011-08-31 11:23:23 +0200699 return false;
700 }
Kevin Rocardace81f82012-12-11 16:19:17 +0100701 log_info("Saving domain \"%s\"'s configuration \"%s\" from parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200702
703 // Delegate
704 pDomainConfiguration->save(pMainBlackboard);
705
706 return true;
707}
708
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100709bool CConfigurableDomain::setElementSequence(const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError)
Patrick Benavoli63499d42011-10-24 18:50:03 +0200710{
711 // Find Domain configuration
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100712 CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200713
714 if (!pDomainConfiguration) {
715
Patrick Benavoli63499d42011-10-24 18:50:03 +0200716 return false;
717 }
718
719 // Delegate to configuration
720 return pDomainConfiguration->setElementSequence(astrNewElementSequence, strError);
721}
722
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100723bool CConfigurableDomain::getElementSequence(const string& strConfiguration, string& strResult) const
Patrick Benavoli63499d42011-10-24 18:50:03 +0200724{
725 // Find Domain configuration
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100726 const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200727
728 if (!pDomainConfiguration) {
729
Patrick Benavoli63499d42011-10-24 18:50:03 +0200730 return false;
731 }
732
733 // Delegate to configuration
734 pDomainConfiguration->getElementSequence(strResult);
735
736 return true;
737}
738
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100739bool CConfigurableDomain::setApplicationRule(const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError)
740{
741 // Find Domain configuration
742 CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
743
744 if (!pDomainConfiguration) {
745
746 return false;
747 }
748
749 // Delegate to configuration
750 return pDomainConfiguration->setApplicationRule(strApplicationRule, pSelectionCriteriaDefinition, strError);
751}
752
753bool CConfigurableDomain::clearApplicationRule(const string& strConfiguration, string& strError)
754{
755 // Find Domain configuration
756 CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strError);
757
758 if (!pDomainConfiguration) {
759
760 return false;
761 }
762
763 // Delegate to configuration
764 pDomainConfiguration->clearApplicationRule();
765
766 return true;
767}
768
769bool CConfigurableDomain::getApplicationRule(const string& strConfiguration, string& strResult) const
770{
771 // Find Domain configuration
772 const CDomainConfiguration* pDomainConfiguration = findConfiguration(strConfiguration, strResult);
773
774 if (!pDomainConfiguration) {
775
776 return false;
777 }
778
779 // Delegate to configuration
780 pDomainConfiguration->getApplicationRule(strResult);
781
782 return true;
783}
784
Patrick Benavoli68a91282011-08-31 11:23:23 +0200785// Last applied configuration
786string CConfigurableDomain::getLastAppliedConfigurationName() const
787{
788 if (_pLastAppliedConfiguration) {
789
790 return _pLastAppliedConfiguration->getName();
791 }
792 return "<none>";
793}
794
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200795// Pending configuration
796string CConfigurableDomain::getPendingConfigurationName() const
797{
798 const CDomainConfiguration* pPendingConfiguration = getPendingConfiguration();
799
800 if (pPendingConfiguration) {
801
802 return pPendingConfiguration->getName();
803 }
804 return "<none>";
805}
806
Patrick Benavoli68a91282011-08-31 11:23:23 +0200807// Ensure validity on whole domain from main blackboard
808void CConfigurableDomain::validate(const CParameterBlackboard* pMainBlackboard)
809{
Patrick Benavoli68a91282011-08-31 11:23:23 +0200810
811 // Propagate
812 uint32_t uiNbConfigurations = getNbChildren();
813 uint32_t uiChild;
814
815 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
816
817 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
818
819 pDomainConfiguration->validate(pMainBlackboard);
820 }
821}
822
823// Ensure validity on areas related to configurable element
824void CConfigurableDomain::validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard)
825{
Kevin Rocardace81f82012-12-11 16:19:17 +0100826 log_info("Validating domain \"" + getName() + "\" against main blackboard for configurable element \"" + pConfigurableElement->getPath() + "\"");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200827
828 // Propagate
829 uint32_t uiNbConfigurations = getNbChildren();
830 uint32_t uiChild;
831
832 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
833
834 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
835
836 pDomainConfiguration->validate(pConfigurableElement, pMainBlackboard);
837 }
838}
839
840// Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
841void CConfigurableDomain::autoValidateAll()
842{
843 // Validate
844 ConfigurableElementListIterator it;
845
846 // Browse all configurable elements for configuration validation
847 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
848
849 const CConfigurableElement* pConfigurableElement = *it;
850
851 // Auto validate element
852 autoValidateAreas(pConfigurableElement);
853 }
854}
855
856// Attempt validation for configurable element's areas, relying on already existing valid configuration inside domain
857void CConfigurableDomain::autoValidateAreas(const CConfigurableElement* pConfigurableElement)
858{
859 // Find first valid configuration for given configurable element
860 const CDomainConfiguration* pValidDomainConfiguration = findValidDomainConfiguration(pConfigurableElement);
861
862 // No valid configuration found, give up
863 if (!pValidDomainConfiguration) {
864
865 return;
866 }
867
Patrick Benavoli68a91282011-08-31 11:23:23 +0200868 // Validate all other configurations against found one, if any
869 uint32_t uiNbConfigurations = getNbChildren();
870 uint32_t uiChild;
871
872 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
873
874 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
875
876 if (pDomainConfiguration != pValidDomainConfiguration && !pDomainConfiguration->isValid(pConfigurableElement)) {
877 // Validate
878 pDomainConfiguration->validateAgainst(pValidDomainConfiguration, pConfigurableElement);
879 }
880 }
881}
882
883// Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
884bool CConfigurableDomain::autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration)
885{
886 // Find another configuration than this one, that ought to be valid!
887 uint32_t uiNbConfigurations = getNbChildren();
888 uint32_t uiChild;
889
890 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
891
892 const CDomainConfiguration* pPotententialValidDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild));
893
894 if (pPotententialValidDomainConfiguration != pDomainConfiguration) {
895
896 // Validate against it
897 pDomainConfiguration->validateAgainst(pPotententialValidDomainConfiguration);
898
899 return true;
900 }
901 }
902 return false;
903}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200904
Patrick Benavoli68a91282011-08-31 11:23:23 +0200905// Search for a valid configuration for given configurable element
906const CDomainConfiguration* CConfigurableDomain::findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const
907{
908 uint32_t uiNbConfigurations = getNbChildren();
909 uint32_t uiChild;
910
911 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
912
913 const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild));
914
915 if (pDomainConfiguration->isValid(pConfigurableElement)) {
916
917 return pDomainConfiguration;
918 }
919 }
920 return NULL;
921}
922
923// Search for an applicable configuration
924const CDomainConfiguration* CConfigurableDomain::findApplicableDomainConfiguration() const
925{
926 uint32_t uiNbConfigurations = getNbChildren();
927 uint32_t uiChild;
928
929 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
930
931 const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild));
932
933 if (pDomainConfiguration->isApplicable()) {
934
935 return pDomainConfiguration;
936 }
937 }
938 return NULL;
939}
940
941// Gather set of configurable elements
942void CConfigurableDomain::gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const
943{
944 // Insert all configurable elements
945 configurableElementSet.insert(_configurableElementList.begin(), _configurableElementList.end());
946}
947
948// Check configurable element already attached
949bool CConfigurableDomain::containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const
950{
951 ConfigurableElementListIterator it;
952
953 // Browse all configurable elements for comparison
954 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
955
956 if (pConfigurableCandidateElement == *it) {
957
958 return true;
959 }
960 }
961 return false;
962}
963
964// Merge any descended configurable element to this one with this one
965void CConfigurableDomain::mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement)
966{
967 list<CConfigurableElement*> mergedConfigurableElementList;
968
969 ConfigurableElementListIterator it;
970
971 // Browse all configurable elements (new one not yet in the list!)
972 for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
973
974 CConfigurableElement* pConfigurablePotentialDescendantElement = *it;
975
976 if (pConfigurablePotentialDescendantElement->isDescendantOf(pNewConfigurableElement)) {
977
Kevin Rocardace81f82012-12-11 16:19:17 +0100978 log_info("In domain \"%s\", merging descendant configurable element's configurations \"%s\" into its ascendant \"%s\" ones", getName().c_str(), pConfigurablePotentialDescendantElement->getName().c_str(), pNewConfigurableElement->getName().c_str());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200979
980 // Merge configuration data
981 mergeConfigurations(pNewConfigurableElement, pConfigurablePotentialDescendantElement);
982
983 // Keep track for removal
984 mergedConfigurableElementList.push_back(pConfigurablePotentialDescendantElement);
985 }
986 }
987
988 // Remove all merged elements (new one not yet in the list!)
989 for (it = mergedConfigurableElementList.begin(); it != mergedConfigurableElementList.end(); ++it) {
990
991 CConfigurableElement* pMergedConfigurableElement = *it;
992
993 // Remove merged from configurable element from internal tracking list
994 // Note: we shouldn't need to recompute the sync set in that case, as the merged to element should include the syncers of merged from elements
995 doRemoveConfigurableElement(pMergedConfigurableElement, false);
996 }
997}
998
999void CConfigurableDomain::mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement)
1000{
1001 // Propagate to domain configurations
1002 uint32_t uiNbConfigurations = getNbChildren();
1003 uint32_t uiChild;
1004
1005 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
1006
1007 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
1008
1009 // Do the merge.
1010 pDomainConfiguration->merge(pToConfigurableElement, pFromConfigurableElement);
1011 }
1012}
1013
1014// Configurable elements association
Frédéric Boisnard9620e442012-05-30 16:15:02 +02001015void CConfigurableDomain::doAddConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard *pMainBlackboard)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001016{
1017 // Inform configurable element
1018 pConfigurableElement->addAttachedConfigurableDomain(this);
1019
Patrick Benavoli63499d42011-10-24 18:50:03 +02001020 // Create associated syncer set
1021 CSyncerSet* pSyncerSet = new CSyncerSet;
1022
1023 // Add to sync set the configurable element one
1024 pConfigurableElement->fillSyncerSet(*pSyncerSet);
1025
1026 // Store it
1027 _configurableElementToSyncerSetMap[pConfigurableElement] = pSyncerSet;
1028
1029 // Add it to global one
1030 _syncerSet += *pSyncerSet;
1031
Patrick Benavoli68a91282011-08-31 11:23:23 +02001032 // Inform configurations
1033 uint32_t uiNbConfigurations = getNbChildren();
1034 uint32_t uiChild;
1035
1036 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
1037
1038 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
1039
Patrick Benavoli63499d42011-10-24 18:50:03 +02001040 pDomainConfiguration->addConfigurableElement(pConfigurableElement, pSyncerSet);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001041 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001042
Frédéric Boisnard9620e442012-05-30 16:15:02 +02001043 // Ensure area validity for that configurable element (if main blackboard provided)
1044 if (pMainBlackboard) {
1045
1046 // Need to validate against main blackboard
1047 validateAreas(pConfigurableElement, pMainBlackboard);
1048 }
1049
1050 // Already associated descendend configurable elements need a merge of their configuration data
Patrick Benavoli68a91282011-08-31 11:23:23 +02001051 mergeAlreadyAssociatedDescendantConfigurableElements(pConfigurableElement);
1052
1053 // Add to list
1054 _configurableElementList.push_back(pConfigurableElement);
1055}
1056
1057void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet)
1058{
1059 // Remove from list
1060 _configurableElementList.remove(pConfigurableElement);
1061
Patrick Benavoli63499d42011-10-24 18:50:03 +02001062 // Remove associated syncer set
1063 CSyncerSet* pSyncerSet = getSyncerSet(pConfigurableElement);
1064
1065 _configurableElementToSyncerSetMap.erase(pConfigurableElement);
1066
1067 delete pSyncerSet;
1068
Patrick Benavoli68a91282011-08-31 11:23:23 +02001069 // Inform configurable element
1070 pConfigurableElement->removeAttachedConfigurableDomain(this);
1071
1072 // Inform configurations
1073 uint32_t uiNbConfigurations = getNbChildren();
1074 uint32_t uiChild;
1075
1076 for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) {
1077
1078 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild));
1079
1080 pDomainConfiguration->removeConfigurableElement(pConfigurableElement);
1081 }
1082 // Recompute our sync set if needed
1083 if (bRecomputeSyncSet) {
1084
1085 computeSyncSet();
1086 }
1087}
Patrick Benavoli63499d42011-10-24 18:50:03 +02001088
1089// Syncer set retrieval from configurable element
1090CSyncerSet* CConfigurableDomain::getSyncerSet(const CConfigurableElement* pConfigurableElement) const
1091{
1092 ConfigurableElementToSyncerSetMapIterator mapIt = _configurableElementToSyncerSetMap.find(pConfigurableElement);
1093
1094 assert(mapIt != _configurableElementToSyncerSetMap.end());
1095
1096 return mapIt->second;
1097}
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001098
1099// Configuration retrieval
1100CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError)
1101{
1102 CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strConfiguration));
1103
1104 if (!pDomainConfiguration) {
1105
1106 strError = "Domain configuration " + strConfiguration + " not found";
1107
1108 return NULL;
1109 }
1110 return pDomainConfiguration;
1111}
1112
1113const CDomainConfiguration* CConfigurableDomain::findConfiguration(const string& strConfiguration, string& strError) const
1114{
1115 const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strConfiguration));
1116
1117 if (!pDomainConfiguration) {
1118
1119 strError = "Domain configuration " + strConfiguration + " not found";
1120
1121 return NULL;
1122 }
1123 return pDomainConfiguration;
1124}