Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 0cec4dc

Browse files
committed
Let a domain decide when he should be synchronized.
Domains are browsed twice when applying configurations. The first one gather syncer of domains which are not "sequence aware" and launch a sync on them. The second one launch an apply without providing a syncer set. It lets sequence aware domains to synchronize if needed. This patch allows to browse domains only once. If a domain is sequence aware, it will be synchronized during configurations restauration. If not, the synchronisation will be delayed at the end of all applies. Sequence aware domains are now synchronized first. Signed-off-by: Jules Clero <[email protected]>
1 parent 34a5623 commit 0cec4dc

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

parameter/ConfigurableDomain.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,11 @@ const CDomainConfiguration* CConfigurableDomain::getPendingConfiguration() const
519519
}
520520

521521
// Configuration application if required
522-
void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForce) const
522+
void CConfigurableDomain::apply(
523+
CParameterBlackboard* pParameterBlackboard,
524+
CSyncerSet& syncerSet,
525+
bool bForce) const
523526
{
524-
// Apply configuration only if the blackboard will
525-
// be synchronized either now or by syncerSet.
526-
if(!pSyncerSet ^ _bSequenceAware) {
527-
// The configuration can not be syncronised
528-
return;
529-
}
530-
531527
if (bForce) {
532528
// Force a configuration restore by forgetting about last applied configuration
533529
_pLastAppliedConfiguration = NULL;
@@ -543,20 +539,17 @@ void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyn
543539
pApplicableDomainConfiguration->getName().c_str(),
544540
getName().c_str());
545541

546-
// Check if we need to synchronize during restore
547-
bool bSync = !pSyncerSet && _bSequenceAware;
548-
549-
// Do the restore
550-
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, NULL);
542+
// Do the restore, and synchronize if we are sequence aware
543+
pApplicableDomainConfiguration->restore(pParameterBlackboard, _bSequenceAware, NULL);
551544

552545
// Record last applied configuration
553546
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
554547

555548
// Check we need to provide syncer set to caller
556-
if (pSyncerSet && !_bSequenceAware) {
549+
if (!_bSequenceAware) {
557550

558551
// Since we applied changes, add our own sync set to the given one
559-
*pSyncerSet += _syncerSet;
552+
syncerSet += _syncerSet;
560553
}
561554
}
562555
}

parameter/ConfigurableDomain.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,17 @@ class CConfigurableDomain : public CBinarySerializableElement
9595
// Ensure validity on whole domain from main blackboard
9696
void validate(const CParameterBlackboard* pMainBlackboard);
9797

98-
// Configuration application if required
99-
void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForced) const;
98+
/**
99+
* Apply the configuration if required
100+
*
101+
* @param[in] pParameterBlackboard the blackboard to synchronize
102+
* @param[in] syncerSet the set containing application syncers
103+
* @param[in] bForced boolean used to force configuration application
104+
*/
105+
void apply(
106+
CParameterBlackboard* pParameterBlackboard,
107+
CSyncerSet& syncerSet,
108+
bool bForced) const;
100109

101110
// Return applicable configuration validity for given configurable element
102111
bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;

parameter/ConfigurableDomains.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,10 @@ void CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, CSy
8383
const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild));
8484

8585
// Apply and collect syncers when relevant
86-
pChildConfigurableDomain->apply(pParameterBlackboard, &syncerSet, bForce);
86+
pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce);
8787
}
8888
// Synchronize those collected syncers
8989
syncerSet.sync(*pParameterBlackboard, false, NULL);
90-
91-
// Then deal with domains that need to synchronize along apply
92-
for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) {
93-
94-
const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild));
95-
96-
// Apply and synchronize when relevant
97-
pChildConfigurableDomain->apply(pParameterBlackboard, NULL, bForce);
98-
}
9990
}
10091

10192
// From IXmlSource

0 commit comments

Comments
 (0)