diff options
23 files changed, 1051 insertions, 469 deletions
diff --git a/parameter/AreaConfiguration.cpp b/parameter/AreaConfiguration.cpp index d9d3fcf..2e8c63d 100644 --- a/parameter/AreaConfiguration.cpp +++ b/parameter/AreaConfiguration.cpp @@ -34,8 +34,10 @@ #include "BinaryStream.h" #include <assert.h> -CAreaConfiguration::CAreaConfiguration(const CConfigurableElement* pConfigurableElement) : _pConfigurableElement(pConfigurableElement), _bValid(false) +CAreaConfiguration::CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet) + : _pConfigurableElement(pConfigurableElement), _pSyncerSet(pSyncerSet), _bValid(false) { + // Size blackboard _blackboard.setSize(_pConfigurableElement->getFootPrint()); } @@ -46,11 +48,22 @@ void CAreaConfiguration::save(const CParameterBlackboard* pMainBlackboard) } // Apply data to current -void CAreaConfiguration::restore(CParameterBlackboard* pMainBlackboard) const +bool CAreaConfiguration::restore(CParameterBlackboard* pMainBlackboard, bool bSync, string& strError) const { assert(_bValid); pMainBlackboard->restoreFrom(&_blackboard, _pConfigurableElement->getOffset()); + + // Synchronize if required + if (bSync) { + + if (!_pSyncerSet->sync(*pMainBlackboard, false, strError)) { + + return false; + } + } + + return true; } // Ensure validity @@ -91,7 +104,7 @@ void CAreaConfiguration::validateAgainst(const CAreaConfiguration* pValidAreaCon } // XML configuration settings parsing -bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) +bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) { // Assign blackboard to configuration context configurationAccessContext.setParameterBlackboard(&_blackboard); @@ -100,7 +113,7 @@ bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSetti configurationAccessContext.setBaseOffset(_pConfigurableElement->getOffset()); // Parse configuration settings (element contents) - if (_pConfigurableElement->serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext)) { + if (_pConfigurableElement->serializeXmlSettings(xmlConfigurableElementSettingsElementContent, configurationAccessContext)) { if (!configurationAccessContext.serializeOut()) { diff --git a/parameter/AreaConfiguration.h b/parameter/AreaConfiguration.h index 541a07f..b5e7e4c 100644 --- a/parameter/AreaConfiguration.h +++ b/parameter/AreaConfiguration.h @@ -32,6 +32,7 @@ #include "ParameterBlackboard.h" #include "BinaryStream.h" +#include "SyncerSet.h" using namespace std; @@ -42,13 +43,13 @@ class CConfigurationAccessContext; class CAreaConfiguration { public: - CAreaConfiguration(const CConfigurableElement* pConfigurableElement); + CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet); // Save data from current void save(const CParameterBlackboard* pMainBlackboard); // Apply data to current - void restore(CParameterBlackboard* pMainBlackboard) const; + bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, string& strError) const; // Ensure validity void validate(const CParameterBlackboard* pMainBlackboard); @@ -69,7 +70,7 @@ public: void copyToInner(CAreaConfiguration* pToAreaConfiguration) const; // XML configuration settings parsing/composing - bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); + bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); // Serialization void serialize(CBinaryStream& binaryStream); @@ -77,13 +78,18 @@ public: // Data size uint32_t getSize() const; private: - // Associated configurable element - const CConfigurableElement* _pConfigurableElement; // Store validity void setValid(bool bValid); + // Associated configurable element + const CConfigurableElement* _pConfigurableElement; + + // Syncer set (required for immediate synchronization) + const CSyncerSet* _pSyncerSet; + // Configurable element settings CParameterBlackboard _blackboard; + // Area configuration validity (invalid area configurations can't be restored) bool _bValid; }; diff --git a/parameter/BinaryStream.h b/parameter/BinaryStream.h index fdac4eb..2e66b5c 100644 --- a/parameter/BinaryStream.h +++ b/parameter/BinaryStream.h @@ -63,6 +63,7 @@ private: string _strFileName; // Serialization direction bool _bOut; + // Data size uint32_t _uiDataSize; // System structure checksum uint8_t _uiStructureChecksum; diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp index 912fa5e..c9e3266 100644 --- a/parameter/ConfigurableDomain.cpp +++ b/parameter/ConfigurableDomain.cpp @@ -38,15 +38,15 @@ #define base CBinarySerializableElement -CConfigurableDomain::CConfigurableDomain(const string& strName) : base(strName), _pLastAppliedConfiguration(NULL) +CConfigurableDomain::CConfigurableDomain(const string& strName) : base(strName), _bSequenceAware(false), _pLastAppliedConfiguration(NULL) { } CConfigurableDomain::~CConfigurableDomain() { + // Remove all configurable elements ConfigurableElementListIterator it; - // Browse all configurable elements for their syncers for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { CConfigurableElement* pConfigurableElement = *it; @@ -54,6 +54,14 @@ CConfigurableDomain::~CConfigurableDomain() // Remove from configurable element pConfigurableElement->removeAttachedConfigurableDomain(this); } + + // Remove all associated syncer sets + ConfigurableElementToSyncerSetMapIterator mapIt; + + for (mapIt = _configurableElementToSyncerSetMap.begin(); mapIt != _configurableElementToSyncerSetMap.end(); ++mapIt) { + + delete mapIt->second; + } } string CConfigurableDomain::getKind() const @@ -66,14 +74,36 @@ bool CConfigurableDomain::childrenAreDynamic() const return true; } +// Sequence awareness +void CConfigurableDomain::setSequenceAwareness(bool bSequenceAware) +{ + if (_bSequenceAware != bSequenceAware) { + + log("Making domain \"%s\" sequence %s", getName().c_str(), bSequenceAware ? "aware" : "unaware"); + + _bSequenceAware = bSequenceAware; + } +} + +bool CConfigurableDomain::getSequenceAwareness() const +{ + return _bSequenceAware; +} + // From IXmlSource void CConfigurableDomain::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { + // Sequence awareness + xmlElement.setAttributeBoolean("SequenceAware", _bSequenceAware); + // Configurations composeDomainConfigurations(xmlElement, serializingContext); // Configurable Elements - composeConfigurableElements(xmlElement, serializingContext); + composeConfigurableElements(xmlElement); + + // Settings + composeSettings(xmlElement, serializingContext); } // XML composing @@ -88,11 +118,8 @@ void CConfigurableDomain::composeDomainConfigurations(CXmlElement& xmlElement, C base::toXml(xmlConfigurationsElement, serializingContext); } -void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement) const { - // Context - const CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<const CXmlDomainSerializingContext&>(serializingContext); - // Create ConfigurableElements element CXmlElement xmlConfigurableElementsElement; @@ -112,18 +139,25 @@ void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement, C // Set Path attribute xmlChildConfigurableElement.setAttributeString("Path", pConfigurableElement->getPath()); - - if (xmlDomainSerializingContext.withSettings()) { - - // Compose configurations for that configurable element - composeConfigurableElementConfigurations(pConfigurableElement, xmlChildConfigurableElement, serializingContext); - } } } -// Serialize configurations for one configurable element -void CConfigurableDomain::composeConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext) const +void CConfigurableDomain::composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { + // Context + const CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<const CXmlDomainSerializingContext&>(serializingContext); + + if (!xmlDomainSerializingContext.withSettings()) { + + return; + } + + // Create Settings element + CXmlElement xmlSettingsElement; + + xmlElement.createChild(xmlSettingsElement, "Settings"); + + // Serialize out all configurations settings uint32_t uiNbConfigurations = getNbChildren(); uint32_t uiChildConfiguration; @@ -134,21 +168,39 @@ void CConfigurableDomain::composeConfigurableElementConfigurations(const CConfig // Create child xml element for that configuration CXmlElement xmlConfigurationSettingsElement; - xmlConfigurableElementElement.createChild(xmlConfigurationSettingsElement, pDomainConfiguration->getKind()); + xmlSettingsElement.createChild(xmlConfigurationSettingsElement, pDomainConfiguration->getKind()); // Set its name attribute xmlConfigurationSettingsElement.setNameAttribute(pDomainConfiguration->getName()); - // Have domain configuration serialize settings for configurable element - ((CConfigurableDomain&)(*this)).serializeConfigurableElementConfiguration((CDomainConfiguration*)pDomainConfiguration, pConfigurableElement, xmlConfigurationSettingsElement, serializingContext, true); + // Serialize out configuration settings + pDomainConfiguration->composeSettings(xmlConfigurationSettingsElement, serializingContext); } } // From IXmlSink bool CConfigurableDomain::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { + // Context + CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); + + // Sequence awareness (optional) + _bSequenceAware = xmlElement.hasAttribute("SequenceAware") && xmlElement.getAttributeBoolean("SequenceAware"); + // Local parsing. Do not dig - return parseDomainConfigurations(xmlElement, serializingContext) && parseConfigurableElements(xmlElement, serializingContext); + if (!parseDomainConfigurations(xmlElement, serializingContext) || !parseConfigurableElements(xmlElement, serializingContext) || !parseSettings(xmlElement, serializingContext)) { + + return false; + } + + // All provided configurations are parsed + // Attempt validation on areas of non provided configurations for all configurable elements if required + if (xmlDomainSerializingContext.autoValidationRequired()) { + + autoValidateAll(); + } + + return true; } // XML parsing @@ -169,9 +221,6 @@ bool CConfigurableDomain::parseDomainConfigurations(const CXmlElement& xmlElemen // Parse configurable elements bool CConfigurableDomain::parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { - // Context - const CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<const CXmlDomainSerializingContext&>(serializingContext); - // Get System Class Element CElement* pRootElement = getRoot(); @@ -222,126 +271,56 @@ bool CConfigurableDomain::parseConfigurableElements(const CXmlElement& xmlElemen return false; } - - // Check we need to parse configuration settings - if (xmlDomainSerializingContext.withSettings()) { - - // Make Domain configuration parse associated configuration nodes if any - if (!parseConfigurableElementConfigurations(pConfigurableElement, xmlConfigurableElementElement, serializingContext)) { - - return false; - } - } } - // All provided configurations are parsed - // Attempt validation on areas of non provided configurations for all configurable elements - autoValidateAll(); return true; } -// Parse configurations for one configurable element -bool CConfigurableDomain::parseConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext) +// Parse settings +bool CConfigurableDomain::parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { // Context CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); - // Parse configurable element's configuration settings - CXmlElement::CChildIterator it(xmlConfigurableElementElement); - - CXmlElement xmlConfigurationSettingsElement; + // Check we actually need to parse configuration settings + if (!xmlDomainSerializingContext.withSettings()) { - while (it.next(xmlConfigurationSettingsElement)) { - // Get domain configuration - CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(xmlConfigurationSettingsElement.getNameAttribute())); - - if (!pDomainConfiguration) { - - xmlDomainSerializingContext.setError("Could not find domain configuration referred to by configurable element of path " + xmlConfigurableElementElement.getPath() + " from ConfigurableDomain description " + getName()); + // No parsing required + return true; + } - return false; - } - // Have domain configuration parse settings for configurable element - if (!serializeConfigurableElementConfiguration(pDomainConfiguration, pConfigurableElement, xmlConfigurationSettingsElement, xmlDomainSerializingContext, false)) { + // Get Settings element + CXmlElement xmlSettingsElement; + if (!xmlElement.getChildElement("Settings", xmlSettingsElement)) { - return false; - } + // No settings, bail out successfully + return true; } - return true; -} + // Parse configuration settings + CXmlElement::CChildIterator it(xmlSettingsElement); -// Serialize one configuration for one configurable element -bool CConfigurableDomain::serializeConfigurableElementConfiguration(CDomainConfiguration* pDomainConfiguration, const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut) -{ - // Actual XML context - CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); - - // Element content - CXmlElement xmlConfigurationSettingsElementContent; + CXmlElement xmlConfigurationSettingsElement; - // Deal with element itself - if (!bSerializeOut) { + while (it.next(xmlConfigurationSettingsElement)) { + // Get domain configuration + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(xmlConfigurationSettingsElement.getNameAttribute())); - // Check structure - if (xmlConfigurationSettingsElement.getNbChildElements() != 1) { + if (!pDomainConfiguration) { - // Structure error - serializingContext.setError("Struture error encountered while parsing settinsg of " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " in Configuration " + pDomainConfiguration->getName() + " in Domain " + getName()); + xmlDomainSerializingContext.setError("Could not find domain configuration referred to by configurable domain " + getName()); return false; } - - // Check name and kind - if (!xmlConfigurationSettingsElement.getChildElement(pConfigurableElement->getKind(), pConfigurableElement->getName(), xmlConfigurationSettingsElementContent)) { - - serializingContext.setError("Couldn't find settings for " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " for Configuration " + pDomainConfiguration->getName() + " in Domain " + getName()); + // Have domain configuration parse settings for all configurable elements + if (!pDomainConfiguration->parseSettings(xmlConfigurationSettingsElement, xmlDomainSerializingContext)) { return false; } - } else { - - // Create child XML element - xmlConfigurationSettingsElement.createChild(xmlConfigurationSettingsElementContent, pConfigurableElement->getKind()); - - // Set Name - xmlConfigurationSettingsElementContent.setNameAttribute(pConfigurableElement->getName()); } - // Change context type to parameter settings access - string strError; - - // Create configuration access context - CConfigurationAccessContext configurationAccessContext(strError, bSerializeOut); - - // Provide current value space - configurationAccessContext.setValueSpaceRaw(xmlDomainSerializingContext.valueSpaceIsRaw()); - - // Provide current output raw format - configurationAccessContext.setOutputRawFormat(xmlDomainSerializingContext.outputRawFormatIsHex()); - - // Get subsystem - const CSubsystem* pSubsystem = pConfigurableElement->getBelongingSubsystem(); - - if (pSubsystem && pSubsystem != pConfigurableElement) { - - // Element is a descendant of subsystem - - // Deal with Endianness - configurationAccessContext.setBigEndianSubsystem(pSubsystem->isBigEndian()); - } - - // Have domain configuration parse settings for configurable element - if (!pDomainConfiguration->serializeXmlSettings(pConfigurableElement, xmlConfigurationSettingsElementContent, configurationAccessContext)) { - - // Forward error - xmlDomainSerializingContext.setError(strError); - - return false; - } return true; } - // Configurable elements association bool CConfigurableDomain::addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError) { @@ -441,7 +420,7 @@ bool CConfigurableDomain::split(CConfigurableElement* pConfigurableElement, stri } // Configuration application if required -void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce) +bool CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce, string& strError) const { if (bForce) { // Force a configuration restore by forgetting about last applied configuration @@ -457,15 +436,24 @@ void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyn log("Applying configuration \"%s\" from domain \"%s\"", pApplicableDomainConfiguration->getName().c_str(), getName().c_str()); // Do the restore - pApplicableDomainConfiguration->restore(pParameterBlackboard); + if (!pApplicableDomainConfiguration->restore(pParameterBlackboard, _bSequenceAware, strError)) { + + return false; + } // Record last applied configuration _pLastAppliedConfiguration = pApplicableDomainConfiguration; - // Since we applied changes, add our own sync set to the given one - syncerSet += _syncerSet; + // Check we did not already sync the changes + if (!_bSequenceAware) { + + // Since we applied changes, add our own sync set to the given one + syncerSet += _syncerSet; + } } } + + return true; } // Return applicable configuration validity for given configurable element @@ -499,16 +487,16 @@ bool CConfigurableDomain::hasRules() const void CConfigurableDomain::computeSyncSet() { // Clean sync set first - _syncerSet.clear(); + _syncerSet.clear(); - // Browse all configurable elements for their syncers - ConfigurableElementListIterator it; + // Add syncer sets for all associated configurable elements + ConfigurableElementToSyncerSetMapIterator mapIt; - for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + for (mapIt = _configurableElementToSyncerSetMap.begin(); mapIt != _configurableElementToSyncerSetMap.end(); ++mapIt) { - const CConfigurableElement* pConfigurableElement = *it; + const CSyncerSet* pSyncerSet = mapIt->second; - pConfigurableElement->fillSyncerSet(_syncerSet); + _syncerSet += *pSyncerSet; } } @@ -532,7 +520,13 @@ bool CConfigurableDomain::createConfiguration(const string& strName, const CPara for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { - pDomainConfiguration->addConfigurableElement(*it); + const CConfigurableElement* pConfigurableElement = *it;; + + // Retrieve associated syncer set + CSyncerSet* pSyncerSet = getSyncerSet(pConfigurableElement); + + // Associate to configuration + pDomainConfiguration->addConfigurableElement(pConfigurableElement, pSyncerSet); } // Hierarchy @@ -631,7 +625,10 @@ bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameter log("Restoring domain \"%s\"'s configuration \"%s\" to parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str()); // Delegate - pDomainConfiguration->restore(pMainBlackboard); + if (!pDomainConfiguration->restore(pMainBlackboard, _bSequenceAware && bAutoSync, strError)) { + + return false; + } // Record last applied configuration _pLastAppliedConfiguration = pDomainConfiguration; @@ -659,6 +656,40 @@ bool CConfigurableDomain::saveConfiguration(const string& strName, const CParame return true; } +bool CConfigurableDomain::setElementSequence(const string& strName, const vector<string>& astrNewElementSequence, string& strError) +{ + // Find Domain configuration + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strError = "Domain configuration " + strName + " not found"; + + return false; + } + + // Delegate to configuration + return pDomainConfiguration->setElementSequence(astrNewElementSequence, strError); +} + +bool CConfigurableDomain::getElementSequence(const string& strName, string& strResult) const +{ + // Find Domain configuration + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strResult = "Domain configuration " + strName + " not found"; + + return false; + } + + // Delegate to configuration + pDomainConfiguration->getElementSequence(strResult); + + return true; +} + // Last applied configuration string CConfigurableDomain::getLastAppliedConfigurationName() const { @@ -885,6 +916,18 @@ void CConfigurableDomain::doAddConfigurableElement(CConfigurableElement* pConfig // Inform configurable element pConfigurableElement->addAttachedConfigurableDomain(this); + // Create associated syncer set + CSyncerSet* pSyncerSet = new CSyncerSet; + + // Add to sync set the configurable element one + pConfigurableElement->fillSyncerSet(*pSyncerSet); + + // Store it + _configurableElementToSyncerSetMap[pConfigurableElement] = pSyncerSet; + + // Add it to global one + _syncerSet += *pSyncerSet; + // Inform configurations uint32_t uiNbConfigurations = getNbChildren(); uint32_t uiChild; @@ -893,10 +936,8 @@ void CConfigurableDomain::doAddConfigurableElement(CConfigurableElement* pConfig CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); - pDomainConfiguration->addConfigurableElement(pConfigurableElement); + pDomainConfiguration->addConfigurableElement(pConfigurableElement, pSyncerSet); } - // Add to our own sync set the configurable element one - pConfigurableElement->fillSyncerSet(_syncerSet); // Already associated descended configurable elements need a merge of their configuration data mergeAlreadyAssociatedDescendantConfigurableElements(pConfigurableElement); @@ -910,6 +951,13 @@ void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement* pCon // Remove from list _configurableElementList.remove(pConfigurableElement); + // Remove associated syncer set + CSyncerSet* pSyncerSet = getSyncerSet(pConfigurableElement); + + _configurableElementToSyncerSetMap.erase(pConfigurableElement); + + delete pSyncerSet; + // Inform configurable element pConfigurableElement->removeAttachedConfigurableDomain(this); @@ -929,3 +977,13 @@ void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement* pCon computeSyncSet(); } } + +// Syncer set retrieval from configurable element +CSyncerSet* CConfigurableDomain::getSyncerSet(const CConfigurableElement* pConfigurableElement) const +{ + ConfigurableElementToSyncerSetMapIterator mapIt = _configurableElementToSyncerSetMap.find(pConfigurableElement); + + assert(mapIt != _configurableElementToSyncerSetMap.end()); + + return mapIt->second; +} diff --git a/parameter/ConfigurableDomain.h b/parameter/ConfigurableDomain.h index 0438009..87ed41c 100644 --- a/parameter/ConfigurableDomain.h +++ b/parameter/ConfigurableDomain.h @@ -34,6 +34,7 @@ #include "SyncerSet.h" #include <list> #include <set> +#include <map> class CConfigurableElement; class CDomainConfiguration; @@ -42,16 +43,23 @@ class CParameterBlackboard; class CConfigurableDomain : public CBinarySerializableElement { typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator; + typedef map<const CConfigurableElement*, CSyncerSet*>::const_iterator ConfigurableElementToSyncerSetMapIterator; public: CConfigurableDomain(const string& strName); virtual ~CConfigurableDomain(); + // Sequence awareness + void setSequenceAwareness(bool bSequenceAware); + bool getSequenceAwareness() const; + // Configuration Management bool createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError); bool deleteConfiguration(const string& strName, string& strError); bool renameConfiguration(const string& strName, const string& strNewName, string& strError); bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError); bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError); + bool setElementSequence(const string& strName, const vector<string>& astrNewElementSequence, string& strError); + bool getElementSequence(const string& strName, string& strResult) const; // Last applied configuration string getLastAppliedConfigurationName() const; @@ -71,7 +79,7 @@ public: void validate(const CParameterBlackboard* pMainBlackboard); // Configuration application if required - void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced); + bool apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced, string& strError) const; // Return applicable configuration validity for given configurable element bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const; @@ -126,21 +134,29 @@ private: // XML parsing bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); - bool parseConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext); - bool serializeConfigurableElementConfiguration(CDomainConfiguration* pDomainConfiguration, const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut); + bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); // XML composing void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; - void composeConfigurableElements(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; - void composeConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext) const; + void composeConfigurableElements(CXmlElement& xmlElement) const; + void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Syncer set retrieval from configurable element + CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const; // Configurable elements list<CConfigurableElement*> _configurableElementList; + // Associated syncer sets + map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap; + + // Sequence awareness + bool _bSequenceAware; + // Syncer set used to ensure propoer synchronization of restored configurable elements CSyncerSet _syncerSet; // Last applied configuration - const CDomainConfiguration* _pLastAppliedConfiguration; + mutable const CDomainConfiguration* _pLastAppliedConfiguration; }; diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index fa794b3..c65bf3f 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -66,7 +66,7 @@ void CConfigurableDomains::validate(const CParameterBlackboard* pMainBlackboard) } // Configuration application if required -bool CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError) +bool CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError) const { CAutoLog autoLog(this, "Applying configurations"); @@ -74,17 +74,38 @@ bool CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, boo CSyncerSet syncerSet; // Delegate to domains + + // Start with sequence unaware domains uint32_t uiChild; uint32_t uiNbConfigurableDomains = getNbChildren(); for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { - CConfigurableDomain* pChildConfigurableDomain = static_cast<CConfigurableDomain*>(getChild(uiChild)); + const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild)); - pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce); + if (!pChildConfigurableDomain->getSequenceAwareness() && !pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce, strError)) { + + return false; + } } // Synchronize - return syncerSet.sync(*pParameterBlackboard, false, strError); + if (!syncerSet.sync(*pParameterBlackboard, false, strError)) { + + return false; + } + + // Then deal with sequence aware domains + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild)); + + if (pChildConfigurableDomain->getSequenceAwareness() && !pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce, strError)) { + + return false; + } + } + + return true; } // From IXmlSource @@ -163,6 +184,38 @@ bool CConfigurableDomains::renameDomain(const string& strName, const string& str return pConfigurableDomain->rename(strNewName, strError); } +bool CConfigurableDomains::setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain not found"; + + return false; + } + + pConfigurableDomain->setSequenceAwareness(bSequenceAware); + + return true; +} + +bool CConfigurableDomains::getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const +{ + const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain not found"; + + return false; + } + + bSequenceAware = pConfigurableDomain->getSequenceAwareness(); + + return true; +} + /// Configurations bool CConfigurableDomains::listConfigurations(const string& strDomain, string& strResult) const { @@ -310,6 +363,29 @@ void CConfigurableDomains::listConflictingElements(string& strResult) const } } +void CConfigurableDomains::listDomains(string& strResult) const +{ + strResult = "\n"; + + // List domains + uint32_t uiChild; + uint32_t uiNbConfigurableDomains = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild)); + + // Name + strResult += pChildConfigurableDomain->getName(); + + // Sequence awareness + if (pChildConfigurableDomain->getSequenceAwareness()) { + + strResult += " [sequence aware]\n"; + } + } +} + // Gather configurable elements owned by any domain void CConfigurableDomains::gatherAllOwnedConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const { @@ -357,6 +433,37 @@ bool CConfigurableDomains::saveConfiguration(const string& strDomain, const stri return pConfigurableDomain->saveConfiguration(strConfiguration, pMainBlackboard, strError); } +bool CConfigurableDomains::setElementSequence(const string& strDomain, const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + + // Delegate to domain + return pConfigurableDomain->setElementSequence(strConfiguration, astrNewElementSequence, strError); +} + +bool CConfigurableDomains::getElementSequence(const string& strDomain, const string& strConfiguration, string& strResult) const +{ + // Find domain + const CConfigurableDomain* pConfigurableDomain = static_cast<const CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strResult = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate to domain + return pConfigurableDomain->getElementSequence(strConfiguration, strResult); +} + // Last applied configurations void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) const { diff --git a/parameter/ConfigurableDomains.h b/parameter/ConfigurableDomains.h index 134667f..4c6192f 100644 --- a/parameter/ConfigurableDomains.h +++ b/parameter/ConfigurableDomains.h @@ -47,10 +47,13 @@ public: bool createDomain(const string& strName, string& strError); bool deleteDomain(const string& strName, string& strError); bool renameDomain(const string& strName, const string& strNewName, string& strError); + bool setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError); + bool getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const; bool listDomainElements(const string& strDomain, string& strResult) const; bool split(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError); void listAssociatedElements(string& strResult) const; void listConflictingElements(string& strResult) const; + void listDomains(string& strResult) const; /// Configurations bool listConfigurations(const string& strDomain, string& strResult) const; bool createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError); @@ -58,6 +61,8 @@ public: bool renameConfiguration(const string& strDomain, const string& strConfigurationName, const string& strNewConfigurationName, string& strError); bool restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError); bool saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError); + bool setElementSequence(const string& strDomain, const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError); + bool getElementSequence(const string& strDomain, const string& strConfiguration, string& strResult) const; // Last applied configurations void listLastAppliedConfigurations(string& strResult) const; @@ -76,7 +81,7 @@ public: void validate(const CParameterBlackboard* pMainBlackboard); // Configuration application if required - bool apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError); + bool apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError) const; // Class kind virtual string getKind() const; diff --git a/parameter/ConfigurableElement.h b/parameter/ConfigurableElement.h index de9bcd5..1f5498c 100644 --- a/parameter/ConfigurableElement.h +++ b/parameter/ConfigurableElement.h @@ -44,6 +44,7 @@ class CParameterAccessContext; class CConfigurableElement : public CElement { friend class CConfigurableDomain; + friend class CDomainConfiguration; typedef list<const CConfigurableDomain*>::const_iterator ConfigurableDomainListConstIterator; public: CConfigurableElement(const string& strName); diff --git a/parameter/ConfigurableElementAggregator.cpp b/parameter/ConfigurableElementAggregator.cpp index a24c074..53a4bf8 100644 --- a/parameter/ConfigurableElementAggregator.cpp +++ b/parameter/ConfigurableElementAggregator.cpp @@ -71,7 +71,7 @@ bool CConfigurableElementAggregator::doAggregate(const CConfigurableElement* pCo return true; } else { - // Add rogue children if any + // Add children if any aggregateList.insert(aggregateList.end(), childAggregateElementList.begin(), childAggregateElementList.end()); return false; diff --git a/parameter/DomainConfiguration.cpp b/parameter/DomainConfiguration.cpp index 8d5ebfb..a5ac27c 100644 --- a/parameter/DomainConfiguration.cpp +++ b/parameter/DomainConfiguration.cpp @@ -32,6 +32,9 @@ #include "AreaConfiguration.h" #include "ConfigurableElement.h" #include "CompoundRule.h" +#include "Subsystem.h" +#include "XmlDomainSerializingContext.h" +#include "ConfigurationAccessContext.h" #include <assert.h> #define base CBinarySerializableElement @@ -63,21 +66,155 @@ bool CDomainConfiguration::childrenAreDynamic() const } // XML configuration settings parsing -bool CDomainConfiguration::serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) +bool CDomainConfiguration::parseSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext) { - // Find related AreaConfiguration - CAreaConfiguration* pAreaConfiguration = getAreaConfiguration(pConfigurableElement); + // Actual XML context + CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); - assert(pAreaConfiguration); + // Take care of configurable elements / area configurations ranks + list<CAreaConfiguration*> areaConfigurationList; + + // Parse configurable element's configuration settings + CXmlElement::CChildIterator it(xmlConfigurationSettingsElement); + + CXmlElement xmlConfigurableElementSettingsElement; + + while (it.next(xmlConfigurableElementSettingsElement)) { + + // Retrieve area configuration + string strConfigurableElementPath = xmlConfigurableElementSettingsElement.getAttributeString("Path"); + + CAreaConfiguration* pAreaConfiguration = findAreaConfiguration(strConfigurableElementPath); + + if (!pAreaConfiguration) { + + xmlDomainSerializingContext.setError("Configurable Element " + strConfigurableElementPath + " referred to by Configuration " + getPath() + " not associated to Domain"); + + return false; + } + // Ranks + areaConfigurationList.push_back(pAreaConfiguration); + + // Parse + if (!serializeConfigurableElementSettings(pAreaConfiguration, xmlConfigurableElementSettingsElement, xmlDomainSerializingContext, false)) { + + return false; + } + } + + // Reorder area configurations according to XML content + reorderAreaConfigurations(areaConfigurationList); + + return true; +} + +// XML configuration settings composing +void CDomainConfiguration::composeSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext) const +{ + // Go through all are configurations + AreaConfigurationListIterator it; + + for (it = _orderedAreaConfigurationList.begin(); it != _orderedAreaConfigurationList.end(); ++it) { + + const CAreaConfiguration* pAreaConfiguration = *it; + + // Retrieve configurable element + const CConfigurableElement* pConfigurableElement = pAreaConfiguration->getConfigurableElement(); + + // Create configurable element child element + CXmlElement xmlConfigurableElementSettingsElement; + + xmlConfigurationSettingsElement.createChild(xmlConfigurableElementSettingsElement, "ConfigurableElement"); + + // Set Path attribute + xmlConfigurableElementSettingsElement.setAttributeString("Path", pConfigurableElement->getPath()); + + // Delegate composing to area configuration + ((CDomainConfiguration&)(*this)).serializeConfigurableElementSettings((CAreaConfiguration*)pAreaConfiguration, xmlConfigurableElementSettingsElement, serializingContext, true); + } +} + +// Serialize one configuration for one configurable element +bool CDomainConfiguration::serializeConfigurableElementSettings(CAreaConfiguration* pAreaConfiguration, CXmlElement& xmlConfigurableElementSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut) +{ + // Actual XML context + CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); + + // Configurable Element + const CConfigurableElement* pConfigurableElement = pAreaConfiguration->getConfigurableElement(); + + // Element content + CXmlElement xmlConfigurableElementSettingsElementContent; + + // Deal with element itself + if (!bSerializeOut) { + + // Check structure + if (xmlConfigurableElementSettingsElement.getNbChildElements() != 1) { + + // Structure error + serializingContext.setError("Struture error encountered while parsing settings of " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " in Configuration " + getPath()); + + return false; + } + + // Check name and kind + if (!xmlConfigurableElementSettingsElement.getChildElement(pConfigurableElement->getKind(), pConfigurableElement->getName(), xmlConfigurableElementSettingsElementContent)) { + + serializingContext.setError("Couldn't find settings for " + pConfigurableElement->getKind() + " " + pConfigurableElement->getName() + " for Configuration " + getPath()); + + return false; + } + } else { + + // Create child XML element + xmlConfigurableElementSettingsElement.createChild(xmlConfigurableElementSettingsElementContent, pConfigurableElement->getKind()); + + // Set Name + xmlConfigurableElementSettingsElementContent.setNameAttribute(pConfigurableElement->getName()); + } + + // Change context type to parameter settings access + string strError; + + // Create configuration access context + CConfigurationAccessContext configurationAccessContext(strError, bSerializeOut); + + // Provide current value space + configurationAccessContext.setValueSpaceRaw(xmlDomainSerializingContext.valueSpaceIsRaw()); + + // Provide current output raw format + configurationAccessContext.setOutputRawFormat(xmlDomainSerializingContext.outputRawFormatIsHex()); + + // Get subsystem + const CSubsystem* pSubsystem = pConfigurableElement->getBelongingSubsystem(); + + if (pSubsystem && pSubsystem != pConfigurableElement) { + + // Element is a descendant of subsystem - // Delegate to corresponding area configuration - return pAreaConfiguration->serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext); + // Deal with Endianness + configurationAccessContext.setBigEndianSubsystem(pSubsystem->isBigEndian()); + } + + // Have domain configuration parse settings for configurable element + if (!pAreaConfiguration->serializeXmlSettings(xmlConfigurableElementSettingsElementContent, configurationAccessContext)) { + + // Forward error + xmlDomainSerializingContext.setError(strError); + + return false; + } + return true; } // Configurable Elements association -void CDomainConfiguration::addConfigurableElement(const CConfigurableElement* pConfigurableElement) +void CDomainConfiguration::addConfigurableElement(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet) { - _areaConfigurationList.push_back(new CAreaConfiguration(pConfigurableElement)); + CAreaConfiguration* pAreaConfiguration = new CAreaConfiguration(pConfigurableElement, pSyncerSet); + + _areaConfigurationList.push_back(pAreaConfiguration); + _orderedAreaConfigurationList.push_back(pAreaConfiguration); } void CDomainConfiguration::removeConfigurableElement(const CConfigurableElement* pConfigurableElement) @@ -85,10 +222,66 @@ void CDomainConfiguration::removeConfigurableElement(const CConfigurableElement* CAreaConfiguration* pAreaConfigurationToRemove = getAreaConfiguration(pConfigurableElement); _areaConfigurationList.remove(pAreaConfigurationToRemove); + _orderedAreaConfigurationList.remove(pAreaConfigurationToRemove); delete pAreaConfigurationToRemove; } +// Sequence management +bool CDomainConfiguration::setElementSequence(const vector<string>& astrNewElementSequence, string& strError) +{ + // Build a new list of AreaConfiguration objects + list<CAreaConfiguration*> areaConfigurationList; + + uint32_t uiConfigurableElement; + + for (uiConfigurableElement = 0; uiConfigurableElement < astrNewElementSequence.size(); uiConfigurableElement++) { + + string strConfigurableElementPath = astrNewElementSequence[uiConfigurableElement]; + + CAreaConfiguration* pAreaConfiguration = findAreaConfiguration(strConfigurableElementPath); + + if (!pAreaConfiguration) { + + strError = "Element " + strConfigurableElementPath + " not found in domain"; + + return false; + } + // Check not already present in the list + if (findAreaConfiguration(strConfigurableElementPath, areaConfigurationList)) { + + strError = "Element " + strConfigurableElementPath + " provided more than once"; + + return false; + } + + // Store new ordered area configuration + areaConfigurationList.push_back(pAreaConfiguration); + } + + // Reorder area configurations according to given path list + reorderAreaConfigurations(areaConfigurationList); + + return true; +} + +void CDomainConfiguration::getElementSequence(string& strResult) const +{ + strResult = "\n"; + + AreaConfigurationListIterator it; + + // List configurable element paths out of ordered area configuration list + for (it = _orderedAreaConfigurationList.begin(); it != _orderedAreaConfigurationList.end(); ++it) { + + const CAreaConfiguration* pAreaConfiguration = *it; + + const CConfigurableElement* pConfigurableElement = pAreaConfiguration->getConfigurableElement(); + + strResult += pConfigurableElement->getPath() + "\n"; + } +} + // Save data from current void CDomainConfiguration::save(const CParameterBlackboard* pMainBlackboard) { @@ -104,17 +297,22 @@ void CDomainConfiguration::save(const CParameterBlackboard* pMainBlackboard) } // Apply data to current -void CDomainConfiguration::restore(CParameterBlackboard* pMainBlackboard) const +bool CDomainConfiguration::restore(CParameterBlackboard* pMainBlackboard, bool bSync, string& strError) const { AreaConfigurationListIterator it; // Just propagate to areas - for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + for (it = _orderedAreaConfigurationList.begin(); it != _orderedAreaConfigurationList.end(); ++it) { const CAreaConfiguration* pAreaConfiguration = *it; - pAreaConfiguration->restore(pMainBlackboard); + if (!pAreaConfiguration->restore(pMainBlackboard, bSync, strError)) { + + return false; + } } + + return true; } // Ensure validity for configurable element area configuration @@ -238,6 +436,101 @@ CAreaConfiguration* CDomainConfiguration::getAreaConfiguration(const CConfigurab return NULL; } +// AreaConfiguration retrieval from present area configurations +CAreaConfiguration* CDomainConfiguration::findAreaConfiguration(const string& strConfigurableElementPath) const +{ + AreaConfigurationListIterator it; + + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + if (pAreaConfiguration->getConfigurableElement()->getPath() == strConfigurableElementPath) { + + return pAreaConfiguration; + } + } + + // Not found + return NULL; +} + +// AreaConfiguration retrieval from given area configuration list +CAreaConfiguration* CDomainConfiguration::findAreaConfiguration(const string& strConfigurableElementPath, const list<CAreaConfiguration*>& areaConfigurationList) const +{ + AreaConfigurationListIterator it; + + for (it = areaConfigurationList.begin(); it != areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + if (pAreaConfiguration->getConfigurableElement()->getPath() == strConfigurableElementPath) { + + return pAreaConfiguration; + } + } + + // Not found + return NULL; +} + +// Area configuration ordering +void CDomainConfiguration::reorderAreaConfigurations(const list<CAreaConfiguration*>& areaConfigurationList) +{ + // Ensure elements in provided list appear first and ordered the same way in internal one + + // Remove all elements present in the provided list from the internal one + AreaConfigurationListIterator it; + + for (it = areaConfigurationList.begin(); it != areaConfigurationList.end(); ++it) { + + _orderedAreaConfigurationList.remove(*it); + } + + // Prepended provided elements into internal list + _orderedAreaConfigurationList.insert(_orderedAreaConfigurationList.begin(), areaConfigurationList.begin(), areaConfigurationList.end()); +} + +// Find area configuration rank from regular list: for ordered list maintainance +uint32_t CDomainConfiguration::getAreaConfigurationRank(const CAreaConfiguration* pAreaConfiguration) const +{ + uint32_t uiAreaConfigurationRank; + AreaConfigurationListIterator it; + + // Propagate request to areas + for (it = _areaConfigurationList.begin(), uiAreaConfigurationRank = 0; it != _areaConfigurationList.end(); ++it, ++uiAreaConfigurationRank) { + + if (*it == pAreaConfiguration) { + + return uiAreaConfigurationRank; + } + } + + assert(0); + + return 0; +} + +// Find area configuration from regular list based on rank: for ordered list maintainance +CAreaConfiguration* CDomainConfiguration::getAreaConfiguration(uint32_t uiAreaConfigurationRank) const +{ + AreaConfigurationListIterator it; + uint32_t uiCurrentAreaConfigurationRank; + + // Propagate request to areas + for (it = _areaConfigurationList.begin(), uiCurrentAreaConfigurationRank = 0; it != _areaConfigurationList.end(); ++it, ++uiCurrentAreaConfigurationRank) { + + if (uiCurrentAreaConfigurationRank == uiAreaConfigurationRank) { + + return *it; + } + } + + assert(0); + + return NULL; +} + // Presence of application condition bool CDomainConfiguration::hasRule() const { @@ -259,7 +552,36 @@ void CDomainConfiguration::binarySerialize(CBinaryStream& binaryStream) { AreaConfigurationListIterator it; - // Just propagate to areas + // Area configurations order + if (binaryStream.isOut()) { + + for (it = _orderedAreaConfigurationList.begin(); it != _orderedAreaConfigurationList.end(); ++it) { + + // Get rank + uint32_t uiAreaConfigurationRank = getAreaConfigurationRank(*it); + + // Store it + binaryStream.write((const uint8_t*)&uiAreaConfigurationRank, sizeof(uiAreaConfigurationRank)); + } + } else { + + // Empty ordered list first + _orderedAreaConfigurationList.resize(0); + + uint32_t uiAreaConfiguration; + + for (uiAreaConfiguration = 0; uiAreaConfiguration < _areaConfigurationList.size(); uiAreaConfiguration++) { + + // Get rank + uint32_t uiAreaConfigurationRank; + + binaryStream.read((uint8_t*)&uiAreaConfigurationRank, sizeof(uiAreaConfigurationRank)); + + _orderedAreaConfigurationList.push_back(getAreaConfiguration(uiAreaConfigurationRank)); + } + } + + // Propagate to areas for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { CAreaConfiguration* pAreaConfiguration = *it; @@ -271,10 +593,14 @@ void CDomainConfiguration::binarySerialize(CBinaryStream& binaryStream) // Data size uint32_t CDomainConfiguration::getDataSize() const { - uint32_t uiDataSize = 0; + uint32_t uiDataSize; + + // Add necessary size to store area configurations order + uiDataSize = _areaConfigurationList.size() * sizeof(uint32_t); + + // Propagate request to areas AreaConfigurationListIterator it; - // Just propagate request to areas for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { const CAreaConfiguration* pAreaConfiguration = *it; diff --git a/parameter/DomainConfiguration.h b/parameter/DomainConfiguration.h index 26b0c41..981ef77 100644 --- a/parameter/DomainConfiguration.h +++ b/parameter/DomainConfiguration.h @@ -38,6 +38,7 @@ class CAreaConfiguration; class CParameterBlackboard; class CConfigurationAccessContext; class CCompoundRule; +class CSyncerSet; class CDomainConfiguration : public CBinarySerializableElement { @@ -50,13 +51,17 @@ public: virtual ~CDomainConfiguration(); // Configurable Elements association - void addConfigurableElement(const CConfigurableElement* pConfigurableElement); + void addConfigurableElement(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet); void removeConfigurableElement(const CConfigurableElement* pConfigurableElement); + // Sequence management + bool setElementSequence(const vector<string>& astrNewElementSequence, string& strError); + void getElementSequence(string& strResult) const; + // Save data from current void save(const CParameterBlackboard* pMainBlackboard); // Apply data to current - void restore(CParameterBlackboard* pMainBlackboard) const; + bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, string& strError) const; // Ensure validity for configurable element area configuration void validate(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard); // Ensure validity of all area configurations @@ -75,7 +80,8 @@ public: void split(CConfigurableElement* pFromConfigurableElement); // XML configuration settings parsing/composing - bool serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); + bool parseSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext); + void composeSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext) const; // Presence of application condition bool hasRule() const; @@ -91,12 +97,25 @@ public: private: // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean) virtual bool childrenAreDynamic() const; + // XML configuration settings serializing + bool serializeConfigurableElementSettings(CAreaConfiguration* pAreaConfiguration, CXmlElement& xmlConfigurableElementSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut); // AreaConfiguration retrieval from configurable element CAreaConfiguration* getAreaConfiguration(const CConfigurableElement* pConfigurableElement) const; + // AreaConfiguration retrieval from present area configurations + CAreaConfiguration* findAreaConfiguration(const string& strConfigurableElementPath) const; + // AreaConfiguration retrieval from given area configuration list + CAreaConfiguration* findAreaConfiguration(const string& strConfigurableElementPath, const list<CAreaConfiguration*>& areaConfigurationList) const; + // Area configuration ordering + void reorderAreaConfigurations(const list<CAreaConfiguration*>& areaConfigurationList); + // Find area configuration rank from regular list: for ordered list maintainance + uint32_t getAreaConfigurationRank(const CAreaConfiguration* pAreaConfiguration) const; + // Find area configuration from regular list based on rank: for ordered list maintainance + CAreaConfiguration* getAreaConfiguration(uint32_t uiAreaConfigurationRank) const; // Rule const CCompoundRule* getRule() const; // AreaConfigurations list<CAreaConfiguration*> _areaConfigurationList; + list<CAreaConfiguration*> _orderedAreaConfigurationList; }; diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index d5932e3..0fcd4e2 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -103,8 +103,6 @@ const char* gacSystemSchemasSubFolder = "Schemas"; // Remote command parser array const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = { - /// Help - { "help", &CParameterMgr::helpCommandProcess, 0, "", "Show commands description and usage" }, /// Version { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" }, /// Status @@ -129,6 +127,8 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" }, { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" }, { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" }, + { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" }, + { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" }, { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" }, { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" }, { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" }, @@ -140,6 +140,8 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" }, { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" }, { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" }, + { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 2, "<domain> <configuration> <elem path list>", "Set element application order for configuration" }, + { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" }, /// Elements/Parameters { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" }, { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" }, @@ -193,6 +195,22 @@ CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFol // Feed element library feedElementLibraries(); + + _pCommandHandler = new CCommandHandler(this); + + // Add command parsers + uint32_t uiRemoteCommandParserItem; + + for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { + + const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; + + _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName, + pRemoteCommandParserItem->_pfnParser, + pRemoteCommandParserItem->_uiMinArgumentCount, + pRemoteCommandParserItem->_pcHelp, + pRemoteCommandParserItem->_pcDescription); + } } CParameterMgr::~CParameterMgr() @@ -248,6 +266,21 @@ void CParameterMgr::unnestLog() const _uiLogDepth--; } +// Version +string CParameterMgr::getVersion() const +{ + string strVersion; + + // Major + strVersion = toString(guiEditionMajor) + "."; + // Minor + strVersion += toString(guiEditionMinor) + "."; + // Revision + strVersion += toString(guiRevision); + + return strVersion; +} + bool CParameterMgr::load(string& strError) { CAutoLog autoLog(this, "Loading"); @@ -464,6 +497,9 @@ bool CParameterMgr::loadSettings(string& strError) // Selection criteria definition for rule creation xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + // Auto validation of configurations if no binary settings provided + xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation); + log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with"); // Do parse @@ -581,119 +617,20 @@ bool CParameterMgr::applyConfigurations(string& strError) return true; } -// Command processing -bool CParameterMgr::remoteCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) -{ - log("Processing remote command: \"%s\"", remoteCommand.getCommand().c_str()); - - // Dispatch - uint32_t uiRemoteCommandParserItem; - - for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { - - const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; - - if (string(pRemoteCommandParserItem->_pcCommandName) == remoteCommand.getCommand()) { - - // Check enough arguments supplied - if (remoteCommand.getArgumentCount() < pRemoteCommandParserItem->_uiMinArgumentCount) { - - strResult = string("Not enough arguments supplied\nUsage:\n") + pRemoteCommandParserItem->usage(); - - return false; - } - - switch ((this->*pRemoteCommandParserItem->_pfnParser)(remoteCommand, strResult)) { - case EDone: - strResult = "Done"; - case ESucceeded: - return true; - case EShowUsgae: - strResult = pRemoteCommandParserItem->usage(); - // Fall through intentionally - case EFailed: - return false; - default: - assert(0); - } - } - } - // Not found - strResult = "Command not found!"; - - return false; -} - -// Max command usage length, use for formatting -void CParameterMgr::setMaxCommandUsageLength() -{ - // Show usages - uint32_t uiRemoteCommandParserItem; - - for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { - - const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; - - uint32_t uiRemoteCommandUsageLength = pRemoteCommandParserItem->usage().length(); - - if (uiRemoteCommandUsageLength > _uiMaxCommandUsageLength) { - - _uiMaxCommandUsageLength = uiRemoteCommandUsageLength; - } - } -} - /////////////////// Remote command parsers -/// Help -CParameterMgr::CommandStatus CParameterMgr::helpCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) -{ - (void)remoteCommand; - - strResult = "\n"; - - // Show usages - uint32_t uiRemoteCommandParserItem; - - for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { - - const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; - - string strUsage = pRemoteCommandParserItem->usage(); - - strResult += strUsage; - - // Align - uint32_t uiToSpacesAdd = _uiMaxCommandUsageLength + 5 - strUsage.length(); - - while (uiToSpacesAdd--) { - - strResult += " "; - } - - strResult += string("=> ") + string(pRemoteCommandParserItem->_pcDescription) + "\n"; - - } - return ESucceeded; -} - /// Version -CParameterMgr::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; - // Show versions - // Major - strResult = toString(guiEditionMajor) + "."; - // Minor - strResult += toString(guiEditionMinor) + "."; - // Revision - strResult += toString(guiRevision); + // Show version + strResult = getVersion(); - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Status -CParameterMgr::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; // System class @@ -745,42 +682,42 @@ CParameterMgr::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCo getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false); strResult += strSelectionCriteria; - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Tuning Mode -CParameterMgr::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { if (remoteCommand.getArgument(0) == "on") { if (setTuningMode(true, strResult)) { - return EDone; + return CCommandHandler::EDone; } } else if (remoteCommand.getArgument(0) == "off") { if (setTuningMode(false, strResult)) { - return EDone; + return CCommandHandler::EDone; } } else { // Show usage - return EShowUsgae; + return CCommandHandler::EShowUsage; } - return EFailed; + return CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; strResult = tuningModeOn() ? "on" : "off"; - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Value Space -CParameterMgr::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)strResult; @@ -788,32 +725,32 @@ CParameterMgr::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const I setValueSpace(true); - return EDone; + return CCommandHandler::EDone; } else if (remoteCommand.getArgument(0) == "real") { setValueSpace(false); - return EDone; + return CCommandHandler::EDone; } else { // Show usage - return EShowUsgae; + return CCommandHandler::EShowUsage; } - return EFailed; + return CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; strResult = valueSpaceIsRaw() ? "raw" : "real"; - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Output Raw Format -CParameterMgr::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)strResult; @@ -821,156 +758,226 @@ CParameterMgr::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(co setOutputRawFormat(true); - return EDone; + return CCommandHandler::EDone; } else if (remoteCommand.getArgument(0) == "dec") { setOutputRawFormat(false); - return EDone; + return CCommandHandler::EDone; } else { // Show usage - return EShowUsgae; + return CCommandHandler::EShowUsage; } - return EFailed; + return CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; strResult = outputRawFormatIsHex() ? "hex" : "dec"; - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Sync -CParameterMgr::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { if (remoteCommand.getArgument(0) == "on") { if (setAutoSync(true, strResult)) { - return EDone; + return CCommandHandler::EDone; } } else if (remoteCommand.getArgument(0) == "off") { if (setAutoSync(false, strResult)) { - return EDone; + return CCommandHandler::EDone; } } else { // Show usage - return EShowUsgae; + return CCommandHandler::EShowUsage; } - return EFailed; + return CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; strResult = autoSyncOn() ? "on" : "off"; - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; - return sync(strResult) ? EDone : EFailed; + return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } /// Criteria -CParameterMgr::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; getSelectionCriteria()->listSelectionCriteria(strResult, true); - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Domains -CParameterMgr::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; - getConfigurableDomains()->listChildren(strResult); + getConfigurableDomains()->listDomains(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return createDomain(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; + return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return deleteDomain(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; + return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? ESucceeded : EFailed; + // Check tuning mode + if (!checkTuningModeOn(strResult)) { + + return CCommandHandler::EFailed; + } + + // Set property + bool bSequenceAware; + + if (remoteCommand.getArgument(1) == "true") { + + bSequenceAware = true; + + } else if (remoteCommand.getArgument(1) == "false") { + + bSequenceAware = false; + + } else { + // Show usage + return CCommandHandler::EShowUsage; + } + + return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + // Get property + bool bSequenceAware; + + if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) { + + return CCommandHandler::EFailed; + } + + strResult = bSequenceAware ? "true" : "false"; + + return CCommandHandler::ESucceeded; +} + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; +} + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } /// Configurations -CParameterMgr::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? ESucceeded : EFailed; + return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? EDone : EFailed; + return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; + return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; +} + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + // Check tuning mode + if (!checkTuningModeOn(strResult)) { + + return CCommandHandler::EFailed; + } + + // Build configurable element path list + vector<string> astrNewElementSequence; + + uint32_t uiArgument; + + for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) { + + astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument)); + } + + // Delegate to configurable domains + return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; +} + +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + // Delegate to configurable domains + return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; } /// Elements/Parameters -CParameterMgr::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass(), false); @@ -978,7 +985,7 @@ CParameterMgr::CommandStatus CParameterMgr::listElementsCommmandProcess(const IR if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } strResult = string("\n"); @@ -994,11 +1001,11 @@ CParameterMgr::CommandStatus CParameterMgr::listElementsCommmandProcess(const IR // Return sub-elements strResult += pLocatedElement->listQualifiedPaths(false); - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Elements/Parameters -CParameterMgr::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass(), false); @@ -1006,7 +1013,7 @@ CParameterMgr::CommandStatus CParameterMgr::listParametersCommmandProcess(const if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } strResult = string("\n"); @@ -1022,10 +1029,10 @@ CParameterMgr::CommandStatus CParameterMgr::listParametersCommmandProcess(const // Return sub-elements strResult += pLocatedElement->listQualifiedPaths(true); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass()); @@ -1033,7 +1040,7 @@ CParameterMgr::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRe if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } string strError; @@ -1043,10 +1050,10 @@ CParameterMgr::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRe // Dump elements pLocatedElement->dumpContent(strResult, parameterAccessContext); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass()); @@ -1054,7 +1061,7 @@ CParameterMgr::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } // Converted to actual sizable element @@ -1063,10 +1070,10 @@ CParameterMgr::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const // Get size as string strResult = pConfigurableElement->getFootprintAsString(); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass()); @@ -1074,7 +1081,7 @@ CParameterMgr::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } // Convert element @@ -1083,29 +1090,29 @@ CParameterMgr::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const // Return element properties pConfigurableElement->showProperties(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { string strValue; if (!getValue(remoteCommand.getArgument(0), strValue, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } // Succeeded strResult = strValue; - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1), strResult) ? EDone : EFailed; + return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass()); @@ -1113,7 +1120,7 @@ CParameterMgr::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess( if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } // Convert element @@ -1122,10 +1129,10 @@ CParameterMgr::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess( // Return element belonging domains pConfigurableElement->listBelongingDomains(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { CElementLocator elementLocator(getSystemClass()); @@ -1133,7 +1140,7 @@ CParameterMgr::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { - return EFailed; + return CCommandHandler::EFailed; } // Convert element @@ -1142,65 +1149,65 @@ CParameterMgr::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess // Return element belonging domains pConfigurableElement->listAssociatedDomains(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; getConfigurableDomains()->listAssociatedElements(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; getConfigurableDomains()->listConflictingElements(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } -CParameterMgr::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; getSystemClass()->listRogueElements(strResult); - return ESucceeded; + return CCommandHandler::ESucceeded; } /// Settings Import/Export -CParameterMgr::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? EDone : EFailed; + return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? EDone : EFailed; + return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? EDone : EFailed; + return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? EDone : EFailed; + return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; + return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } -CParameterMgr::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; + return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; } // User set/get parameters @@ -1516,7 +1523,7 @@ bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { - return EFailed; + return CCommandHandler::EFailed; } // Convert element @@ -1540,7 +1547,7 @@ bool CParameterMgr::split(const string& strDomain, const string& strConfigurable if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { - return EFailed; + return CCommandHandler::EFailed; } // Convert element @@ -1622,7 +1629,7 @@ bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettin } // Compose - xmlComposer.compose(pConfigurableDomains); + xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion()); // Close composer if (!xmlComposer.close()) { @@ -1664,11 +1671,7 @@ bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strEr return false; } - // Check tuning mode - if (!checkTuningModeOn(strError)) { - return false; - } // Root element CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); @@ -1774,10 +1777,7 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) } // Create server - _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), this); - - // Compute max command usage length - setMaxCommandUsageLength(); + _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), _pCommandHandler); log("Starting remote processor server on port %d", _pSystemClassConfiguration->getServerPort()); // Start diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 4596843..ef2bd90 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -31,7 +31,7 @@ #pragma once #include <pthread.h> -#include "RemoteCommandHandler.h" +#include "RemoteCommandHandlerTemplate.h" #include "PathNavigator.h" #include "SelectionCriterionType.h" #include "SelectionCriterion.h" @@ -51,7 +51,7 @@ class CConfigurableDomains; class IRemoteProcessorServerInterface; class CBackSynchronizer; -class CParameterMgr : private CElement, private IRemoteCommandHandler +class CParameterMgr : private CElement { enum ChildElement { EFrameworkConfiguration, @@ -64,16 +64,10 @@ class CParameterMgr : private CElement, private IRemoteCommandHandler EParameterCreationLibrary, EParameterConfigurationLibrary }; - // Remote command execution status - enum CommandStatus { - EDone, - ESucceeded, - EFailed, - EShowUsgae - }; + typedef TRemoteCommandHandlerTemplate<CParameterMgr> CCommandHandler; // Remote command parsers - typedef CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, string& strResult); + typedef CCommandHandler::CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, string& strResult); // Parser descriptions struct SRemoteCommandParserItem @@ -83,18 +77,11 @@ class CParameterMgr : private CElement, private IRemoteCommandHandler uint32_t _uiMinArgumentCount; const char* _pcHelp; const char* _pcDescription; - - // Usage - string usage() const - { - return string(_pcCommandName) + " " + _pcHelp; - } }; - // Version - static const uint32_t guiEditionMajor = 0x0; - static const uint32_t guiEditionMinor = 0x2; - static const uint32_t guiRevision = 0x1; + static const uint32_t guiEditionMajor = 0x1; + static const uint32_t guiEditionMinor = 0x0; + static const uint32_t guiRevision = 0x0; public: // Logger interface class ILogger @@ -180,68 +167,70 @@ private: virtual void nestLog() const; virtual void unnestLog() const; - // From IRemoteCommandHandler: return true on success, fill result in any cases - virtual bool remoteCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + // Version + string getVersion() const; ////////////////:: Remote command parsers - /// Help - CommandStatus helpCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Version - CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Status - CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Tuning Mode - CommandStatus setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Value Space - CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Output Raw Format - CommandStatus setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Sync - CommandStatus setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Criteria - CommandStatus listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Domains - CommandStatus listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Configurations - CommandStatus listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Elements/Parameters - CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Browse - CommandStatus listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); /// Settings Import/Export - CommandStatus exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); - CommandStatus importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); // Max command usage length, use for formatting void setMaxCommandUsageLength(); @@ -318,6 +307,9 @@ private: // Whole system structure checksum uint8_t _uiStructureChecksum; + // Command Handler + CCommandHandler* _pCommandHandler; + // Remote Processor Server IRemoteProcessorServerInterface* _pRemoteProcessorServer; diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index 2ce45fa..ae6c038 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -34,7 +34,7 @@ #include <assert.h> #ifdef SIMULATION -const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/Documents/gingerbread2/hardware/intel/PRIVATE/parameter-framework/XML"; +const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/Documents/gingerbread3/hardware/intel/PRIVATE/parameter-framework/XML"; #else const char* gpcParameterFrameworkConfigurationFolderPath = "/etc/parameter-framework"; #endif diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp index d3e561b..2f9f326 100644 --- a/parameter/SelectionCriterion.cpp +++ b/parameter/SelectionCriterion.cpp @@ -49,9 +49,9 @@ void CSelectionCriterion::setCriterionState(int iState) // Check for a change if (_iState != iState) { - CAutoLog autoLog(this, "Selection criterion changed event: " + getFormattedDescription(false)); - _iState = iState; + + log("Selection criterion changed event: %s", getFormattedDescription(false).c_str()); } } diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index f0f1985..ce6275b 100644 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -35,6 +35,7 @@ #include <stdlib.h> #include <string.h> #include <sstream> +#include <stdarg.h> CSubsystemObject::CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement) : _pInstanceConfigurableElement(pInstanceConfigurableElement), @@ -132,7 +133,7 @@ bool CSubsystemObject::receiveFromHW(string& strError) // Fall back HW access bool CSubsystemObject::accessHW(bool bReceive, string& strError) { - // Default access falls back + // Default access fall back if (bReceive) { return receiveFromHW(strError); @@ -160,3 +161,18 @@ void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize) _uiAccessedIndex += uiSize; } + +// Logging +void CSubsystemObject::log(const string& strMessage, ...) const +{ + char acBuffer[512]; + va_list listPointer; + + va_start(listPointer, strMessage); + + vsnprintf(acBuffer, sizeof(acBuffer), strMessage.c_str(), listPointer); + + va_end(listPointer); + + _pInstanceConfigurableElement->log(acBuffer); +} diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index e702c87..711d9d1 100644 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h @@ -61,6 +61,8 @@ protected: // Blackboard access from subsystems void blackboardRead(void* pvData, uint32_t uiSize); void blackboardWrite(const void* pvData, uint32_t uiSize); + // Logging + void log(const string& strMessage, ...) const; private: // Instance element to sync from/to CInstanceConfigurableElement* _pInstanceConfigurableElement; diff --git a/parameter/XmlDomainSerializingContext.cpp b/parameter/XmlDomainSerializingContext.cpp index cb5a20d..ef3328f 100644 --- a/parameter/XmlDomainSerializingContext.cpp +++ b/parameter/XmlDomainSerializingContext.cpp @@ -33,7 +33,7 @@ #define base CXmlElementSerializingContext CXmlDomainSerializingContext::CXmlDomainSerializingContext(string& strError, bool bWithSettings) - : base(strError), _bWithSettings(bWithSettings), _bValueSpaceIsRaw(false), _bOutputRawFormatIsHex(false), _pSelectionCriteriaDefinition(NULL) + : base(strError), _bWithSettings(bWithSettings), _bValueSpaceIsRaw(false), _bOutputRawFormatIsHex(false), _pSelectionCriteriaDefinition(NULL), _bAutoValidationRequired(true) { } @@ -75,3 +75,14 @@ const CSelectionCriteriaDefinition* CXmlDomainSerializingContext::getSelectionCr { return _pSelectionCriteriaDefinition; } + +// Auto validation of configurations +void CXmlDomainSerializingContext::setAutoValidationRequired(bool bAutoValidationRequired) +{ + _bAutoValidationRequired = bAutoValidationRequired; +} + +bool CXmlDomainSerializingContext::autoValidationRequired() const +{ + return _bAutoValidationRequired; +} diff --git a/parameter/XmlDomainSerializingContext.h b/parameter/XmlDomainSerializingContext.h index c63552c..7cf58e5 100644 --- a/parameter/XmlDomainSerializingContext.h +++ b/parameter/XmlDomainSerializingContext.h @@ -51,13 +51,13 @@ public: void setOutputRawFormat(bool bIsHex); bool outputRawFormatIsHex(); - // ParameterBlackboard - const CParameterBlackboard* getParameterBlackboard() const; - // Criteria defintion void setSelectionCriteriaDefinition(const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition); const CSelectionCriteriaDefinition* getSelectionCriteriaDefinition() const; + // Auto validation of configurations + void setAutoValidationRequired(bool bAutoValidationRequired); + bool autoValidationRequired() const; private: // Indicate wheter or not to import settings bool _bWithSettings; @@ -67,4 +67,6 @@ private: bool _bOutputRawFormatIsHex; // Criteria defintion const CSelectionCriteriaDefinition* _pSelectionCriteriaDefinition; + // Auto validation of configurations + bool _bAutoValidationRequired; }; diff --git a/xmlserializer/XmlComposer.cpp b/xmlserializer/XmlComposer.cpp index 2cdd5dc..ff607dd 100644 --- a/xmlserializer/XmlComposer.cpp +++ b/xmlserializer/XmlComposer.cpp @@ -80,7 +80,7 @@ bool CXmlComposer::close() } // Composing contents -void CXmlComposer::compose(const IXmlSource* pXmlSource) +void CXmlComposer::compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion) { // Compose document CXmlElement docElement(_pRootNode); @@ -92,7 +92,7 @@ void CXmlComposer::compose(const IXmlSource* pXmlSource) docElement.setAttributeString("xsi:noNamespaceSchemaLocation", _strXmlSchemaFile); // Comment for date/time - docElement.setComment(string(" Exported on ") + getTimeAsString() + " from parameter-framework "); + docElement.setComment(string(" Exported on ") + getTimeAsString() + " from " + strProduct + " version " + strVersion + " "); pXmlSource->toXml(docElement, _serializingContext); } diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlComposer.h index 2f5090f..4b5b822 100644 --- a/xmlserializer/XmlComposer.h +++ b/xmlserializer/XmlComposer.h @@ -47,7 +47,7 @@ public: virtual bool close(); // Composing contents - void compose(const IXmlSource* pXmlSource); + void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion); private: static string getTimeAsString(); diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp index 11b9a94..a16a31e 100644 --- a/xmlserializer/XmlElement.cpp +++ b/xmlserializer/XmlElement.cpp @@ -194,6 +194,12 @@ bool CXmlElement::getParentElement(CXmlElement& parentElement) const } // Setters +void CXmlElement::setAttributeBoolean(const string& strAttributeName, bool bValue) +{ + setAttributeString(strAttributeName, bValue ? "true" : "false"); +} + + void CXmlElement::setAttributeString(const string& strAttributeName, const string& strValue) { xmlNewProp(_pXmlElement, BAD_CAST strAttributeName.c_str(), BAD_CAST strValue.c_str()); diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h index 1028d60..ed040ad 100644 --- a/xmlserializer/XmlElement.h +++ b/xmlserializer/XmlElement.h @@ -68,6 +68,7 @@ public: bool getParentElement(CXmlElement& parentElement) const; // Setters + void setAttributeBoolean(const string& strAttributeName, bool bValue); void setAttributeString(const string& strAttributeName, const string& strValue); void setNameAttribute(const string& strValue); void setTextContent(const string& strContent); |