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

Let a domain decide when he should be synchronized. #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 17 additions & 27 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,45 +519,35 @@ const CDomainConfiguration* CConfigurableDomain::getPendingConfiguration() const
}

// Configuration application if required
void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForce) const
void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard,
CSyncerSet& syncerSet,
bool bForce) const
{
// Apply configuration only if the blackboard will
// be synchronized either now or by syncerSet.
if(!pSyncerSet ^ _bSequenceAware) {
// The configuration can not be syncronised
return;
}

if (bForce) {
// Force a configuration restore by forgetting about last applied configuration
_pLastAppliedConfiguration = NULL;
}
const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();

if (pApplicableDomainConfiguration) {

// Check not the last one before applying
if (!_pLastAppliedConfiguration || _pLastAppliedConfiguration != pApplicableDomainConfiguration) {

log_info("Applying configuration \"%s\" from domain \"%s\"",
pApplicableDomainConfiguration->getName().c_str(),
getName().c_str());
// Check the last applied configuration is different from this one before apply
if (pApplicableDomainConfiguration != NULL &&
_pLastAppliedConfiguration != pApplicableDomainConfiguration) {

// Check if we need to synchronize during restore
bool bSync = !pSyncerSet && _bSequenceAware;
log_info("Applying configuration \"%s\" from domain \"%s\"",
pApplicableDomainConfiguration->getName().c_str(),
getName().c_str());

// Do the restore
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, NULL);
// Do the restore, and synchronize if we are sequence aware
pApplicableDomainConfiguration->restore(pParameterBlackboard, _bSequenceAware, NULL);

// Record last applied configuration
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
// Record last applied configuration
_pLastAppliedConfiguration = pApplicableDomainConfiguration;

// Check we need to provide syncer set to caller
if (pSyncerSet && !_bSequenceAware) {
// Check we need to provide syncer set to caller
if (!_bSequenceAware) {

// Since we applied changes, add our own sync set to the given one
*pSyncerSet += _syncerSet;
}
// Since we applied changes, add our own sync set to the given one
syncerSet += _syncerSet;
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions parameter/ConfigurableDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ class CConfigurableDomain : public CBinarySerializableElement
// Ensure validity on whole domain from main blackboard
void validate(const CParameterBlackboard* pMainBlackboard);

// Configuration application if required
void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForced) const;
/** Apply the configuration if required
*
* @param[in] pParameterBlackboard the blackboard to synchronize
* @param[in] syncerSet the set containing application syncers
* @param[in] bForced boolean used to force configuration application
*/
void apply(CParameterBlackboard* pParameterBlackboard,
CSyncerSet& syncerSet,
bool bForced) const;

// Return applicable configuration validity for given configurable element
bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
Expand Down
11 changes: 1 addition & 10 deletions parameter/ConfigurableDomains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,10 @@ void CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, CSy
const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild));

// Apply and collect syncers when relevant
pChildConfigurableDomain->apply(pParameterBlackboard, &syncerSet, bForce);
pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce);
}
// Synchronize those collected syncers
syncerSet.sync(*pParameterBlackboard, false, NULL);

// Then deal with domains that need to synchronize along apply
for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) {

const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild));

// Apply and synchronize when relevant
pChildConfigurableDomain->apply(pParameterBlackboard, NULL, bForce);
}
}

// From IXmlSource
Expand Down