diff options
Diffstat (limited to 'parameter')
156 files changed, 16083 insertions, 0 deletions
diff --git a/parameter/Android.mk b/parameter/Android.mk new file mode 100644 index 0000000..8db8179 --- /dev/null +++ b/parameter/Android.mk @@ -0,0 +1,127 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES) + +LOCAL_COPY_HEADERS_TO := parameter + +LOCAL_COPY_HEADERS := \ + ParameterMgrPlatformConnector.h \ + SelectionCriterionTypeInterface.h \ + SelectionCriterionInterface.h + +LOCAL_SRC_FILES:= \ + Subsystem.cpp \ + PathNavigator.cpp \ + Element.cpp \ + SystemClass.cpp \ + ElementBuilder.cpp \ + Component.cpp \ + ParameterMgr.cpp \ + SelectionCriteria.cpp \ + SelectionCriterionLibrary.cpp \ + SelectionCriteriaDefinition.cpp \ + SelectionCriterionType.cpp \ + ElementLibrary.cpp \ + SelectionCriterionDefinition.cpp \ + SubsystemElementBuilder.cpp \ + SubsystemLibrary.cpp \ + SelectionCriterion.cpp \ + ComponentLibrary.cpp \ + ParameterBlock.cpp \ + ConfigurableElement.cpp \ + MappingData.cpp \ + ParameterBlackboard.cpp \ + ComponentType.cpp \ + TypeElement.cpp \ + InstanceConfigurableElement.cpp \ + ComponentInstance.cpp \ + ParameterBlockType.cpp \ + ParameterType.cpp \ + Parameter.cpp \ + BooleanParameterType.cpp \ + IntegerParameterType.cpp \ + ArrayParameter.cpp \ + InstanceDefinition.cpp \ + ParameterMgrPlatformConnector.cpp \ + ComputedSizeParameterType.cpp \ + ComputedSizeParameter.cpp \ + FixedPointParameterType.cpp \ + ParameterAccessContext.cpp \ + XmlFileIncluderElement.cpp \ + ParameterFrameworkConfiguration.cpp \ + FrameworkConfigurationGroup.cpp \ + FrameworkConfigurationLocation.cpp \ + KindElement.cpp \ + ElementLibrarySet.cpp \ + ErrorContext.cpp \ + SystemClassConfiguration.cpp \ + AreaConfiguration.cpp \ + DomainConfiguration.cpp \ + ConfigurableDomain.cpp \ + SyncerSet.cpp \ + ConfigurableDomains.cpp \ + BinaryStream.cpp \ + ConfigurationAccessContext.cpp \ + XmlElementSerializingContext.cpp \ + XmlParameterSerializingContext.cpp \ + XmlDomainSerializingContext.cpp \ + BinarySerializableElement.cpp \ + BitParameterBlockType.cpp \ + BitParameterBlock.cpp \ + BitParameterType.cpp \ + BitParameter.cpp \ + ElementLocator.cpp \ + ParameterMgrLogger.cpp \ + AutoLog.cpp \ + Rule.cpp \ + CompoundRule.cpp \ + SelectionCriterionRule.cpp \ + ConfigurableElementAggregator.cpp \ + BackSynchronizer.cpp \ + HardwareBackSynchronizer.cpp \ + SimulatedBackSynchronizer.cpp \ + MappingContext.cpp \ + SubsystemObject.cpp \ + SubsystemObjectCreator.cpp + + +LOCAL_MODULE:= libparameter + +LOCAL_MODULE_TAGS := optional + +TARGET_ERROR_FLAGS += -Wno-non-virtual-dtor + +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../utility/ $(LOCAL_PATH)/../xmlserializer/ $(LOCAL_PATH)/../remote-processor/ + +LOCAL_C_INCLUDES += \ + external/stlport/stlport/ \ + bionic/libstdc++ \ + bionic/ + +LOCAL_C_INCLUDES += + +LOCAL_SHARED_LIBRARIES := libstlport libdl libxmlserializer +LOCAL_STATIC_LIBRARIES := libutility + +LOCAL_LDLIBS += +LOCAL_LDFLAGS += + +include $(BUILD_SHARED_LIBRARY) + +# ==== export parameter script ======================== +include $(CLEAR_VARS) + +LOCAL_MODULE := parameter + +LOCAL_MODULE_TAGS := optional + +LOCAL_MODULE_CLASS := EXECUTABLES + +# This will install the file in /system/bin +LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES) + +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +include $(BUILD_PREBUILT) diff --git a/parameter/AreaConfiguration.cpp b/parameter/AreaConfiguration.cpp new file mode 100644 index 0000000..ecc84a7 --- /dev/null +++ b/parameter/AreaConfiguration.cpp @@ -0,0 +1,165 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "AreaConfiguration.h" +#include "ConfigurableElement.h" +#include "ConfigurationAccessContext.h" +#include "BinaryStream.h" +#include <assert.h> + +CAreaConfiguration::CAreaConfiguration(const CConfigurableElement* pConfigurableElement) : _pConfigurableElement(pConfigurableElement), _bValid(false) +{ + _blackboard.setSize(_pConfigurableElement->getFootPrint()); +} + +// Save data from current +void CAreaConfiguration::save(const CParameterBlackboard* pMainBlackboard) +{ + pMainBlackboard->saveTo(&_blackboard, _pConfigurableElement->getOffset()); +} + +// Apply data to current +void CAreaConfiguration::restore(CParameterBlackboard* pMainBlackboard) const +{ + assert(_bValid); + + pMainBlackboard->restoreFrom(&_blackboard, _pConfigurableElement->getOffset()); +} + +// Ensure validity +void CAreaConfiguration::validate(const CParameterBlackboard* pMainBlackboard) +{ + if (!_bValid) { + + // Saving from blackboard make area configuration valid + save(pMainBlackboard); + + _bValid = true; + } +} + +// Return validity +bool CAreaConfiguration::isValid() const +{ + return _bValid; +} + +// Ensure validity against given valid area configuration +void CAreaConfiguration::validateAgainst(const CAreaConfiguration* pValidAreaConfiguration) +{ + // Should be called on purpose + assert(!_bValid); + + // Check proper against area given + assert(pValidAreaConfiguration->isValid()); + + // Check compatibility + assert(_pConfigurableElement == pValidAreaConfiguration->_pConfigurableElement); + + // Copy + _blackboard.restoreFrom(&pValidAreaConfiguration->_blackboard, 0); + + // Set as valid + _bValid = true; +} + +// XML configuration settings parsing +bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext) +{ + // Assign blackboard to configuration context + configurationAccessContext.setParameterBlackboard(&_blackboard); + + // Assign base offset to configuration context + configurationAccessContext.setBaseOffset(_pConfigurableElement->getOffset()); + + // Parse configuration settings + if (_pConfigurableElement->serializeXmlSettings(xmlConfigurationSettingsElement, configurationAccessContext)) { + + if (!configurationAccessContext.serializeOut()) { + + // Serialized in areas are valid + _bValid = true; + } + return true; + } + return false; +} + +// Compound handling +const CConfigurableElement* CAreaConfiguration::getConfigurableElement() const +{ + return _pConfigurableElement; +} + +// Configuration merging (we assume from element is descendant of this) +void CAreaConfiguration::copyFromInner(const CAreaConfiguration* pFromAreaConfiguration) +{ + assert(pFromAreaConfiguration->getConfigurableElement()->isDescendantOf(_pConfigurableElement)); + + _blackboard.restoreFrom(&pFromAreaConfiguration->_blackboard, pFromAreaConfiguration->getConfigurableElement()->getOffset() - _pConfigurableElement->getOffset()); +} + +// Configuration splitting +void CAreaConfiguration::copyToInner(CAreaConfiguration* pToAreaConfiguration) const +{ + assert(pToAreaConfiguration->getConfigurableElement()->isDescendantOf(_pConfigurableElement)); + + _blackboard.saveTo(&pToAreaConfiguration->_blackboard, pToAreaConfiguration->getConfigurableElement()->getOffset() - _pConfigurableElement->getOffset()); + + // Inner becomes valid + pToAreaConfiguration->setValid(true); +} + +// Serialization +void CAreaConfiguration::serialize(CBinaryStream& binaryStream) +{ + // Delegate to blackboard + _blackboard.serialize(binaryStream); + + if (!binaryStream.isOut()) { + + // Serialized in areas are valid + _bValid = true; + } +} + +// Data size +uint32_t CAreaConfiguration::getSize() const +{ + return _blackboard.getSize(); +} + +// Store validity +void CAreaConfiguration::setValid(bool bValid) +{ + _bValid = bValid; +} + + diff --git a/parameter/AreaConfiguration.h b/parameter/AreaConfiguration.h new file mode 100644 index 0000000..4e7e2f0 --- /dev/null +++ b/parameter/AreaConfiguration.h @@ -0,0 +1,90 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterBlackboard.h" +#include "BinaryStream.h" + +using namespace std; + +class CConfigurableElement; +class CXmlElement; +class CConfigurationAccessContext; + +class CAreaConfiguration +{ +public: + CAreaConfiguration(const CConfigurableElement* pConfigurableElement); + + // Save data from current + void save(const CParameterBlackboard* pMainBlackboard); + + // Apply data to current + void restore(CParameterBlackboard* pMainBlackboard) const; + + // Ensure validity + void validate(const CParameterBlackboard* pMainBlackboard); + + // Return validity + bool isValid() const; + + // Ensure validity against given valid area configuration + void validateAgainst(const CAreaConfiguration* pValidAreaConfiguration); + + // Compound handling + const CConfigurableElement* getConfigurableElement() const; + + // Configuration merging + void copyFromInner(const CAreaConfiguration* pFromAreaConfiguration); + + // Configuration splitting + void copyToInner(CAreaConfiguration* pToAreaConfiguration) const; + + // XML configuration settings parsing/composing + bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext); + + // Serialization + void serialize(CBinaryStream& binaryStream); + + // Data size + uint32_t getSize() const; +private: + // Associated configurable element + const CConfigurableElement* _pConfigurableElement; + // Store validity + void setValid(bool bValid); + + // Configurable element settings + CParameterBlackboard _blackboard; + // Area configuration validity (invalid area configurations can't be restored) + bool _bValid; +}; + diff --git a/parameter/ArrayParameter.cpp b/parameter/ArrayParameter.cpp new file mode 100644 index 0000000..2cdae2f --- /dev/null +++ b/parameter/ArrayParameter.cpp @@ -0,0 +1,282 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ArrayParameter.h" +#include <sstream> // for istringstream +#include "Tokenizer.h" +#include "ParameterType.h" +#include "ParameterAccessContext.h" +#include "ConfigurationAccessContext.h" +#include "ParameterBlackboard.h" + +#define base CParameter + +CArrayParameter::CArrayParameter(const string& strName, const CTypeElement* pTypeElement, uint32_t uiLength) : base(strName, pTypeElement), _uiLength(uiLength) +{ +} + +uint32_t CArrayParameter::getFootPrint() const +{ + return getSize() * _uiLength; +} + +// XML configuration settings parsing +bool CArrayParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Check for value space + handleValueSpaceAttribute(xmlConfigurableElementSettingsElement, configurationAccessContext); + + // Handle access + if (!configurationAccessContext.serializeOut()) { + + // Actually set values to blackboard + if (!setValues(0, configurationAccessContext.getBaseOffset(), xmlConfigurableElementSettingsElement.getTextContent(), configurationAccessContext)) { + + return false; + } + } else { + + // Get string value + string strValue; + + // Whole array requested + getValues(configurationAccessContext.getBaseOffset(), strValue, configurationAccessContext); + + // Populate value into xml text node + xmlConfigurableElementSettingsElement.setTextContent(strValue); + } + + // Done + return true; +} + +// User set/get +bool CArrayParameter::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + uint32_t uiStartIndex; + + if (!getIndex(pathNavigator, uiStartIndex, parameterContext)) { + + return false; + } + + if (uiStartIndex == (uint32_t)-1) { + + // No index provided, start with 0 + uiStartIndex = 0; + } + + // Actually set values + if (!setValues(uiStartIndex, 0, strValue, parameterContext)) { + + return false; + } + + // Synchronize + if (parameterContext.getAutoSync() && !sync(parameterContext)) { + + // Append parameter path to error + errorContext.appendToError(" " + getPath()); + + return false; + } + + return true; +} + +bool CArrayParameter::getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + uint32_t uiIndex; + + if (!getIndex(pathNavigator, uiIndex, parameterContext)) { + + return false; + } + if (uiIndex == (uint32_t)-1) { + + // Whole array requested + getValues(0, strValue, parameterContext); + + } else { + // Scalar requested + doGetValue(strValue, getOffset() + uiIndex * getSize(), parameterContext); + } + + return true; +} + +void CArrayParameter::logValue(string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Dump values + getValues(0, strValue, parameterContext); + + // Prepend unit if any + prependUnit(strValue); +} + +// Used for simulation only +void CArrayParameter::setDefaultValues(CParameterAccessContext& parameterAccessContext) const +{ + // Get default value from type + uint32_t uiDefaultValue = static_cast<const CParameterType*>(getTypeElement())->getDefaultValue(); + + // Write blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Process + uint32_t uiValueIndex; + uint32_t uiSize = getSize(); + uint32_t uiOffset = getOffset(); + bool bSubsystemIsBigEndian = parameterAccessContext.isBigEndianSubsystem(); + + for (uiValueIndex = 0; uiValueIndex < _uiLength; uiValueIndex++) { + + // Beware this code works on little endian architectures only! + pBlackboard->write(&uiDefaultValue, uiSize, uiOffset, bSubsystemIsBigEndian); + + uiOffset += uiSize; + } +} + +// Index from path +bool CArrayParameter::getIndex(CPathNavigator& pathNavigator, uint32_t& uiIndex, CErrorContext& errorContext) const +{ + uiIndex = (uint32_t)-1; + + string* pStrChildName = pathNavigator.next(); + + if (pStrChildName) { + + // Check index is numeric + istringstream iss(*pStrChildName); + + iss >> uiIndex; + + if (!iss) { + + errorContext.setError("Expected numerical expression as last item in " + pathNavigator.getCurrentPath()); + + return false; + } + + if (uiIndex >= _uiLength) { + ostringstream oss; + + oss << "Provided index out of range (max is " << _uiLength - 1 << ")"; + + errorContext.setError(oss.str()); + + return false; + } + + // Check no other item provided in path + pStrChildName = pathNavigator.next(); + + if (pStrChildName) { + + // Should be leaf element + errorContext.setError("Path not found: " + pathNavigator.getCurrentPath()); + + return false; + } + } + + return true; +} + +// Common set value processing +bool CArrayParameter::setValues(uint32_t uiStartIndex, uint32_t uiBaseOffset, const string& strValue, CParameterAccessContext& parameterContext) const +{ + // Deal with value(s) + Tokenizer tok(strValue); + + vector<string> astrValues = tok.split(); + uint32_t uiNbValues = astrValues.size(); + + // Check number of provided values + if (uiNbValues + uiStartIndex > _uiLength) { + + // Out of bounds + parameterContext.setError("Too many values provided"); + + return false; + } + + // Process + uint32_t uiValueIndex; + uint32_t uiSize = getSize(); + uint32_t uiOffset = getOffset() + uiStartIndex * uiSize - uiBaseOffset; + + for (uiValueIndex = 0; uiValueIndex < uiNbValues; uiValueIndex++) { + + if (!doSetValue(astrValues[uiValueIndex], uiOffset, parameterContext)) { + + // Append parameter path to error + parameterContext.appendToError(" " + getPath() + "/" + getIndexAsString(uiValueIndex + uiStartIndex)); + + return false; + } + + uiOffset += uiSize; + } + return true; +} + +// Common get value processing +void CArrayParameter::getValues(uint32_t uiBaseOffset, string& strValues, CParameterAccessContext& parameterContext) const +{ + uint32_t uiValueIndex; + uint32_t uiSize = getSize(); + uint32_t uiOffset = getOffset() - uiBaseOffset; + + for (uiValueIndex = 0; uiValueIndex < _uiLength; uiValueIndex++) { + string strReadValue; + + doGetValue(strReadValue, uiOffset, parameterContext); + + strValues += strReadValue + " "; + + uiOffset += uiSize; + } +} + +string CArrayParameter::getIndexAsString(uint32_t uiIndex) +{ + ostringstream strStream; + + strStream << uiIndex; + + return strStream.str(); +} diff --git a/parameter/ArrayParameter.h b/parameter/ArrayParameter.h new file mode 100644 index 0000000..b102d06 --- /dev/null +++ b/parameter/ArrayParameter.h @@ -0,0 +1,65 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Parameter.h" + +class CArrayParameter : public CParameter +{ +public: + CArrayParameter(const string& strName, const CTypeElement* pTypeElement, uint32_t uiLength); + + // Instantiation, allocation + virtual uint32_t getFootPrint() const; + + // XML configuration settings parsing + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; +protected: + // User set/get + virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; + virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; + virtual void logValue(string& strValue, CErrorContext& errorContext) const; + // Used for simulation only + virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; + +private: + // Common set value processing + bool setValues(uint32_t uiStartIndex, uint32_t uiBaseOffset, const string& strValue, CParameterAccessContext& parameterContext) const; + // Log / get values common + void getValues(uint32_t uiBaseOffset, string& strValues, CParameterAccessContext& parameterContext) const; + // Index retrieval from user set/get request + bool getIndex(CPathNavigator& pathNavigator, uint32_t& uiIndex, CErrorContext& errorContext) const; + // Int to string conversion utility + static string getIndexAsString(uint32_t uiIndex); + + // Array length + uint32_t _uiLength; +}; diff --git a/parameter/AutoLog.cpp b/parameter/AutoLog.cpp new file mode 100644 index 0000000..b01c444 --- /dev/null +++ b/parameter/AutoLog.cpp @@ -0,0 +1,49 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "AutoLog.h" + +CAutoLog::CAutoLog(const CElement* pElement, const string& strContext) : _pElement(pElement), _strContext(strContext) +{ + // Log + _pElement->doLog(_strContext + " {"); + + // Nest + _pElement->nestLog(); +} + +CAutoLog::~CAutoLog() +{ + // Unnest + _pElement->unnestLog(); + + // Log + _pElement->doLog( "} " + _strContext); +} diff --git a/parameter/AutoLog.h b/parameter/AutoLog.h new file mode 100644 index 0000000..cdbc769 --- /dev/null +++ b/parameter/AutoLog.h @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CAutoLog +{ +public: + CAutoLog(const CElement* pElement, const string& strContext); + ~CAutoLog(); + +private: + // Logger element + const CElement* _pElement; + // Context + string _strContext; +}; + diff --git a/parameter/BackSynchronizer.cpp b/parameter/BackSynchronizer.cpp new file mode 100644 index 0000000..6c46170 --- /dev/null +++ b/parameter/BackSynchronizer.cpp @@ -0,0 +1,39 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BackSynchronizer.h" +#include "ConfigurableElement.h" + +CBackSynchronizer::CBackSynchronizer(const CConfigurableElement* pConfigurableElement) + : _configurableElementAggregator(_needingBackSyncList, &CConfigurableElement::hasNoValidDomainAssociated) +{ + // Aggegate elements + _configurableElementAggregator.aggegate(pConfigurableElement); +} diff --git a/parameter/BackSynchronizer.h b/parameter/BackSynchronizer.h new file mode 100644 index 0000000..56caf94 --- /dev/null +++ b/parameter/BackSynchronizer.h @@ -0,0 +1,55 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ConfigurableElementAggregator.h" +#include <string> + +using namespace std; + +class CParameterBlackboard; + +class CBackSynchronizer +{ +public: + CBackSynchronizer(const CConfigurableElement* pConfigurableElement); + + // Back synchronization + virtual bool sync() = 0; + +protected: + // Aggegate list + list<const CConfigurableElement*> _needingBackSyncList; +private: + // Aggegator + CConfigurableElementAggregator _configurableElementAggregator; +}; + diff --git a/parameter/BinarySerializableElement.cpp b/parameter/BinarySerializableElement.cpp new file mode 100644 index 0000000..718ba4a --- /dev/null +++ b/parameter/BinarySerializableElement.cpp @@ -0,0 +1,71 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BinarySerializableElement.h" + +#define base CElement + +CBinarySerializableElement::CBinarySerializableElement(const string& strName) : base(strName) +{ +} + +// Binary Serialization +void CBinarySerializableElement::binarySerialize(CBinaryStream& binaryStream) +{ + // Propagate + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + CBinarySerializableElement* pChild = static_cast<CBinarySerializableElement*>(getChild(uiChild)); + + pChild->binarySerialize(binaryStream); + } +} + +// Data size +uint32_t CBinarySerializableElement::getDataSize() const +{ + // Propagate + uint32_t uiDataSize = 0; + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CBinarySerializableElement* pChild = static_cast<const CBinarySerializableElement*>(getChild(uiChild)); + + uiDataSize += pChild->getDataSize(); + } + + return uiDataSize; +} + diff --git a/parameter/BinarySerializableElement.h b/parameter/BinarySerializableElement.h new file mode 100644 index 0000000..bf27789 --- /dev/null +++ b/parameter/BinarySerializableElement.h @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include "BinaryStream.h" + +class CBinarySerializableElement : public CElement +{ +public: + CBinarySerializableElement(const string& strName); + + // Serialization + virtual void binarySerialize(CBinaryStream& binaryStream); + + // Data size + virtual uint32_t getDataSize() const; +protected: +}; diff --git a/parameter/BinaryStream.cpp b/parameter/BinaryStream.cpp new file mode 100644 index 0000000..ee3beb1 --- /dev/null +++ b/parameter/BinaryStream.cpp @@ -0,0 +1,173 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BinaryStream.h" +#include <string.h> +#include <assert.h> + +using namespace std; + +CBinaryStream::CBinaryStream(const string& strFileName, bool bOut, uint32_t uiDataSize, uint8_t uiStructureChecksum) : + _strFileName(strFileName), + _bOut(bOut), + _uiDataSize(uiDataSize), + _uiStructureChecksum(uiStructureChecksum), + _puiData(new uint8_t[uiDataSize]), + _uiPos(0), + _bOpen(false) +{ +} + +CBinaryStream::~CBinaryStream() +{ + delete [] _puiData; + + if (_bOpen) { + + close(); + } +} + +bool CBinaryStream::open(string& strError) +{ + assert(!_bOpen); + + _fileStream.open(_strFileName.c_str(), (_bOut ? ios::out : ios::in|ios::ate)|ios::binary); + + if (!_fileStream.is_open() || !_fileStream.good()) { + + strError = string("Failed to ") + (_bOut ? "write" : "read") + "-open"; + + return false; + } + if (!_bOut) { + + // Get file size + ifstream::pos_type uiFileSize = _fileStream.tellg(); + + // Validate file size + if (_uiDataSize + sizeof(_uiStructureChecksum) != (uint32_t)uiFileSize) { + + // Size different from expected + strError = "Unexpected file size"; + + return false; + } + + // Back to beginning of file + _fileStream.seekg(0, ios::beg); + + // Get data + _fileStream.read((char*)_puiData, _uiDataSize); + + // File checksum + uint8_t uiFileChecksum; + _fileStream.read((char*)&uiFileChecksum, sizeof(uiFileChecksum)); + + // Data checksum + uint8_t uiDataChecksum = computeChecksum(); + + // Validate checksum + if (uiDataChecksum != uiFileChecksum) { + + strError = "Integrity checks failed"; + + return false; + } + } + + // Keep track + _bOpen = true; + + return true; +} + +void CBinaryStream::close() +{ + assert(_bOpen); + + if (_bOut) { + + // Get data + _fileStream.write((const char*)_puiData, _uiDataSize); + + // Compute checksum + uint8_t uiDataChecksum = computeChecksum(); + + // Write checksum + _fileStream.write((const char*)&uiDataChecksum, sizeof(uiDataChecksum)); + } + + // Keep track + _bOpen = false; + + // Close file + _fileStream.close(); +} + +void CBinaryStream::reset() +{ + _uiPos = 0; +} + +void CBinaryStream::write(const uint8_t* puiData, uint32_t uiSize) +{ + assert(_uiPos + uiSize <= _uiDataSize); + + memcpy(&_puiData[_uiPos], puiData, uiSize); + + _uiPos += uiSize; +} + +void CBinaryStream::read(uint8_t* puiData, uint32_t uiSize) +{ + assert(_uiPos + uiSize <= _uiDataSize); + + memcpy(puiData, &_puiData[_uiPos], uiSize); + + _uiPos += uiSize; +} + +uint8_t CBinaryStream::computeChecksum() const +{ + uint32_t uiIndex; + uint8_t uiDataChecksum = _uiStructureChecksum; + + for (uiIndex = 0; uiIndex < _uiDataSize; uiIndex++) { + + uiDataChecksum += _puiData[uiIndex]; + } + return uiDataChecksum; +} + +bool CBinaryStream::isOut() const +{ + return _bOut; +} diff --git a/parameter/BinaryStream.h b/parameter/BinaryStream.h new file mode 100644 index 0000000..fdac4eb --- /dev/null +++ b/parameter/BinaryStream.h @@ -0,0 +1,78 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> +#include <string> +#include <fstream> + +using namespace std; + +class CBinaryStream +{ +public: + CBinaryStream(const string& strFileName, bool bOut, uint32_t uiDataSize, uint8_t uiStructureChecksum); + ~CBinaryStream(); + + // Open close + bool open(string& strError); + void close(); + + // Seek + void reset(); + + // Read/Write + void write(const uint8_t* puiData, uint32_t uiSize); + void read(uint8_t* puiData, uint32_t uiSize); + + // Direction + bool isOut() const; +private: + // Checksum + uint8_t computeChecksum() const; + + // File name + string _strFileName; + // Serialization direction + bool _bOut; + uint32_t _uiDataSize; + // System structure checksum + uint8_t _uiStructureChecksum; + // Read/Write data + uint8_t* _puiData; + // File + fstream _fileStream; + // Ops in faile + uint32_t _uiPos; + // File state + bool _bOpen; +}; + diff --git a/parameter/BitParameter.cpp b/parameter/BitParameter.cpp new file mode 100644 index 0000000..f687544 --- /dev/null +++ b/parameter/BitParameter.cpp @@ -0,0 +1,180 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BitParameter.h" +#include "BitParameterType.h" +#include "ParameterAccessContext.h" +#include "ConfigurationAccessContext.h" +#include "ParameterBlackboard.h" +#include "BitParameterBlock.h" + +#define base CInstanceConfigurableElement + +CBitParameter::CBitParameter(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement) +{ +} + +// Type +CInstanceConfigurableElement::Type CBitParameter::getType() const +{ + return EBitParameter; +} + +// Size +uint32_t CBitParameter::getSize() const +{ + return static_cast<const CBitParameterBlock*>(getParent())->getSize(); +} + +// XML configuration settings parsing/composing +bool CBitParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Handle access + if (!configurationAccessContext.serializeOut()) { + + // Write to blackboard + if (!doSetValue(xmlConfigurableElementSettingsElement.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { + + // Append parameter path to error + configurationAccessContext.appendToError(" " + getPath()); + + return false; + } + } else { + + // Get string value + string strValue; + + doGetValue(strValue, getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext); + + // Populate value into xml text node + xmlConfigurableElementSettingsElement.setTextContent(strValue); + } + + // Done + return true; +} + +uint32_t CBitParameter::getFootPrint() const +{ + // Allocation made on parent side + return 0; +} + +// Dump +void CBitParameter::logValue(string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Dump value + doGetValue(strValue, getOffset(), parameterContext); +} + +// Parameter Access +bool CBitParameter::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const +{ + // Check path validity + if (!checkPathExhausted(pathNavigator, errorContext)) { + + return false; + } + // Parameter context + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Set Value + if (!doSetValue(strValue, getOffset(), parameterContext)) { + + // Append parameter path to error + parameterContext.appendToError(" " + getPath()); + + return false; + } + // Synchronize + if (!sync(parameterContext)) { + + // Append parameter path to error + parameterContext.appendToError(" " + getPath()); + + return false; + } + return true; +} + +bool CBitParameter::getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const +{ + // Check path validity + if (!checkPathExhausted(pathNavigator, errorContext)) { + + return false; + } + // Parameter context + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Get Value + doGetValue(strValue, getOffset(), parameterContext); + + return true; +} + +bool CBitParameter::doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const +{ + uint32_t uiData = 0; + + // Read/modify/write + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->read(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); + + // Convert + if (!static_cast<const CBitParameterType*>(getTypeElement())->asInteger(strValue, uiData, parameterAccessContext)) { + + return false; + } + // Write blackboard + pBlackboard->write(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); + + return true; +} + +void CBitParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const +{ + uint32_t uiData = 0; + + // Read blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->read(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); + + // Convert + static_cast<const CBitParameterType*>(getTypeElement())->asString(uiData, strValue); +} + diff --git a/parameter/BitParameter.h b/parameter/BitParameter.h new file mode 100644 index 0000000..15be074 --- /dev/null +++ b/parameter/BitParameter.h @@ -0,0 +1,66 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> + +#include "InstanceConfigurableElement.h" + +class CParameterAccessContext; +class CConfigurationAccessContext; + +class CBitParameter : public CInstanceConfigurableElement +{ +public: + CBitParameter(const string& strName, const CTypeElement* pTypeElement); + + // Instantiation, allocation + virtual uint32_t getFootPrint() const; + + // Type + virtual Type getType() const; + + // XML configuration settings parsing/composing + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; +protected: + // Parameter Access + virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; + virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; + virtual void logValue(string& strValue, CErrorContext& errorContext) const; +private: + // Size + uint32_t getSize() const; + + // Actual Access + bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + +}; diff --git a/parameter/BitParameterBlock.cpp b/parameter/BitParameterBlock.cpp new file mode 100644 index 0000000..61a38c9 --- /dev/null +++ b/parameter/BitParameterBlock.cpp @@ -0,0 +1,71 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BitParameterBlock.h" +#include "BitParameterBlockType.h" +#include "ParameterAccessContext.h" +#include "ParameterBlackboard.h" + +#define base CInstanceConfigurableElement + +CBitParameterBlock::CBitParameterBlock(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement) +{ +} + +CInstanceConfigurableElement::Type CBitParameterBlock::getType() const +{ + return EBitParameterBlock; +} + +// Instantiation, allocation +uint32_t CBitParameterBlock::getFootPrint() const +{ + return getSize(); +} + +// Size +uint32_t CBitParameterBlock::getSize() const +{ + return static_cast<const CBitParameterBlockType*>(getTypeElement())->getSize(); +} + +// Used for simulation only +void CBitParameterBlock::setDefaultValues(CParameterAccessContext& parameterAccessContext) const +{ + // Get default value from type + uint32_t uiDefaultValue = 0; + + // Write blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->write(&uiDefaultValue, getSize(), getOffset(), parameterAccessContext.isBigEndianSubsystem()); +} + diff --git a/parameter/BitParameterBlock.h b/parameter/BitParameterBlock.h new file mode 100644 index 0000000..c58859f --- /dev/null +++ b/parameter/BitParameterBlock.h @@ -0,0 +1,52 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "InstanceConfigurableElement.h" + +class CBitParameterBlock : public CInstanceConfigurableElement +{ +public: + CBitParameterBlock(const string& strName, const CTypeElement* pTypeElement); + + // Instantiation, allocation + virtual uint32_t getFootPrint() const; + + // Type + virtual Type getType() const; + + // Size + uint32_t getSize() const; + + // Used for simulation only + virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; +}; + diff --git a/parameter/BitParameterBlockType.cpp b/parameter/BitParameterBlockType.cpp new file mode 100644 index 0000000..fa4be1b --- /dev/null +++ b/parameter/BitParameterBlockType.cpp @@ -0,0 +1,70 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BitParameterBlockType.h" +#include "BitParameterBlock.h" + +#define base CTypeElement + +CBitParameterBlockType::CBitParameterBlockType(const string& strName) : base(strName), _uiSize(0) +{ +} + +string CBitParameterBlockType::getKind() const +{ + return "BitParameterBlock"; +} + +bool CBitParameterBlockType::childrenAreDynamic() const +{ + return true; +} + +// Size +uint32_t CBitParameterBlockType::getSize() const +{ + return _uiSize; +} + +// From IXmlSink +bool CBitParameterBlockType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Size + _uiSize = xmlElement.getAttributeInteger("Size") / 8; + + // Base + return base::fromXml(xmlElement, serializingContext); +} + +// Instantiation +CInstanceConfigurableElement* CBitParameterBlockType::doInstantiate() const +{ + return new CBitParameterBlock(getName(), this); +} diff --git a/parameter/BitParameterBlockType.h b/parameter/BitParameterBlockType.h new file mode 100644 index 0000000..586aee6 --- /dev/null +++ b/parameter/BitParameterBlockType.h @@ -0,0 +1,56 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "TypeElement.h" + +class CBitParameterBlockType : public CTypeElement +{ +public: + CBitParameterBlockType(const string& strName); + + // Size + uint32_t getSize() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // CElement + virtual string getKind() const; +private: + virtual bool childrenAreDynamic() const; + // Instantiation + virtual CInstanceConfigurableElement* doInstantiate() const; + + // Size in bytes + uint32_t _uiSize; +}; + diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp new file mode 100644 index 0000000..e12cd60 --- /dev/null +++ b/parameter/BitParameterType.cpp @@ -0,0 +1,136 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BitParameterType.h" +#include "BitParameter.h" +#include <stdlib.h> +#include <sstream> +#include "ParameterAccessContext.h" +#include "BitParameterBlockType.h" + +#define base CTypeElement + +CBitParameterType::CBitParameterType(const string& strName) : base(strName), _uiBitPos(0), _uiBitSize(0) +{ +} + +// CElement +string CBitParameterType::getKind() const +{ + return "BitParameter"; +} + +// From IXmlSink +bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Pos + _uiBitPos = xmlElement.getAttributeInteger("Pos"); + + // Size + _uiBitSize = xmlElement.getAttributeInteger("Size"); + + // TODO: Validate bit pos and size still fit into parent type + const CBitParameterBlockType* pBitParameterBlockType = static_cast<const CBitParameterBlockType*>(getParent()); + + uint32_t uiParentBlockBitSize = pBitParameterBlockType->getSize() << 3; + + if (_uiBitPos + _uiBitSize > uiParentBlockBitSize) { + + // Range exceeded + ostringstream strStream; + + strStream << "Pos and Size attributes inconsistent with maximum container element size (" << uiParentBlockBitSize << " bits) for " + getKind(); + + serializingContext.setError(strStream.str()); + + return false; + } + + // Base + return base::fromXml(xmlElement, serializingContext); +} + +// Conversion +bool CBitParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const +{ + uint32_t uiConvertedValue = strtoul(strValue.c_str(), NULL, 0); + + if (uiConvertedValue > getMaxValue()) { + + // Range exceeded + ostringstream strStream; + + strStream << strValue << " value out of range [0, " << getMaxValue() << "] for " + getKind(); + + parameterAccessContext.setError(strStream.str()); + + return false; + } + + // Do bitwise operation + uiValue = (uiValue & ~getMask()) | (uiConvertedValue << _uiBitPos); + + return true; +} + +void CBitParameterType::asString(const uint32_t& uiValue, string& strValue) const +{ + uint32_t uiConvertedValue = (uiValue & getMask()) >> _uiBitPos; + + // Format + ostringstream strStream; + + strStream << uiConvertedValue; + + strValue = strStream.str(); +} + +// Bit Size +uint32_t CBitParameterType::getBitSize() const +{ + return _uiBitSize; +} + +CInstanceConfigurableElement* CBitParameterType::doInstantiate() const +{ + return new CBitParameter(getName(), this); +} + +// Max value +uint32_t CBitParameterType::getMaxValue() const +{ + return (1 << _uiBitSize) - 1; +} + +// Biwise mask +uint32_t CBitParameterType::getMask() const +{ + return getMaxValue() << _uiBitPos; +} diff --git a/parameter/BitParameterType.h b/parameter/BitParameterType.h new file mode 100644 index 0000000..2a94922 --- /dev/null +++ b/parameter/BitParameterType.h @@ -0,0 +1,68 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> + +#include "TypeElement.h" + +class CParameterAccessContext; + +class CBitParameterType : public CTypeElement +{ +public: + CBitParameterType(const string& strName); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Conversion + bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; + void asString(const uint32_t& uiValue, string& strValue) const; + + // Bit Size + uint32_t getBitSize() const; + + // CElement + virtual string getKind() const; +private: + // Instantiation + virtual CInstanceConfigurableElement* doInstantiate() const; + // Max value + uint32_t getMaxValue() const; + // Biwise mask + uint32_t getMask() const; + + // Pos in bits + uint32_t _uiBitPos; + // Size in bits + uint32_t _uiBitSize; +}; diff --git a/parameter/BooleanParameterType.cpp b/parameter/BooleanParameterType.cpp new file mode 100644 index 0000000..d84d683 --- /dev/null +++ b/parameter/BooleanParameterType.cpp @@ -0,0 +1,73 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "BooleanParameterType.h" +#include "ParameterAccessContext.h" + +#define base CParameterType + +CBooleanParameterType::CBooleanParameterType(const string& strName) : base(strName) +{ + setSize(1); +} + +CBooleanParameterType::~CBooleanParameterType() +{ +} + +string CBooleanParameterType::getKind() const +{ + return "BooleanParameter"; +} + +bool CBooleanParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const +{ + if (strValue == "1") { + + uiValue = true; + } else if (strValue == "0") { + + uiValue = false; + } else { + + parameterAccessContext.setError(strValue + " value not part of numerical space {0, 1} for " + getKind()); + + return false; + } + + return true; +} + +void CBooleanParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const +{ + (void)parameterAccessContext; + + strValue = uiValue ? "1" : "0"; +} diff --git a/parameter/BooleanParameterType.h b/parameter/BooleanParameterType.h new file mode 100644 index 0000000..1bf0a5a --- /dev/null +++ b/parameter/BooleanParameterType.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterType.h" + +class CBooleanParameterType : public CParameterType +{ +public: + CBooleanParameterType(const string& strName); + virtual ~CBooleanParameterType(); + + virtual string getKind() const; + virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; + virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; +}; diff --git a/parameter/Component.cpp b/parameter/Component.cpp new file mode 100644 index 0000000..66c9893 --- /dev/null +++ b/parameter/Component.cpp @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "Component.h" +#include "ComponentLibrary.h" +#include "Mapper.h" + +#define base CParameterBlock + +CComponent::CComponent(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement) +{ +} + +CInstanceConfigurableElement::Type CComponent::getType() const +{ + return EComponent; +} diff --git a/parameter/Component.h b/parameter/Component.h new file mode 100644 index 0000000..d43e6e8 --- /dev/null +++ b/parameter/Component.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterBlock.h" + +class CComponent : public CParameterBlock +{ +public: + CComponent(const string& strName, const CTypeElement* pTypeElement); + + // Type + virtual Type getType() const; +private: +}; + diff --git a/parameter/ComponentInstance.cpp b/parameter/ComponentInstance.cpp new file mode 100644 index 0000000..12566d5 --- /dev/null +++ b/parameter/ComponentInstance.cpp @@ -0,0 +1,102 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ComponentInstance.h" +#include "ComponentLibrary.h" +#include "ComponentType.h" +#include "Component.h" +#include "XmlParameterSerializingContext.h" + +#define base CTypeElement + +CComponentInstance::CComponentInstance(const string& strName) : base(strName), _pComponentType(NULL) +{ +} + +string CComponentInstance::getKind() const +{ + return "Component"; +} + +bool CComponentInstance::childrenAreDynamic() const +{ + return true; +} + +bool CComponentInstance::getMappingData(const string& strKey, string& strValue) const +{ + // Try myself first then associated component type + return base::getMappingData(strKey, strValue) || (_pComponentType && _pComponentType->getMappingData(strKey, strValue)); +} + +bool CComponentInstance::hasMappingData() const +{ + // Try myself first then extended component type + return base::hasMappingData() || (_pComponentType && _pComponentType->hasMappingData()); +} + +bool CComponentInstance::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Context + CXmlParameterSerializingContext& parameterBuildContext = static_cast<CXmlParameterSerializingContext&>(serializingContext); + + const CComponentLibrary* pComponentLibrary = parameterBuildContext.getComponentLibrary(); + + string strComponentType = xmlElement.getAttributeString("Type"); + + _pComponentType = pComponentLibrary->getComponentType(strComponentType); + + if (!_pComponentType) { + + serializingContext.setError("Unable to create Component " + xmlElement.getPath() + ". ComponentType " + strComponentType + " not found!"); + + return false; + } + if (_pComponentType == getParent()) { + + serializingContext.setError("Recursive definition of " + _pComponentType->getName() + " due to " + xmlElement.getPath() + " referring to one of its own type."); + + return false; + } + + return base::fromXml(xmlElement, serializingContext); +} + +CInstanceConfigurableElement* CComponentInstance::doInstantiate() const +{ + return new CComponent(getName(), this); +} + +void CComponentInstance::populate(CElement* pElement) const +{ + base::populate(pElement); + + _pComponentType->populate(static_cast<CComponent*>(pElement)); +} diff --git a/parameter/ComponentInstance.h b/parameter/ComponentInstance.h new file mode 100644 index 0000000..dffab7f --- /dev/null +++ b/parameter/ComponentInstance.h @@ -0,0 +1,58 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "TypeElement.h" + +class CComponentType; + +class CComponentInstance : public CTypeElement +{ +public: + CComponentInstance(const string& strName); + + // Mapping info + virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool hasMappingData() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // CElement + virtual string getKind() const; +private: + virtual bool childrenAreDynamic() const; + virtual CInstanceConfigurableElement* doInstantiate() const; + virtual void populate(CElement* pElement) const; + + const CComponentType* _pComponentType; +}; + diff --git a/parameter/ComponentLibrary.cpp b/parameter/ComponentLibrary.cpp new file mode 100644 index 0000000..f29f2d7 --- /dev/null +++ b/parameter/ComponentLibrary.cpp @@ -0,0 +1,53 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ComponentLibrary.h" +#include "ComponentType.h" +#include <assert.h> + +CComponentLibrary::CComponentLibrary() +{ +} + +bool CComponentLibrary::childrenAreDynamic() const +{ + return true; +} + +string CComponentLibrary::getKind() const +{ + return "ComponentLibrary"; +} + +const CComponentType* CComponentLibrary::getComponentType(const string& strName) const +{ + return static_cast<const CComponentType*>(findChild(strName)); +} + diff --git a/parameter/ComponentLibrary.h b/parameter/ComponentLibrary.h new file mode 100644 index 0000000..e5c246e --- /dev/null +++ b/parameter/ComponentLibrary.h @@ -0,0 +1,49 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "XmlElement.h" +#include "Element.h" +#include "Component.h" + +class CComponentType; + +class CComponentLibrary : public CElement +{ +public: + CComponentLibrary(); + + const CComponentType* getComponentType(const string& strName) const; + + virtual string getKind() const; +private: + virtual bool childrenAreDynamic() const; +}; diff --git a/parameter/ComponentType.cpp b/parameter/ComponentType.cpp new file mode 100644 index 0000000..ee83464 --- /dev/null +++ b/parameter/ComponentType.cpp @@ -0,0 +1,122 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ComponentType.h" +#include "ComponentLibrary.h" +#include "TypeElement.h" +#include "XmlParameterSerializingContext.h" +#include <assert.h> + +#define base CTypeElement + +CComponentType::CComponentType(const string& strName) : base(strName), _pExtendsComponentType(NULL) +{ +} + +string CComponentType::getKind() const +{ + return "ComponentType"; +} + +bool CComponentType::childrenAreDynamic() const +{ + return true; +} + +bool CComponentType::getMappingData(const string& strKey, string& strValue) const +{ + // Try myself first then extended component type + return base::getMappingData(strKey, strValue) || (_pExtendsComponentType && _pExtendsComponentType->getMappingData(strKey, strValue)); +} + +bool CComponentType::hasMappingData() const +{ + // Try myself first then extended component type + return base::hasMappingData() || (_pExtendsComponentType && _pExtendsComponentType->hasMappingData()); +} + +bool CComponentType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Context + CXmlParameterSerializingContext& parameterBuildContext = static_cast<CXmlParameterSerializingContext&>(serializingContext); + + const CComponentLibrary* pComponentLibrary = parameterBuildContext.getComponentLibrary(); + + // Populate children + if (!base::fromXml(xmlElement, serializingContext)) { + + return false; + } + + // Check for Extends attribute (extensions will be populated after and not before) + if (xmlElement.hasAttribute("Extends")) { + + string strExtendsType = xmlElement.getAttributeString("Extends"); + + _pExtendsComponentType = pComponentLibrary->getComponentType(strExtendsType); + + if (!_pExtendsComponentType) { + + serializingContext.setError("ComponentType " + strExtendsType + " referred to by " + xmlElement.getPath() + " not found!"); + + return false; + } + + if (_pExtendsComponentType == this) { + + serializingContext.setError("Recursive ComponentType definition of " + xmlElement.getPath()); + + return false; + } + } + + return true; +} + +void CComponentType::populate(CElement* pElement) const +{ + // Populate children + base::populate(pElement); + + // Manage extended type + if (_pExtendsComponentType) { + + // Populate from extended type + _pExtendsComponentType->populate(pElement); + } +} + +CInstanceConfigurableElement* CComponentType::doInstantiate() const +{ + // Not supposed to be called directly (instantiation made through CComponentInstance object) + assert(0); + + return NULL; +} diff --git a/parameter/ComponentType.h b/parameter/ComponentType.h new file mode 100644 index 0000000..0bd311b --- /dev/null +++ b/parameter/ComponentType.h @@ -0,0 +1,60 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "TypeElement.h" + +class CInstanceConfigurableElement; + +class CComponentType : public CTypeElement +{ +public: + CComponentType(const string& strName); + + void populate(CElement* pElement) const; + + // Mapping info + virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool hasMappingData() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + // CElement + virtual string getKind() const; +private: + // CElement + virtual bool childrenAreDynamic() const; + // Component creation + virtual CInstanceConfigurableElement* doInstantiate() const; + + // Ref + const CComponentType* _pExtendsComponentType; +}; diff --git a/parameter/CompoundRule.cpp b/parameter/CompoundRule.cpp new file mode 100644 index 0000000..6078a2d --- /dev/null +++ b/parameter/CompoundRule.cpp @@ -0,0 +1,87 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "CompoundRule.h" + +#define base CRule + +CCompoundRule::CCompoundRule() : _bTypeAll(false) +{ +} + +// Class kind +string CCompoundRule::getKind() const +{ + return "CompoundRule"; +} + +// Returns true if children dynamic creation is to be dealt with +bool CCompoundRule::childrenAreDynamic() const +{ + return true; +} + +// Rule check +bool CCompoundRule::matches() const +{ + uint32_t uiChild; + uint32_t uiNbChildren = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CRule* pRule = static_cast<const CRule*>(getChild(uiChild)); + + if (pRule->matches() ^ _bTypeAll) { + + return !_bTypeAll; + } + } + return _bTypeAll; +} + +// From IXmlSink +bool CCompoundRule::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Get type + _bTypeAll = xmlElement.getAttributeBoolean("Type", "All"); + + // Base + return base::fromXml(xmlElement, serializingContext); +} + +// From IXmlSource +void CCompoundRule::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Set type + xmlElement.setAttributeString("Type", _bTypeAll ? "All" : "Any"); + + // Base + base::toXml(xmlElement, serializingContext); +} diff --git a/parameter/CompoundRule.h b/parameter/CompoundRule.h new file mode 100644 index 0000000..9012a05 --- /dev/null +++ b/parameter/CompoundRule.h @@ -0,0 +1,57 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Rule.h" + +class CCompoundRule : public CRule +{ +public: + CCompoundRule(); + + // Rule check + virtual bool matches() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // From IXmlSource + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Class kind + virtual string getKind() const; +private: + // Returns true if children dynamic creation is to be dealt with + virtual bool childrenAreDynamic() const; + + // Type + bool _bTypeAll; +}; diff --git a/parameter/ComputedSizeParameter.cpp b/parameter/ComputedSizeParameter.cpp new file mode 100644 index 0000000..4d263da --- /dev/null +++ b/parameter/ComputedSizeParameter.cpp @@ -0,0 +1,90 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ComputedSizeParameter.h" +#include "ConfigurableElement.h" +#include "ParameterType.h" +#include "InstanceConfigurableElement.h" +#include "ComputedSizeParameterType.h" +#include <assert.h> +#include <sstream> +#include "ParameterAccessContext.h" + +#define base CParameter + +CComputedSizeParameter::CComputedSizeParameter(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement), _pReferredElement(NULL) +{ +} + +uint32_t CComputedSizeParameter::getFootPrint() const +{ + // Virtual parameter + return 0; +} + +bool CComputedSizeParameter::init(string& strError) +{ + // Seek referred parameter in parent hierarchy + const CElement* pParent = getParent(); + + assert(pParent); + + _pReferredElement = static_cast<const CConfigurableElement*>(pParent->findChild(static_cast<const CComputedSizeParameterType*>(getTypeElement())->getReferredElementName())); + + if (!_pReferredElement) { + + strError = "Could not find referred Parameter " + getTypeElement()->getName() + " from " + getKind() + " " + getPath(); + + return false; + } + + return true; +} + +bool CComputedSizeParameter::doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) +{ + // Read only kind of parameter, can't be set! + (void)strValue; + (void)uiOffset; + + parameterAccessContext.setError("Read only parameter"); + + return false; +} + +void CComputedSizeParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const +{ + assert(_pReferredElement); + // Parameter can't be an array + assert(uiOffset == getOffset()); + + static_cast<const CParameterType*>(getTypeElement())->asString(_pReferredElement->getFootPrint(), strValue, parameterAccessContext); +} + diff --git a/parameter/ComputedSizeParameter.h b/parameter/ComputedSizeParameter.h new file mode 100644 index 0000000..99c1ad2 --- /dev/null +++ b/parameter/ComputedSizeParameter.h @@ -0,0 +1,51 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Parameter.h" + +class CConfigurableElement; + +class CComputedSizeParameter : public CParameter +{ +public: + CComputedSizeParameter(const string& strName, const CTypeElement* pTypeElement); + + virtual bool init(string& strError); + + virtual uint32_t getFootPrint() const; +protected: + virtual bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext); + virtual void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; +private: + const CConfigurableElement* _pReferredElement; +}; + diff --git a/parameter/ComputedSizeParameterType.cpp b/parameter/ComputedSizeParameterType.cpp new file mode 100644 index 0000000..02daf79 --- /dev/null +++ b/parameter/ComputedSizeParameterType.cpp @@ -0,0 +1,88 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ComputedSizeParameterType.h" +#include "ComputedSizeParameter.h" +#include <sstream> +#include <stdlib.h> + +#define base CParameterType + +CComputedSizeParameterType::CComputedSizeParameterType(const string& strName) : base(strName) +{ +} + +string CComputedSizeParameterType::getKind() const +{ + return "ComputedSizeParameter"; +} + +bool CComputedSizeParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Size + setSize(xmlElement.getAttributeInteger("Size") / 8); + + _strReferredElementName = xmlElement.getAttributeString("Parameter"); + + return base::fromXml(xmlElement, serializingContext); +} + +bool CComputedSizeParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const +{ + (void)parameterAccessContext; + + uiValue = strtoul(strValue.c_str(), NULL, 0); + + return true; +} + +void CComputedSizeParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const +{ + (void)parameterAccessContext; + + // Format + ostringstream strStream; + + strStream << uiValue; + + strValue = strStream.str(); +} + +const string& CComputedSizeParameterType::getReferredElementName() const +{ + return _strReferredElementName; +} + +CInstanceConfigurableElement* CComputedSizeParameterType::doInstantiate() const +{ + // Scalar parameter + return new CComputedSizeParameter(getName(), this); +} + diff --git a/parameter/ComputedSizeParameterType.h b/parameter/ComputedSizeParameterType.h new file mode 100644 index 0000000..63ae6b3 --- /dev/null +++ b/parameter/ComputedSizeParameterType.h @@ -0,0 +1,54 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterType.h" + +class CComputedSizeParameterType : public CParameterType +{ +public: + CComputedSizeParameterType(const string& strName); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; + virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; + virtual string getKind() const; + + const string& getReferredElementName() const; + +private: + virtual CInstanceConfigurableElement* doInstantiate() const; + + string _strReferredElementName; +}; + diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp new file mode 100644 index 0000000..807171f --- /dev/null +++ b/parameter/ConfigurableDomain.cpp @@ -0,0 +1,922 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ConfigurableDomain.h" +#include "DomainConfiguration.h" +#include "ConfigurableElement.h" +#include "ConfigurationAccessContext.h" +#include "Subsystem.h" +#include "XmlDomainSerializingContext.h" +#include <assert.h> + +#define base CBinarySerializableElement + +CConfigurableDomain::CConfigurableDomain(const string& strName) : base(strName), _pLastAppliedConfiguration(NULL) +{ +} + +CConfigurableDomain::~CConfigurableDomain() +{ + ConfigurableElementListIterator it; + + // Browse all configurable elements for their syncers + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + CConfigurableElement* pConfigurableElement = *it; + + // Remove from configurable element + pConfigurableElement->removeAttachedConfigurableDomain(this); + } +} + +string CConfigurableDomain::getKind() const +{ + return "ConfigurableDomain"; +} + +bool CConfigurableDomain::childrenAreDynamic() const +{ + return true; +} + +// From IXmlSource +void CConfigurableDomain::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Configurations + composeDomainConfigurations(xmlElement, serializingContext); + + // Configurable Elements + composeConfigurableElements(xmlElement, serializingContext); +} + +// XML composing +void CConfigurableDomain::composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Create Configurations element + CXmlElement xmlConfigurationsElement; + + xmlElement.createChild(xmlConfigurationsElement, "Configurations"); + + // Delegate to base + base::toXml(xmlConfigurationsElement, serializingContext); +} + +void CConfigurableDomain::composeConfigurableElements(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Context + const CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<const CXmlDomainSerializingContext&>(serializingContext); + + // Create ConfigurableElements element + CXmlElement xmlConfigurableElementsElement; + + xmlElement.createChild(xmlConfigurableElementsElement, "ConfigurableElements"); + + // Serialize out all configurable elements settings + ConfigurableElementListIterator it; + + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + // Create corresponding XML child element + CXmlElement xmlChildConfigurableElement; + + xmlConfigurableElementsElement.createChild(xmlChildConfigurableElement, "ConfigurableElement"); + + // 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 +{ + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChildConfiguration; + + for (uiChildConfiguration = 0; uiChildConfiguration < uiNbConfigurations; uiChildConfiguration++) { + + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChildConfiguration)); + + // Create child xml element for that configuration + CXmlElement xmlConfigurationSettingsElement; + + xmlConfigurableElementElement.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); + } +} + +// From IXmlSink +bool CConfigurableDomain::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Local parsing. Do not dig + return parseDomainConfigurations(xmlElement, serializingContext) && parseConfigurableElements(xmlElement, serializingContext); +} + +// XML parsing +bool CConfigurableDomain::parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // We're supposedly clean + assert(_configurableElementList.empty()); + + // Get Configurations element + CXmlElement xmlConfigurationsElement; + + xmlElement.getChildElement("Configurations", xmlConfigurationsElement); + + // Parse it and create domain configuration objects + return base::fromXml(xmlConfigurationsElement, serializingContext); +} + +// 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(); + + CElement* pSystemClassElement = pRootElement->findChildOfKind("SystemClass"); + + assert(pSystemClassElement); + + // Get ConfigurableElements element + CXmlElement xmlConfigurableElementsElement; + xmlElement.getChildElement("ConfigurableElements", xmlConfigurableElementsElement); + + // Parse it and associate found configurable elements to it + CXmlElement::CChildIterator it(xmlConfigurableElementsElement); + + CXmlElement xmlConfigurableElementElement; + + while (it.next(xmlConfigurableElementElement)) { + + // Locate configurable element + string strConfigurableElementPath = xmlConfigurableElementElement.getAttributeString("Path"); + + CPathNavigator pathNavigator(strConfigurableElementPath); + + string* pStrChildName = pathNavigator.next(); + + // Is there an element and does it match system class name? + if (!pStrChildName || *pStrChildName != pSystemClassElement->getName()) { + + serializingContext.setError("Could not find configurable element of path " + strConfigurableElementPath + " from ConfigurableDomain description " + getName()); + + return false; + } + + // Browse system class for configurable element + CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pSystemClassElement->findDescendant(pathNavigator)); + + if (!pConfigurableElement) { + + serializingContext.setError("Could not find configurable element of path " + strConfigurableElementPath + " from ConfigurableDomain description " + getName()); + + return false; + } + // Add found element to domain + string strError; + if (!addConfigurableElement(pConfigurableElement, NULL, strError)) { + + serializingContext.setError(strError); + + 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) +{ + // Context + CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); + + // Parse configurable element's configuration settings + CXmlElement::CChildIterator it(xmlConfigurableElementElement); + + CXmlElement xmlConfigurationSettingsElement; + + 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()); + + return false; + } + // Have domain configuration parse settings for configurable element + if (!serializeConfigurableElementConfiguration(pDomainConfiguration, pConfigurableElement, xmlConfigurationSettingsElement, xmlDomainSerializingContext, false)) { + + return false; + } + } + + return true; +} + +// 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); + + // Change context type for parameter settings access + string strError; + + // Create configuration access context + CConfigurationAccessContext configurationAccessContext(strError, bSerializeOut); + + // Provide current value space + configurationAccessContext.setValueSpaceRaw(xmlDomainSerializingContext.valueSpaceIsRaw()); + + // 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, xmlConfigurationSettingsElement, configurationAccessContext)) { + + // Forward error + xmlDomainSerializingContext.setError(strError); + + return false; + } + return true; +} + +// Configurable elements association +bool CConfigurableDomain::addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Already associated? + if (containsConfigurableElement(pConfigurableElement)) { + + strError = "Configurable element " + pConfigurableElement->getPath() + " already associated to configuration domain " + getName(); + + return false; + } + + // Already owned? + if (pConfigurableElement->belongsTo(this)) { + + strError = "Configurable element " + pConfigurableElement->getPath() + " already owned by configuration domain " + getName(); + + return false; + } + log("Adding configurable element \"%s\" into domain \"%s\"", pConfigurableElement->getPath().c_str(), getName().c_str()); + + // Do add + doAddConfigurableElement(pConfigurableElement); + + // Ensure area validity for that configurable element (if main blackboard provided) + if (pMainBlackboard) { + + // Need to validate against main blackboard + validateAreas(pConfigurableElement, pMainBlackboard); + } + + return true; +} + +bool CConfigurableDomain::removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError) +{ + // Not associated? + if (!containsConfigurableElement(pConfigurableElement)) { + + strError = "Configurable element " + pConfigurableElement->getPath() + " not associated to configuration domain " + getName(); + + return false; + } + log("Removing configurable element \"%s\" from domain \"%s\"", pConfigurableElement->getPath().c_str(), getName().c_str()); + + // Do remove + doRemoveConfigurableElement(pConfigurableElement, true); + + return true; +} + +// Domain splitting +bool CConfigurableDomain::split(CConfigurableElement* pConfigurableElement, string& strError) +{ + // Not associated? + if (!containsConfigurableElement(pConfigurableElement)) { + + strError = "Configurable element " + pConfigurableElement->getPath() + " not associated to configuration domain " + getName(); + + return false; + } + log("Splitting configurable element \"%s\" domain \"%s\"", pConfigurableElement->getPath().c_str(), getName().c_str()); + + // Create sub domain areas for all configurable element's children + uint32_t uiNbConfigurableElementChildren = pConfigurableElement->getNbChildren(); + + if (!uiNbConfigurableElementChildren) { + + strError = "Configurable element " + pConfigurableElement->getPath() + " has no children to split configurable domain to"; + + return false; + } + + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurableElementChildren; uiChild++) { + + CConfigurableElement* pChildConfigurableElement = static_cast<CConfigurableElement*>(pConfigurableElement->getChild(uiChild)); + + doAddConfigurableElement(pChildConfigurableElement); + } + + // Delegate to configurations + uint32_t uiNbConfigurations = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + pDomainConfiguration->split(pConfigurableElement); + } + + // Remove given configurable element from this domain + // Note: we shouldn't need to recompute the sync set in that case, as the splitted element should include the syncers of its children elements + doRemoveConfigurableElement(pConfigurableElement, false); + + return true; +} + +// Configuration application if required +void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce) +{ + if (bForce) { + // Force a configuration restore by forgetting about last applied configuration + _pLastAppliedConfiguration = NULL; + } + const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration(); + + if (pApplicableDomainConfiguration) { + + // Check not the last one before applying + if (!_pLastAppliedConfiguration || _pLastAppliedConfiguration != pApplicableDomainConfiguration) { + + log("Applying configuration \"%s\" from domain \"%s\"", pApplicableDomainConfiguration->getName().c_str(), getName().c_str()); + + // Do the restore + pApplicableDomainConfiguration->restore(pParameterBlackboard); + + // Record last applied configuration + _pLastAppliedConfiguration = pApplicableDomainConfiguration; + + // Since we applied changes, add our own sync set to the given one + syncerSet += _syncerSet; + } + } +} + +// Return applicable configuration validity for given configurable element +bool CConfigurableDomain::isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const +{ + const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration(); + + return pApplicableDomainConfiguration && pApplicableDomainConfiguration->isValid(pConfigurableElement); +} + +// Presence of application condition on any configuration +bool CConfigurableDomain::hasRules() const +{ + // Delegate to configurations + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild)); + + if (pDomainConfiguration->hasRule()) { + + return true; + } + } + return false; +} + +// In case configurable element was removed +void CConfigurableDomain::computeSyncSet() +{ + // Clean sync set first + _syncerSet.clear(); + + // Browse all configurable elements for their syncers + ConfigurableElementListIterator it; + + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + pConfigurableElement->fillSyncerSet(_syncerSet); + } +} + +// Configuration Management +bool CConfigurableDomain::createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Already exists? + if (findChild(strName)) { + + strError = "Already existing configuration"; + + return false; + } + log("Creating domain configuration \"%s\" into domain \"%s\"", strName.c_str(), getName().c_str()); + + // Creation + CDomainConfiguration* pDomainConfiguration = new CDomainConfiguration(strName); + + // Configurable elements association + ConfigurableElementListIterator it; + + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + pDomainConfiguration->addConfigurableElement(*it); + } + + // Hierarchy + addChild(pDomainConfiguration); + + // Ensure validity of fresh new domain configuration + // Attempt auto validation, so that the user gets his/her own settings by defaults + if (!autoValidateConfiguration(pDomainConfiguration)) { + + // No valid configuration found to copy in from, validate againt main blackboard (will concerned remaining invalid parts) + pDomainConfiguration->validate(pMainBlackboard); + } + + return true; +} + +bool CConfigurableDomain::deleteConfiguration(const string& strName, string& strError) +{ + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strError = "Configuration not found"; + + return false; + } + + // Check configuration has no rule (prevent accidental loss of data) + if (pDomainConfiguration->hasRule()) { + + strError = "Deletion of configuration containing application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file."; + + return false; + } + + log("Deleting configuration \"%s\" from domain \"%s\"", strName.c_str(), getName().c_str()); + + // Was the last applied? + if (pDomainConfiguration == _pLastAppliedConfiguration) { + + // Forget about it + _pLastAppliedConfiguration = NULL; + } + + // Hierarchy + removeChild(pDomainConfiguration); + + // Destroy + delete pDomainConfiguration; + + return true; +} + +void CConfigurableDomain::listAssociatedToElements(string& strResult) const +{ + strResult = "\n"; + + ConfigurableElementListIterator it; + + // Browse all configurable elements + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + strResult += pConfigurableElement->getPath() + "\n"; + } +} + +bool CConfigurableDomain::renameConfiguration(const string& strName, const string& strNewName, string& strError) +{ + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strError = "Configuration not found"; + + return false; + } + log("Renaming domain \"%s\"'s configuration \"%s\" to \"%s\"", getName().c_str(), strName.c_str(), strNewName.c_str()); + + // Rename + return pDomainConfiguration->rename(strNewName, strError); +} + +bool CConfigurableDomain::restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) +{ + // Find Domain configuration + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strError = "Domain configuration " + strName + " not found"; + + return false; + } + log("Restoring domain \"%s\"'s configuration \"%s\" to parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str()); + + // Delegate + pDomainConfiguration->restore(pMainBlackboard); + + // Record last applied configuration + _pLastAppliedConfiguration = pDomainConfiguration; + + // Synchronize + return !bAutoSync || _syncerSet.sync(*pMainBlackboard, false, strError); +} + +bool CConfigurableDomain::saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Find Domain configuration + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(findChild(strName)); + + if (!pDomainConfiguration) { + + strError = "Domain configuration " + strName + " not found"; + + return false; + } + log("Saving domain \"%s\"'s configuration \"%s\" from parameter blackboard", getName().c_str(), pDomainConfiguration->getName().c_str()); + + // Delegate + pDomainConfiguration->save(pMainBlackboard); + + return true; +} + +// Last applied configuration +string CConfigurableDomain::getLastAppliedConfigurationName() const +{ + if (_pLastAppliedConfiguration) { + + return _pLastAppliedConfiguration->getName(); + } + return "<none>"; +} + +// Ensure validity on whole domain from main blackboard +void CConfigurableDomain::validate(const CParameterBlackboard* pMainBlackboard) +{ + log("Validating whole domain \"" + getName() + "\" against main blackboard"); + + // Propagate + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + pDomainConfiguration->validate(pMainBlackboard); + } +} + +// Ensure validity on areas related to configurable element +void CConfigurableDomain::validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard) +{ + log("Validating domain \"" + getName() + "\" against main blackboard for configurable element \"" + pConfigurableElement->getPath() + "\""); + + // Propagate + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + pDomainConfiguration->validate(pConfigurableElement, pMainBlackboard); + } +} + +// Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain +void CConfigurableDomain::autoValidateAll() +{ + // Validate + ConfigurableElementListIterator it; + + // Browse all configurable elements for configuration validation + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + // Auto validate element + autoValidateAreas(pConfigurableElement); + } +} + +// Attempt validation for configurable element's areas, relying on already existing valid configuration inside domain +void CConfigurableDomain::autoValidateAreas(const CConfigurableElement* pConfigurableElement) +{ + // Find first valid configuration for given configurable element + const CDomainConfiguration* pValidDomainConfiguration = findValidDomainConfiguration(pConfigurableElement); + + // No valid configuration found, give up + if (!pValidDomainConfiguration) { + + return; + } + + log("Auto validating domain \"" + getName() + "\" against configuration \"" + pValidDomainConfiguration->getName() + "\" for configurable element " + pConfigurableElement->getPath()); + + // Validate all other configurations against found one, if any + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + if (pDomainConfiguration != pValidDomainConfiguration && !pDomainConfiguration->isValid(pConfigurableElement)) { + // Validate + pDomainConfiguration->validateAgainst(pValidDomainConfiguration, pConfigurableElement); + } + } +} + +// Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain +bool CConfigurableDomain::autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration) +{ + // Find another configuration than this one, that ought to be valid! + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + const CDomainConfiguration* pPotententialValidDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild)); + + if (pPotententialValidDomainConfiguration != pDomainConfiguration) { + + // Validate against it + pDomainConfiguration->validateAgainst(pPotententialValidDomainConfiguration); + + return true; + } + } + return false; +} +#if 0 +void CConfigurableDomain::autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration) +{ + // Validate + ConfigurableElementListIterator it; + + // Browse all configurable elements for configuration validation + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + // Find first valid configuration for given configurable element + const CDomainConfiguration* pValidDomainConfiguration = findValidDomainConfiguration(pConfigurableElement); + + // Check valid configuration exists for that configurable element + if (pValidDomainConfiguration) { + + // Called on purpose + assert(pValidDomainConfiguration != pDomainConfiguration); + + // Validate + pDomainConfiguration->validateAgainst(pValidDomainConfiguration, pConfigurableElement); + } + } +} +#endif +// Search for a valid configuration for given configurable element +const CDomainConfiguration* CConfigurableDomain::findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const +{ + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild)); + + if (pDomainConfiguration->isValid(pConfigurableElement)) { + + return pDomainConfiguration; + } + } + return NULL; +} + +// Search for an applicable configuration +const CDomainConfiguration* CConfigurableDomain::findApplicableDomainConfiguration() const +{ + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(getChild(uiChild)); + + if (pDomainConfiguration->isApplicable()) { + + return pDomainConfiguration; + } + } + return NULL; +} + +// Gather set of configurable elements +void CConfigurableDomain::gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const +{ + // Insert all configurable elements + configurableElementSet.insert(_configurableElementList.begin(), _configurableElementList.end()); +} + +// Check configurable element already attached +bool CConfigurableDomain::containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const +{ + ConfigurableElementListIterator it; + + // Browse all configurable elements for comparison + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + if (pConfigurableCandidateElement == *it) { + + return true; + } + } + return false; +} + +// Merge any descended configurable element to this one with this one +void CConfigurableDomain::mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement) +{ + list<CConfigurableElement*> mergedConfigurableElementList; + + ConfigurableElementListIterator it; + + // Browse all configurable elements (new one not yet in the list!) + for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) { + + CConfigurableElement* pConfigurablePotentialDescendantElement = *it; + + if (pConfigurablePotentialDescendantElement->isDescendantOf(pNewConfigurableElement)) { + + log("In domain \"%s\", merging descendant configurable element's configurations \"%s\" into its ascendant \"%s\" ones", getName().c_str(), pConfigurablePotentialDescendantElement->getName().c_str(), pNewConfigurableElement->getName().c_str()); + + // Merge configuration data + mergeConfigurations(pNewConfigurableElement, pConfigurablePotentialDescendantElement); + + // Keep track for removal + mergedConfigurableElementList.push_back(pConfigurablePotentialDescendantElement); + } + } + + // Remove all merged elements (new one not yet in the list!) + for (it = mergedConfigurableElementList.begin(); it != mergedConfigurableElementList.end(); ++it) { + + CConfigurableElement* pMergedConfigurableElement = *it; + + // Remove merged from configurable element from internal tracking list + // Note: we shouldn't need to recompute the sync set in that case, as the merged to element should include the syncers of merged from elements + doRemoveConfigurableElement(pMergedConfigurableElement, false); + } +} + +void CConfigurableDomain::mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement) +{ + // Propagate to domain configurations + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + // Do the merge. + pDomainConfiguration->merge(pToConfigurableElement, pFromConfigurableElement); + } +} + +// Configurable elements association +void CConfigurableDomain::doAddConfigurableElement(CConfigurableElement* pConfigurableElement) +{ + // Inform configurable element + pConfigurableElement->addAttachedConfigurableDomain(this); + + // Inform configurations + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + pDomainConfiguration->addConfigurableElement(pConfigurableElement); + } + // 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); + + // Add to list + _configurableElementList.push_back(pConfigurableElement); +} + +void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet) +{ + // Remove from list + _configurableElementList.remove(pConfigurableElement); + + // Inform configurable element + pConfigurableElement->removeAttachedConfigurableDomain(this); + + // Inform configurations + uint32_t uiNbConfigurations = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurations; uiChild++) { + + CDomainConfiguration* pDomainConfiguration = static_cast<CDomainConfiguration*>(getChild(uiChild)); + + pDomainConfiguration->removeConfigurableElement(pConfigurableElement); + } + // Recompute our sync set if needed + if (bRecomputeSyncSet) { + + computeSyncSet(); + } +} diff --git a/parameter/ConfigurableDomain.h b/parameter/ConfigurableDomain.h new file mode 100644 index 0000000..0438009 --- /dev/null +++ b/parameter/ConfigurableDomain.h @@ -0,0 +1,146 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "BinarySerializableElement.h" +#include "SyncerSet.h" +#include <list> +#include <set> + +class CConfigurableElement; +class CDomainConfiguration; +class CParameterBlackboard; + +class CConfigurableDomain : public CBinarySerializableElement +{ + typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator; +public: + CConfigurableDomain(const string& strName); + virtual ~CConfigurableDomain(); + + // 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); + + // Last applied configuration + string getLastAppliedConfigurationName() const; + + // Associated Configurable elements + void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const; + void listAssociatedToElements(string& strResult) const; + + // Configurable elements association + bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError); + bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError); + + // Domain splitting + bool split(CConfigurableElement* pConfigurableElement, string& strError); + + // Ensure validity on whole domain from main blackboard + void validate(const CParameterBlackboard* pMainBlackboard); + + // Configuration application if required + void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced); + + // Return applicable configuration validity for given configurable element + bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const; + + // Presence of application condition on any configuration + bool hasRules() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // From IXmlSource + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Class kind + virtual string getKind() const; +private: + // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean) + virtual bool childrenAreDynamic() const; + + // Ensure validity on areas related to configurable element + void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard); + + // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain + void autoValidateAll(); + + // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain + void autoValidateAreas(const CConfigurableElement* pConfigurableElement); + + // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain + bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration); + + // Search for a valid configuration for given configurable element + const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const; + + // Search for an applicable configuration + const CDomainConfiguration* findApplicableDomainConfiguration() const; + + // In case configurable element was removed + void computeSyncSet(); + + // Check configurable element already attached + bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const; + + // Merge any descended configurable element to this one + void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement); + void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement); + + // Configurable elements association + void doAddConfigurableElement(CConfigurableElement* pConfigurableElement); + void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet); + + // 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); + + // 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; + + // Configurable elements + list<CConfigurableElement*> _configurableElementList; + + // Syncer set used to ensure propoer synchronization of restored configurable elements + CSyncerSet _syncerSet; + + // Last applied configuration + const CDomainConfiguration* _pLastAppliedConfiguration; +}; + diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp new file mode 100644 index 0000000..1961b2f --- /dev/null +++ b/parameter/ConfigurableDomains.cpp @@ -0,0 +1,428 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ConfigurableDomains.h" +#include "ConfigurableDomain.h" +#include "ConfigurableElement.h" +#include "BinaryStream.h" + +#define base CBinarySerializableElement + +CConfigurableDomains::CConfigurableDomains(const string& strSystemClassName) : base(strSystemClassName) +{ +} + +string CConfigurableDomains::getKind() const +{ + return "ConfigurableDomains"; +} + +bool CConfigurableDomains::childrenAreDynamic() const +{ + return true; +} + +// Ensure validity on whole domains from main blackboard +void CConfigurableDomains::validate(const CParameterBlackboard* pMainBlackboard) +{ + // Delegate to domains + uint32_t uiChild; + uint32_t uiNbConfigurableDomains = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + CConfigurableDomain* pChildConfigurableDomain = static_cast<CConfigurableDomain*>(getChild(uiChild)); + + pChildConfigurableDomain->validate(pMainBlackboard); + } +} + +// Configuration application if required +bool CConfigurableDomains::apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError) +{ + log("Applying configurations"); + + // Syncer set + CSyncerSet syncerSet; + + // Delegate to domains + uint32_t uiChild; + uint32_t uiNbConfigurableDomains = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + CConfigurableDomain* pChildConfigurableDomain = static_cast<CConfigurableDomain*>(getChild(uiChild)); + + pChildConfigurableDomain->apply(pParameterBlackboard, syncerSet, bForce); + } + // Synchronize + return syncerSet.sync(*pParameterBlackboard, false, strError); +} + +// From IXmlSource +void CConfigurableDomains::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Set attribute + xmlElement.setAttributeString("SystemClassName", getName()); + + base::toXml(xmlElement, serializingContext); +} + +// Configuration/Domains handling +/// Domains +bool CConfigurableDomains::createDomain(const string& strName, string& strError) +{ + // Already exists? + if (findChild(strName)) { + + strError = "Already existing configurable domain"; + + return false; + } + + log("Creating configurable domain \"%s\"", strName.c_str()); + + // Creation/Hierarchy + addChild(new CConfigurableDomain(strName)); + + return true; +} + +bool CConfigurableDomains::deleteDomain(const string& strName, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain not found"; + + return false; + } + + // Check domain has no rule (prevent accidental loss of data) + if (pConfigurableDomain->hasRules()) { + + strError = "Deletion of domain containing configurations with application rules is not supported to prevent any accitental loss of data.\nPlease consider a direct modification of the XML file."; + + return false; + } + + log("Deleting configurable domain \"%s\"", strName.c_str()); + + // Hierarchy + removeChild(pConfigurableDomain); + + // Destroy + delete pConfigurableDomain; + + return true; +} + +bool CConfigurableDomains::renameDomain(const string& strName, const string& strNewName, string& strError) +{ + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strName)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain not found"; + + return false; + } + + log("Renaming configurable domain \"%s\" to \"%s\"", strName.c_str(), strNewName.c_str()); + + // Rename + return pConfigurableDomain->rename(strNewName, strError); +} + +/// Configurations +bool CConfigurableDomains::listConfigurations(const string& strDomain, string& strResult) const +{ + const CElement* pConfigurableDomain = findChild(strDomain); + + if (!pConfigurableDomain) { + + strResult = "Configurable domain not found"; + + return false; + } + // delegate + pConfigurableDomain->listChildren(strResult); + + return true; +} + +bool CConfigurableDomains::createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->createConfiguration(strConfiguration, pMainBlackboard, strError); +} + +bool CConfigurableDomains::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->deleteConfiguration(strConfiguration, strError); +} + +bool CConfigurableDomains::renameConfiguration(const string& strDomain, const string& strConfigurationName, const string& strNewConfigurationName, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->renameConfiguration(strConfigurationName, strNewConfigurationName, strError); +} + +bool CConfigurableDomains::listDomainElements(const string& strDomain, 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 + pConfigurableDomain->listAssociatedToElements(strResult); + + return true; +} + +bool CConfigurableDomains::split(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + pConfigurableDomain->split(pConfigurableElement, strError); + + return true; +} + +void CConfigurableDomains::listAssociatedElements(string& strResult) const +{ + strResult = "\n"; + + set<const CConfigurableElement*> configurableElementSet; + + // Get all owned configurable elements + gatherAllOwnedConfigurableElements(configurableElementSet); + + // Fill result + set<const CConfigurableElement*>::const_iterator it; + + for (it = configurableElementSet.begin(); it != configurableElementSet.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + string strAssociatedDomainList; + + pConfigurableElement->listAssociatedDomains(strAssociatedDomainList, false); + + strResult += pConfigurableElement->getPath() + " [" + strAssociatedDomainList + "]\n"; + } +} + +void CConfigurableDomains::listConflictingElements(string& strResult) const +{ + strResult = "\n"; + + set<const CConfigurableElement*> configurableElementSet; + + // Get all owned configurable elements + gatherAllOwnedConfigurableElements(configurableElementSet); + + // Fill result + set<const CConfigurableElement*>::const_iterator it; + + for (it = configurableElementSet.begin(); it != configurableElementSet.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + if (pConfigurableElement->getBelongingDomainCount() > 1) { + + string strBelongingDomainList; + + pConfigurableElement->listBelongingDomains(strBelongingDomainList, false); + + strResult += pConfigurableElement->getPath() + " contained in multiple domains: " + strBelongingDomainList + "\n"; + } + } +} + +// Gather configurable elements owned by any domain +void CConfigurableDomains::gatherAllOwnedConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const +{ + // Delegate to domains + uint32_t uiChild; + uint32_t uiNbConfigurableDomains = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild)); + + pChildConfigurableDomain->gatherConfigurableElements(configurableElementSet); + } +} + +// Config restore +bool CConfigurableDomains::restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->restoreConfiguration(strConfiguration, pMainBlackboard, bAutoSync, strError); +} + +// Config save +bool CConfigurableDomains::saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->saveConfiguration(strConfiguration, pMainBlackboard, strError); +} + +// Last applied configurations +void CConfigurableDomains::listLastAppliedConfigurations(string& strResult) const +{ + strResult = "\n"; + + // Browse domains + uint32_t uiChild; + uint32_t uiNbConfigurableDomains = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbConfigurableDomains; uiChild++) { + + const CConfigurableDomain* pChildConfigurableDomain = static_cast<const CConfigurableDomain*>(getChild(uiChild)); + + strResult += pChildConfigurableDomain->getName() + ": " + pChildConfigurableDomain->getLastAppliedConfigurationName() + "\n"; + } +} + +// Configurable element - domain association +bool CConfigurableDomains::addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->addConfigurableElement(pConfigurableElement, pMainBlackboard, strError); +} + +bool CConfigurableDomains::removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError) +{ + // Find domain + CConfigurableDomain* pConfigurableDomain = static_cast<CConfigurableDomain*>(findChild(strDomain)); + + if (!pConfigurableDomain) { + + strError = "Configurable domain " + strDomain + " not found"; + + return false; + } + // Delegate + return pConfigurableDomain->removeConfigurableElement(pConfigurableElement, strError); +} + +// Binary settings load/store +bool CConfigurableDomains::serializeSettings(const string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, string& strError) +{ + // Instantiate byte stream + CBinaryStream binarySettingsStream(strBinarySettingsFilePath, bOut, getDataSize(), uiStructureChecksum); + + // Open file + if (!binarySettingsStream.open(strError)) { + + strError = "Unable to open binary settings file " + strBinarySettingsFilePath + ": " + strError; + + return false; + } + + // Serialize + binarySerialize(binarySettingsStream); + + // Close stream + binarySettingsStream.close(); + + return true; +} diff --git a/parameter/ConfigurableDomains.h b/parameter/ConfigurableDomains.h new file mode 100644 index 0000000..134667f --- /dev/null +++ b/parameter/ConfigurableDomains.h @@ -0,0 +1,89 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "BinarySerializableElement.h" +#include <set> + +class CParameterBlackboard; +class CConfigurableElement; +class CSyncerSet; + +class CConfigurableDomains : public CBinarySerializableElement +{ +public: + CConfigurableDomains(const string& strSystemClassName); + + // Configuration/Domains handling + /// Domains + 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 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; + /// Configurations + bool listConfigurations(const string& strDomain, string& strResult) const; + bool createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError); + bool deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError); + 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); + + // Last applied configurations + void listLastAppliedConfigurations(string& strResult) const; + + // Configurable element - domain association + bool addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError); + bool removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError); + + // Binary settings load/store + bool serializeSettings(const string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, string& strError); + + // From IXmlSource + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Ensure validity on whole domains from main blackboard + void validate(const CParameterBlackboard* pMainBlackboard); + + // Configuration application if required + bool apply(CParameterBlackboard* pParameterBlackboard, bool bForce, string& strError); + + // Class kind + virtual string getKind() const; +private: + // Returns true if children dynamic creation is to be dealt with + virtual bool childrenAreDynamic() const; + // Gather owned configurable elements owned by any domain + void gatherAllOwnedConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const; +}; + diff --git a/parameter/ConfigurableElement.cpp b/parameter/ConfigurableElement.cpp new file mode 100644 index 0000000..9707fb2 --- /dev/null +++ b/parameter/ConfigurableElement.cpp @@ -0,0 +1,539 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ConfigurableElement.h" +#include "MappingData.h" +#include "SyncerSet.h" +#include "ConfigurableDomain.h" +#include "ConfigurationAccessContext.h" +#include "ConfigurableElementAggregator.h" +#include <assert.h> + +#define base CElement + +CConfigurableElement::CConfigurableElement(const string& strName) : base(strName), _uiOffset(0) +{ +} + +CConfigurableElement::~CConfigurableElement() +{ +} + +// XML configuration settings parsing +bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + if (!configurationAccessContext.serializeOut()) { + // Just do basic checks and propagate to children + CXmlElement::CChildIterator it(xmlConfigurableElementSettingsElement); + + CXmlElement xmlChildConfigurableElementSettingsElement; + + // Propagate to children + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + // Get child + const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + if (!it.next(xmlChildConfigurableElementSettingsElement)) { + + // Structure error + configurationAccessContext.setError("Configuration settings parsing: Settings don't conform to structure of configurable element " + getName()); + + return false; + } + + // Check element type matches in type + if (xmlChildConfigurableElementSettingsElement.getType() != pChildConfigurableElement->getKind()) { + + // Type error + configurationAccessContext.setError("Configuration settings parsing: Settings for configurable element " + pChildConfigurableElement->getName() + " does not match expected type: " + xmlChildConfigurableElementSettingsElement.getType() + " instead of " + pChildConfigurableElement->getKind()); + + return false; + } + + // Check element type matches in name + if (xmlChildConfigurableElementSettingsElement.getNameAttribute() != pChildConfigurableElement->getName()) { + + // Name error + configurationAccessContext.setError("Configuration settings parsing: Under configurable elememnt " + getName() + ", expected element name " + pChildConfigurableElement->getName() + " but found " + xmlChildConfigurableElementSettingsElement.getNameAttribute() + " instead"); + + return false; + } + + // Parse child configurable element's settings + if (!pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext)) { + + return false; + } + } + // There should remain no configurable element to parse + if (it.next(xmlChildConfigurableElementSettingsElement)) { + + // Structure error + configurationAccessContext.setError("Configuration settings parsing: Settings don't conform to structure of configurable element " + getName()); + + return false; + } + } else { + // Propagate to children + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + // Create corresponding child element + CXmlElement xmlChildConfigurableElementSettingsElement; + + xmlConfigurableElementSettingsElement.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); + + // Handle element name attribute + xmlChildConfigurableElementSettingsElement.setNameAttribute(pChildConfigurableElement->getName()); + + // Propagate + pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext); + } + } + // Done + return true; +} + +#if 0 +bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + if (!configurationAccessContext.serializeOut()) { + // Just do basic checks and propagate to children + CXmlElement::CChildIterator it(xmlConfigurableElementSettingsElement); + + CXmlElement xmlChildConfigurableElementSettingsElement; + + while (it.next(xmlChildConfigurableElementSettingsElement)) { + + // Find child configurable element + const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(findChild(xmlChildConfigurableElementSettingsElement.getNameAttribute())); + + if (!pChildConfigurableElement) { + + configurationAccessContext.setError("Configuration settings parsing: Unable to find configurable element " + xmlChildConfigurableElementSettingsElement.getNameAttribute() + " under configurable element " + getName()); + + return false; + } + + // Check element type matches + if (xmlChildConfigurableElementSettingsElement.getType() != pChildConfigurableElement->getKind()) { + + configurationAccessContext.setError("Settings for configurable element " + pChildConfigurableElement->getName() + " does not match expected type: " + xmlChildConfigurableElementSettingsElement.getType() + " instead of " + pChildConfigurableElement->getKind()); + + return false; + } + + // Parse child configurable element's settings + if (!pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext)) { + + return false; + } + } + } else { + // Propagate to children + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + // Create corresponding child element + CXmlElement xmlChildConfigurableElementSettingsElement; + + xmlConfigurableElementSettingsElement.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); + + // Handle element name attribute + xmlChildConfigurableElementSettingsElement.setNameAttribute(pChildConfigurableElement->getName()); + + // Propagate + pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext); + } + } + // Done + return true; +} +#endif + +// Parameter access +bool CConfigurableElement::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const +{ + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + errorContext.setError("Non settable element"); + + return false; + } + + const CConfigurableElement* pChild = static_cast<const CConfigurableElement*>(findChild(*pStrChildName)); + + if (!pChild) { + + errorContext.setError("Path not found: " + pathNavigator.getCurrentPath()); + + return false; + } + + return pChild->setValue(pathNavigator, strValue, errorContext); +} + +bool CConfigurableElement::getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const +{ + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + errorContext.setError("Non gettable element"); + + return false; + } + + const CConfigurableElement* pChild = static_cast<const CConfigurableElement*>(findChild(*pStrChildName)); + + if (!pChild) { + + errorContext.setError("Path not found: " + pathNavigator.getCurrentPath()); + + return false; + } + + return pChild->getValue(pathNavigator, strValue, errorContext); +} + +// Used for simulation only +void CConfigurableElement::setDefaultValues(CParameterAccessContext& parameterAccessContext) const +{ + // Propagate to children + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + pConfigurableElement->setDefaultValues(parameterAccessContext); + } +} + +// Offset +void CConfigurableElement::setOffset(uint32_t uiOffset) +{ + // Assign offset locally + _uiOffset = uiOffset; + + // Propagate to children + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(getChild(uiIndex)); + + pConfigurableElement->setOffset(uiOffset); + + uiOffset += pConfigurableElement->getFootPrint(); + } +} + +uint32_t CConfigurableElement::getOffset() const +{ + return _uiOffset; +} + +// Memory +uint32_t CConfigurableElement::getFootPrint() const +{ + uint32_t uiSize = 0; + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + uiSize += pConfigurableElement->getFootPrint(); + } + + return uiSize; +} + +// Browse parent path to find syncer +ISyncer* CConfigurableElement::getSyncer() const +{ + // Check parent + const CElement* pParent = getParent(); + + if (isOfConfigurableElementType(pParent)) { + + return static_cast<const CConfigurableElement*>(pParent)->getSyncer(); + } + return false; +} + +// Syncer set (me, ascendant or descendant ones) +void CConfigurableElement::fillSyncerSet(CSyncerSet& syncerSet) const +{ + // Try me or ascendants + ISyncer* pMineOrAscendantSyncer = getSyncer(); + + if (pMineOrAscendantSyncer) { + + // Provide found syncer object + syncerSet += pMineOrAscendantSyncer; + + // Done + return; + } + // Fetch descendant ones + fillSyncerSetFromDescendant(syncerSet); +} + +// Syncer set (descendant) +void CConfigurableElement::fillSyncerSetFromDescendant(CSyncerSet& syncerSet) const +{ + // Dig + uint32_t uiIndex; + uint32_t uiNbChildren = getNbChildren(); + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); + + pConfigurableElement->fillSyncerSetFromDescendant(syncerSet); + } +} + +// Configurable domain association +void CConfigurableElement::addAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain) +{ + _configurableDomainList.push_back(pConfigurableDomain); +} + +void CConfigurableElement::removeAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain) +{ + _configurableDomainList.remove(pConfigurableDomain); +} + +// Belonging domain +bool CConfigurableElement::belongsTo(const CConfigurableDomain* pConfigurableDomain) const +{ + if (containsConfigurableDomain(pConfigurableDomain)) { + + return true; + } + return belongsToDomainAscending(pConfigurableDomain); +} + +// Belonging domains +void CConfigurableElement::getBelongingDomains(list<const CConfigurableDomain*>& configurableDomainList) const +{ + configurableDomainList.insert(configurableDomainList.end(), _configurableDomainList.begin(), _configurableDomainList.end()); + + // Check parent + const CElement* pParent = getParent(); + + if (isOfConfigurableElementType(pParent)) { + + static_cast<const CConfigurableElement*>(pParent)->getBelongingDomains(configurableDomainList); + } +} + +void CConfigurableElement::listBelongingDomains(string& strResult, bool bVertical) const +{ + // Get belonging domain list + list<const CConfigurableDomain*> configurableDomainList; + + getBelongingDomains(configurableDomainList); + + // Fill list + listDomains(configurableDomainList, strResult, bVertical); +} + +// Elements with no domains +void CConfigurableElement::listRogueElements(string& strResult) const +{ + strResult = "\n"; + + // Get rogue element aggregate list (no associated domain) + list<const CConfigurableElement*> rogueElementList; + + CConfigurableElementAggregator configurableElementAggregator(rogueElementList, &CConfigurableElement::hasNoDomainAssociated); + + configurableElementAggregator.aggegate(this); + + // Build list as string + list<const CConfigurableElement*>::const_iterator it; + + for (it = rogueElementList.begin(); it != rogueElementList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + strResult += pConfigurableElement->getPath() + "\n"; + } +} + +// Matching check for no domain association +bool CConfigurableElement::hasNoDomainAssociated() const +{ + return _configurableDomainList.empty(); +} + +// Matching check for no valid associated domains +bool CConfigurableElement::hasNoValidDomainAssociated() const +{ + if (_configurableDomainList.empty()) { + + // No domains associated + return true; + } + + ConfigurableDomainListConstIterator it; + + // Browse all configurable domains for validity checking + for (it = _configurableDomainList.begin(); it != _configurableDomainList.end(); ++it) { + + const CConfigurableDomain* pConfigurableDomain = *it; + + if (pConfigurableDomain->isApplicableConfigurationValid(this)) { + + return false; + } + } + + return true; +} + +// Owning domains +void CConfigurableElement::listAssociatedDomains(string& strResult, bool bVertical) const +{ + // Fill list + listDomains(_configurableDomainList, strResult, bVertical); +} + +uint32_t CConfigurableElement::getBelongingDomainCount() const +{ + // Get belonging domain list + list<const CConfigurableDomain*> configurableDomainList; + + getBelongingDomains(configurableDomainList); + + return configurableDomainList.size(); +} + +void CConfigurableElement::listDomains(const list<const CConfigurableDomain*>& configurableDomainList, string& strResult, bool bVertical) const +{ + if (bVertical && configurableDomainList.empty()) { + + strResult = "\n"; + } + + // Fill list + ConfigurableDomainListConstIterator it; + bool bFirst = true; + + // Browse all configurable domains for comparison + for (it = configurableDomainList.begin(); it != configurableDomainList.end(); ++it) { + + const CConfigurableDomain* pConfigurableDomain = *it; + + if (!bVertical && !bFirst) { + + strResult += ", "; + } + + strResult += pConfigurableDomain->getName(); + + if (bVertical) { + + strResult += "\n"; + } else { + + bFirst = false; + } + } +} + +bool CConfigurableElement::containsConfigurableDomain(const CConfigurableDomain* pConfigurableDomain) const +{ + ConfigurableDomainListConstIterator it; + + // Browse all configurable domains for comparison + for (it = _configurableDomainList.begin(); it != _configurableDomainList.end(); ++it) { + + if (pConfigurableDomain == *it) { + + return true; + } + } + return false; +} + +// Belonging domain ascending search +bool CConfigurableElement::belongsToDomainAscending(const CConfigurableDomain* pConfigurableDomain) const +{ + // Check parent + const CElement* pParent = getParent(); + + if (isOfConfigurableElementType(pParent)) { + + return static_cast<const CConfigurableElement*>(pParent)->belongsTo(pConfigurableDomain); + } + return false; +} + +// Belonging subsystem +const CSubsystem* CConfigurableElement::getBelongingSubsystem() const +{ + const CElement* pParent = getParent(); + + // Stop at sytem class + if (!pParent->getParent()) { + + return NULL; + } + + return static_cast<const CConfigurableElement*>(pParent)->getBelongingSubsystem(); +} + +// Check parent is still of current type (by structure knowledge) +bool CConfigurableElement::isOfConfigurableElementType(const CElement* pParent) const +{ + assert(pParent); + + // Up to system class + return !!pParent->getParent(); +} diff --git a/parameter/ConfigurableElement.h b/parameter/ConfigurableElement.h new file mode 100644 index 0000000..5b61d3b --- /dev/null +++ b/parameter/ConfigurableElement.h @@ -0,0 +1,120 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +#include <list> + +class CConfigurableDomain; +class CSyncerSet; +class ISyncer; +class CSubsystem; +class CConfigurationAccessContext; +class CParameterAccessContext; + +class CConfigurableElement : public CElement +{ + friend class CConfigurableDomain; + typedef list<const CConfigurableDomain*>::const_iterator ConfigurableDomainListConstIterator; +public: + CConfigurableElement(const string& strName); + virtual ~CConfigurableElement(); + + // Offset in main blackboard + void setOffset(uint32_t uiOffset); + uint32_t getOffset() const; + + // Allocation + virtual uint32_t getFootPrint() const; + + // Syncer set (me, ascendant or descendant ones) + void fillSyncerSet(CSyncerSet& syncerSet) const; + + // Belonging domain + bool belongsTo(const CConfigurableDomain* pConfigurableDomain) const; + + // Belonging domains + void listBelongingDomains(string& strResult, bool bVertical = true) const; + + // Matching check for domain association + bool hasNoDomainAssociated() const; + + // Matching check for no valid associated domains + bool hasNoValidDomainAssociated() const; + + // Owning domains + void listAssociatedDomains(string& strResult, bool bVertical = true) const; + uint32_t getBelongingDomainCount() const; + + // Elements with no domains + void listRogueElements(string& strResult) const; + + // Parameter access + virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; + virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; + // Used for simulation only + virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; + + // XML configuration settings parsing + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; +protected: + // Syncer (me or ascendant) + virtual ISyncer* getSyncer() const; + // Syncer set (descendant) + virtual void fillSyncerSetFromDescendant(CSyncerSet& syncerSet) const; + // Configuration Domain local search + bool containsConfigurableDomain(const CConfigurableDomain* pConfigurableDomain) const; +private: + // Configurable domain association + void addAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain); + void removeAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain); + + // Belonging domain ascending search + bool belongsToDomainAscending(const CConfigurableDomain* pConfigurableDomain) const; + + // Belonging domains + void getBelongingDomains(list<const CConfigurableDomain*>& configurableDomainList) const; + void listDomains(const list<const CConfigurableDomain*>& configurableDomainList, string& strResult, bool bVertical) const; + + // Belonging subsystem + virtual const CSubsystem* getBelongingSubsystem() const; + + // Check parent is still of current type (by structure knowledge) + bool isOfConfigurableElementType(const CElement* pParent) const; + + // Offset in main blackboard + uint32_t _uiOffset; + + // Associated configurable domains + list<const CConfigurableDomain*> _configurableDomainList; +}; + diff --git a/parameter/ConfigurableElementAggregator.cpp b/parameter/ConfigurableElementAggregator.cpp new file mode 100644 index 0000000..a24c074 --- /dev/null +++ b/parameter/ConfigurableElementAggregator.cpp @@ -0,0 +1,79 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ConfigurableElementAggregator.h" +#include "ConfigurableElement.h" + +CConfigurableElementAggregator::CConfigurableElementAggregator(list<const CConfigurableElement*>& aggregateList, MatchesAggregationCriterion pfnMatchesAggregationCriterion) + : _aggregateList(aggregateList), _pfnMatchesAggregationCriterion(pfnMatchesAggregationCriterion) +{ +} + +// Aggregate +void CConfigurableElementAggregator::aggegate(const CConfigurableElement* pConfigurableElement) +{ + doAggregate(pConfigurableElement, _aggregateList); +} + +// Recursive aggregate +bool CConfigurableElementAggregator::doAggregate(const CConfigurableElement* pConfigurableElement, list<const CConfigurableElement*>& aggregateList) +{ + if (!(pConfigurableElement->*_pfnMatchesAggregationCriterion)()) { + + // Not a candidate for aggregation + return false; + } + // Check children + list<const CConfigurableElement*> childAggregateElementList; + + uint32_t uiIndex; + uint32_t uiNbChildren = pConfigurableElement->getNbChildren(); + uint32_t uiNbMatchingChildren = 0; + + for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { + + const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(pConfigurableElement->getChild(uiIndex)); + + uiNbMatchingChildren += doAggregate(pChildConfigurableElement, childAggregateElementList); + } + + if (uiNbMatchingChildren == uiNbChildren) { + + // All children match => self is a match + aggregateList.push_back(pConfigurableElement); + + return true; + } else { + // Add rogue children if any + aggregateList.insert(aggregateList.end(), childAggregateElementList.begin(), childAggregateElementList.end()); + + return false; + } +} diff --git a/parameter/ConfigurableElementAggregator.h b/parameter/ConfigurableElementAggregator.h new file mode 100644 index 0000000..58b0481 --- /dev/null +++ b/parameter/ConfigurableElementAggregator.h @@ -0,0 +1,61 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <list> + +using namespace std; + +class CConfigurableElement; + +class CConfigurableElementAggregator +{ +public: + // Matching check method type + typedef bool (CConfigurableElement::*MatchesAggregationCriterion)() const; + + // Constructor + CConfigurableElementAggregator(list<const CConfigurableElement*>& aggregateList, MatchesAggregationCriterion pfnMatchesAggregationCriterion); + + // Aggregate + void aggegate(const CConfigurableElement* pConfigurableElement); + +private: + // Recursive aggregate + bool doAggregate(const CConfigurableElement* pConfigurableElement, list<const CConfigurableElement*>& aggregateList); + + // Aggegate list + list<const CConfigurableElement*>& _aggregateList; + + // Matching check method + MatchesAggregationCriterion _pfnMatchesAggregationCriterion; +}; + diff --git a/parameter/ConfigurationAccessContext.cpp b/parameter/ConfigurationAccessContext.cpp new file mode 100644 index 0000000..4b97eff --- /dev/null +++ b/parameter/ConfigurationAccessContext.cpp @@ -0,0 +1,54 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ConfigurationAccessContext.h" + +#define base CParameterAccessContext + +CConfigurationAccessContext::CConfigurationAccessContext(string& strError, bool bSerializeOut) : base(strError), _bSerializeOut(bSerializeOut), _uiBaseOffset(0) +{ +} + +// Serialization direction +bool CConfigurationAccessContext::serializeOut() const +{ + return _bSerializeOut; +} + +// Base offset for blackboard access +void CConfigurationAccessContext::setBaseOffset(uint32_t uiBaseOffset) +{ + _uiBaseOffset = uiBaseOffset; +} + +uint32_t CConfigurationAccessContext::getBaseOffset() const +{ + return _uiBaseOffset; +} diff --git a/parameter/ConfigurationAccessContext.h b/parameter/ConfigurationAccessContext.h new file mode 100644 index 0000000..0f2966a --- /dev/null +++ b/parameter/ConfigurationAccessContext.h @@ -0,0 +1,54 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterAccessContext.h" +#include <stdint.h> + +class CConfigurationAccessContext : public CParameterAccessContext +{ +public: + CConfigurationAccessContext(string& strError, bool bSerializeOut); + + // Serialization direction + bool serializeOut() const; + + // Base offset for blackboard access + void setBaseOffset(uint32_t uiBaseOffset); + uint32_t getBaseOffset() const; + +private: + // Serialization direction + bool _bSerializeOut; + // Base offset where parameters are stored in configuration blackboards + uint32_t _uiBaseOffset; +}; + diff --git a/parameter/DomainConfiguration.cpp b/parameter/DomainConfiguration.cpp new file mode 100644 index 0000000..4ab5f1d --- /dev/null +++ b/parameter/DomainConfiguration.cpp @@ -0,0 +1,285 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "DomainConfiguration.h" +#include "AreaConfiguration.h" +#include "ConfigurableElement.h" +#include "CompoundRule.h" +#include <assert.h> + +#define base CBinarySerializableElement + +CDomainConfiguration::CDomainConfiguration(const string& strName) : base(strName) +{ +} + +CDomainConfiguration::~CDomainConfiguration() +{ + AreaConfigurationListIterator it; + + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + delete *it; + } +} + +// Class kind +string CDomainConfiguration::getKind() const +{ + return "Configuration"; +} + +// Child dynamic creation +bool CDomainConfiguration::childrenAreDynamic() const +{ + return true; +} + +// XML configuration settings parsing +bool CDomainConfiguration::serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext) +{ + // Find related AreaConfiguration + CAreaConfiguration* pAreaConfiguration = getAreaConfiguration(pConfigurableElement); + + assert(pAreaConfiguration); + + // Delegate to corresponding area configuration + return pAreaConfiguration->serializeXmlSettings(xmlConfigurationSettingsElement, configurationAccessContext); +} + +// Configurable Elements association +void CDomainConfiguration::addConfigurableElement(const CConfigurableElement* pConfigurableElement) +{ + _areaConfigurationList.push_back(new CAreaConfiguration(pConfigurableElement)); +} + +void CDomainConfiguration::removeConfigurableElement(const CConfigurableElement* pConfigurableElement) +{ + CAreaConfiguration* pAreaConfigurationToRemove = getAreaConfiguration(pConfigurableElement); + + _areaConfigurationList.remove(pAreaConfigurationToRemove); + + delete pAreaConfigurationToRemove; +} + +// Save data from current +void CDomainConfiguration::save(const CParameterBlackboard* pMainBlackboard) +{ + AreaConfigurationListIterator it; + + // Just propagate to areas + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + pAreaConfiguration->save(pMainBlackboard); + } +} + +// Apply data to current +void CDomainConfiguration::restore(CParameterBlackboard* pMainBlackboard) const +{ + AreaConfigurationListIterator it; + + // Just propagate to areas + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + const CAreaConfiguration* pAreaConfiguration = *it; + + pAreaConfiguration->restore(pMainBlackboard); + } +} + +// Ensure validity for configurable element area configuration +void CDomainConfiguration::validate(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard) +{ + CAreaConfiguration* pAreaConfigurationToValidate = getAreaConfiguration(pConfigurableElement); + + // Delegate + pAreaConfigurationToValidate->validate(pMainBlackboard); +} + +// Ensure validity of all area configurations +void CDomainConfiguration::validate(const CParameterBlackboard* pMainBlackboard) +{ + AreaConfigurationListIterator it; + + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + pAreaConfiguration->validate(pMainBlackboard); + } +} + +// Return configuration validity for given configurable element +bool CDomainConfiguration::isValid(const CConfigurableElement* pConfigurableElement) const +{ + // Get child configurable elemnt's area configuration + CAreaConfiguration* pAreaConfiguration = getAreaConfiguration(pConfigurableElement); + + assert(pAreaConfiguration); + + return pAreaConfiguration->isValid(); +} + +// Ensure validity of configurable element's area configuration by copying in from a valid one +void CDomainConfiguration::validateAgainst(const CDomainConfiguration* pValidDomainConfiguration, const CConfigurableElement* pConfigurableElement) +{ + // Retrieve related area configurations + CAreaConfiguration* pAreaConfigurationToValidate = getAreaConfiguration(pConfigurableElement); + const CAreaConfiguration* pAreaConfigurationToValidateAgainst = pValidDomainConfiguration->getAreaConfiguration(pConfigurableElement); + + // Delegate to area + pAreaConfigurationToValidate->validateAgainst(pAreaConfigurationToValidateAgainst); +} + +// Ensure validity of all configurable element's area configuration by copying in from a valid ones +void CDomainConfiguration::validateAgainst(const CDomainConfiguration* pValidDomainConfiguration) +{ + // Copy in configuration data from against domain + AreaConfigurationListIterator it, itAgainst; + + for (it = _areaConfigurationList.begin(), itAgainst = pValidDomainConfiguration->_areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it, ++itAgainst) { + + CAreaConfiguration* pAreaConfigurationToValidate = *it; + const CAreaConfiguration* pAreaConfigurationToValidateAgainst = *itAgainst; + + // Delegate to area + pAreaConfigurationToValidate->validateAgainst(pAreaConfigurationToValidateAgainst); + } +} + +// Dynamic data application +bool CDomainConfiguration::isApplicable() const +{ + const CCompoundRule* pRule = getRule(); + + return pRule && pRule->matches(); +} + +// Merge existing configurations to given configurable element ones +void CDomainConfiguration::merge(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement) +{ + // Retrieve related area configurations + CAreaConfiguration* pAreaConfigurationToMergeTo = getAreaConfiguration(pToConfigurableElement); + const CAreaConfiguration* pAreaConfigurationToMergeFrom = getAreaConfiguration(pFromConfigurableElement); + + // Do the merge + pAreaConfigurationToMergeTo->copyFromInner(pAreaConfigurationToMergeFrom); +} + +// Domain splitting +void CDomainConfiguration::split(CConfigurableElement* pFromConfigurableElement) +{ + // Retrieve related area configuration + const CAreaConfiguration* pAreaConfigurationToSplitFrom = getAreaConfiguration(pFromConfigurableElement); + + // Go through children areas to copy configuration data to them + uint32_t uiNbConfigurableElementChildren = pFromConfigurableElement->getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbConfigurableElementChildren; uiChild++) { + + CConfigurableElement* pToChildConfigurableElement = static_cast<CConfigurableElement*>(pFromConfigurableElement->getChild(uiChild)); + + // Get child configurable elemnt's area configuration + CAreaConfiguration* pChildAreaConfiguration = getAreaConfiguration(pToChildConfigurableElement); + + // Do the copy + pAreaConfigurationToSplitFrom->copyToInner(pChildAreaConfiguration); + } +} + +// AreaConfiguration retrieval from configurable element +CAreaConfiguration* CDomainConfiguration::getAreaConfiguration(const CConfigurableElement* pConfigurableElement) const +{ + AreaConfigurationListIterator it; + + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + if (pAreaConfiguration->getConfigurableElement() == pConfigurableElement) { + + return pAreaConfiguration; + } + } + // Not found? + assert(0); + + return NULL; +} + +// Presence of application condition +bool CDomainConfiguration::hasRule() const +{ + return !!getRule(); +} + +// Rule +const CCompoundRule* CDomainConfiguration::getRule() const +{ + if (getNbChildren()) { + // Rule created + return static_cast<const CCompoundRule*>(getChild(ECompoundRule)); + } + return NULL; +} + +// Serialization +void CDomainConfiguration::binarySerialize(CBinaryStream& binaryStream) +{ + AreaConfigurationListIterator it; + + // Just propagate to areas + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + CAreaConfiguration* pAreaConfiguration = *it; + + pAreaConfiguration->serialize(binaryStream); + } +} + +// Data size +uint32_t CDomainConfiguration::getDataSize() const +{ + uint32_t uiDataSize = 0; + AreaConfigurationListIterator it; + + // Just propagate request to areas + for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) { + + const CAreaConfiguration* pAreaConfiguration = *it; + + uiDataSize += pAreaConfiguration->getSize(); + } + return uiDataSize; +} diff --git a/parameter/DomainConfiguration.h b/parameter/DomainConfiguration.h new file mode 100644 index 0000000..27779ec --- /dev/null +++ b/parameter/DomainConfiguration.h @@ -0,0 +1,102 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "BinarySerializableElement.h" +#include <list> + +class CConfigurableElement; +class CAreaConfiguration; +class CParameterBlackboard; +class CConfigurationAccessContext; +class CCompoundRule; + +class CDomainConfiguration : public CBinarySerializableElement +{ + enum ChildElementType { + ECompoundRule + }; + typedef list<CAreaConfiguration*>::const_iterator AreaConfigurationListIterator; +public: + CDomainConfiguration(const string& strName); + virtual ~CDomainConfiguration(); + + // Configurable Elements association + void addConfigurableElement(const CConfigurableElement* pConfigurableElement); + void removeConfigurableElement(const CConfigurableElement* pConfigurableElement); + + // Save data from current + void save(const CParameterBlackboard* pMainBlackboard); + // Apply data to current + void restore(CParameterBlackboard* pMainBlackboard) const; + // Ensure validity for configurable element area configuration + void validate(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard); + // Ensure validity of all area configurations + void validate(const CParameterBlackboard* pMainBlackboard); + // Return configuration validity for given configurable element + bool isValid(const CConfigurableElement* pConfigurableElement) const; + // Ensure validity of configurable element's area configuration by copying in from a valid one + void validateAgainst(const CDomainConfiguration* pValidDomainConfiguration, const CConfigurableElement* pConfigurableElement); + // Ensure validity of all configurable element's area configuration by copying in from a valid ones + void validateAgainst(const CDomainConfiguration* pValidDomainConfiguration); + // Applicability checking + bool isApplicable() const; + // Merge existing configurations to given configurable element ones + void merge(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement); + // Domain splitting + void split(CConfigurableElement* pFromConfigurableElement); + + // XML configuration settings parsing/composing + bool serializeXmlSettings(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CConfigurationAccessContext& configurationAccessContext); + + // Presence of application condition + bool hasRule() const; + + // Serialization + virtual void binarySerialize(CBinaryStream& binaryStream); + + // Data size + virtual uint32_t getDataSize() const; + + // Class kind + virtual string getKind() const; +private: + // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean) + virtual bool childrenAreDynamic() const; + // AreaConfiguration retrieval from configurable element + CAreaConfiguration* getAreaConfiguration(const CConfigurableElement* pConfigurableElement) const; + + // Rule + const CCompoundRule* getRule() const; + + // AreaConfigurations + list<CAreaConfiguration*> _areaConfigurationList; +}; diff --git a/parameter/Element.cpp b/parameter/Element.cpp new file mode 100644 index 0000000..8cc6783 --- /dev/null +++ b/parameter/Element.cpp @@ -0,0 +1,649 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "Element.h" +#include <assert.h> +#include <stdio.h> +#include <stdarg.h> +#include "XmlElementSerializingContext.h" +#include "ElementLibrary.h" +#include "ErrorContext.h" + +CElement::CElement(const string& strName) : _strName(strName), _pParent(NULL) +{ +} + +CElement::~CElement() +{ + removeChildren(); +} + +// Logging +void CElement::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); + + doLog(acBuffer); +} + +void CElement::doLog(const string& strLog) const +{ + assert(_pParent); + + // Propagate till root + _pParent->doLog(strLog); +} + +void CElement::nestLog() const +{ + assert(_pParent); + + // Propagate till root + _pParent->nestLog(); +} + +void CElement::unnestLog() const +{ + assert(_pParent); + + // Propagate till root + _pParent->unnestLog(); +} + + +void CElement::setDescription(const string& strDescription) +{ + _strDescription = strDescription; +} + +const string& CElement::getDescription() const +{ + return _strDescription; +} + +bool CElement::childrenAreDynamic() const +{ + // By default, children are searched and not created during xml parsing + return false; +} + +bool CElement::init(string& strError) +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + CElement* pElement = _childArray[uiIndex];; + + if (!pElement->init(strError)) { + + return false; + } + } + + return true; +} + +void CElement::dumpContent(string& strContent, CErrorContext& errorContext, const uint32_t uiDepth) const +{ + string strIndent; + + // Level + uint32_t uiNbIndents = uiDepth; + + while (uiNbIndents--) { + + strIndent += " "; + } + // Type + strContent += strIndent + "- " + getKind(); + + // Name + if (!_strName.empty()) { + + strContent += ": " + getName(); + } + + // Value + string strValue; + logValue(strValue, errorContext); + + if (!strValue.empty()) { + + strContent += " = " + strValue; + } + + strContent += "\n"; + + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + _childArray[uiIndex]->dumpContent(strContent, errorContext, uiDepth + 1); + } +} + +void CElement::logValue(string& strValue, CErrorContext& errorContext) const +{ + (void)strValue; + (void)errorContext; +} + +// From IXmlSink +bool CElement::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Propagate through children + CXmlElement::CChildIterator childIterator(xmlElement); + + // Context + CXmlElementSerializingContext& elementSerializingContext = static_cast<CXmlElementSerializingContext&>(serializingContext); + + CXmlElement childElement; + + while (childIterator.next(childElement)) { + + CElement* pChild; + + if (!childrenAreDynamic()) { + + pChild = findChildOfKind(childElement.getType()); + + if (!pChild) { + + elementSerializingContext.setError("XML Path not found: " + xmlElement.getPath()); + + return false; + } + + } else { + // Child needs creation + pChild = elementSerializingContext.getElementLibrary()->createElement(childElement); + + if (pChild) { + + // Store created child! + addChild(pChild); + } else { + + elementSerializingContext.setError("Unable to create XML element " + childElement.getPath()); + + return false; + } + } + + // Dig + if (!pChild->fromXml(childElement, elementSerializingContext)) { + + return false; + } + } + + return true; +} + +// From IXmlSource +void CElement::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + // Browse children and propagate + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CElement* pChild = _childArray[uiChild]; + + // Create corresponding child element + CXmlElement xmlChildElement; + + xmlElement.createChild(xmlChildElement, pChild->getKind()); + + // Set attributes + pChild->setXmlNameAttribute(xmlChildElement); + + + // Propagate + pChild->toXml(xmlChildElement, serializingContext); + } +} + +void CElement::setXmlNameAttribute(CXmlElement& xmlElement) const +{ + // By default, set Name attribute if any + string strName = getName(); + + if (!strName.empty()) { + + xmlElement.setNameAttribute(strName); + } +} + +// Name +void CElement::setName(const string& strName) +{ + _strName = strName; +} + +const string& CElement::getName() const +{ + return _strName; +} + +bool CElement::rename(const string& strName, string& strError) +{ + // Check for conflict with brotherhood if relevant + if (_pParent && _pParent->childrenAreDynamic()) { + + uint32_t uiParentChild; + uint32_t uiParentNbChildren = _pParent->getNbChildren(); + + for (uiParentChild = 0; uiParentChild < uiParentNbChildren; uiParentChild++) { + + const CElement* pParentChild = _pParent->getChild(uiParentChild); + + if (pParentChild != this && pParentChild->getName() == strName) { + + // Conflict + strError = "Name conflicts with brother element"; + + return false; + } + } + } + // Change name + setName(strName); + + return true; +} + +string CElement::getPathName() const +{ + if (!_strName.empty()) { + + return _strName; + } else { + + return getKind(); + } +} + +void CElement::addChild(CElement* pChild) +{ + _childArray.push_back(pChild); + + pChild->_pParent = this; +} + +CElement* CElement::getChild(uint32_t uiIndex) +{ + assert(uiIndex <= _childArray.size()); + + return _childArray[uiIndex]; +} + +const CElement* CElement::getChild(uint32_t uiIndex) const +{ + assert(uiIndex <= _childArray.size()); + + return _childArray[uiIndex]; +} + +CElement* CElement::getLastChild() +{ + uint32_t uiNbChildren = getNbChildren(); + + assert(uiNbChildren); + + return _childArray[uiNbChildren - 1]; +} + +bool CElement::removeChild(CElement* pChild) +{ + ChildArrayIterator it; + + for (it = _childArray.begin(); it != _childArray.end(); ++it) { + + CElement* pElement = *it; + + if (pElement == pChild) { + + _childArray.erase(it); + + return true; + } + } + return false; +} + +void CElement::listChildren(string& strChildList) const +{ + strChildList = "\n"; + + // Get list of children names + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CElement* pChild = _childArray[uiChild]; + + strChildList += pChild->getName() + "\n"; + } +} + +string CElement::listQualifiedPaths(bool bDive, uint32_t uiLevel) const +{ + string strResult = getQualifiedPath() + "\n"; + + if (bDive || !uiLevel) { + // Get list of children paths + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CElement* pChild = _childArray[uiChild]; + + strResult += pChild->listQualifiedPaths(bDive, uiLevel + 1); + } + } + return strResult; +} + +void CElement::listChildrenPaths(string& strChildList) const +{ + strChildList = "\n"; + + // Get list of children paths + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CElement* pChild = _childArray[uiChild]; + + strChildList += pChild->getPath() + "\n"; + } +} + +uint32_t CElement::getNbChildren() const +{ + return _childArray.size(); +} + +const CElement* CElement::getParent() const +{ + return _pParent; +} + +CElement* CElement::getParent() +{ + return _pParent; +} + +void CElement::clean() +{ + if (childrenAreDynamic()) { + + removeChildren(); + } else { + // Just propagate + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + _childArray[uiIndex]->clean(); + } + } +} + +void CElement::removeChildren() +{ + // Delete in reverse order + ChildArrayReverseIterator it; + + for (it = _childArray.rbegin(); it != _childArray.rend(); ++it) { + + delete *it; + } + _childArray.clear(); +} + +const CElement* CElement::findDescendant(CPathNavigator& pathNavigator) const +{ + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + return this; + } + + const CElement* pChild = findChild(*pStrChildName); + + if (!pChild) { + + return NULL; + } + + return pChild->findDescendant(pathNavigator); +} + +CElement* CElement::findDescendant(CPathNavigator& pathNavigator) +{ + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + return this; + } + + CElement* pChild = findChild(*pStrChildName); + + if (!pChild) { + + return NULL; + } + + return pChild->findDescendant(pathNavigator); +} + +bool CElement::isDescendantOf(const CElement* pCandidateAscendant) const +{ + if (!_pParent) { + + return false; + } + if (_pParent == pCandidateAscendant) { + + return true; + } + return _pParent->isDescendantOf(pCandidateAscendant); +} + +CElement* CElement::findAscendantOfKind(const string& strKind) +{ + if (!_pParent) { + + return NULL; + } + + if (_pParent->getKind() == strKind) { + + return _pParent; + } + return _pParent->findAscendantOfKind(strKind); +} + +CElement* CElement::findChild(const string& strName) +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + CElement* pElement = _childArray[uiIndex]; + + if (pElement->getPathName() == strName) { + + return pElement; + } + } + + return NULL; +} + +const CElement* CElement::findChild(const string& strName) const +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + const CElement* pElement = _childArray[uiIndex]; + + if (pElement->getPathName() == strName) { + + return pElement; + } + } + + return NULL; +} + +CElement* CElement::findChildOfKind(const string& strKind) +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + CElement* pElement = _childArray[uiIndex]; + + if (pElement->getKind() == strKind) { + + return pElement; + } + } + + return NULL; +} + +const CElement* CElement::findChildOfKind(const string& strKind) const +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + const CElement* pElement = _childArray[uiIndex];; + + if (pElement->getKind() == strKind) { + + return pElement; + } + } + + return NULL; +} + +CElement* CElement::getRoot() +{ + if (!_pParent) { + + return this; + } + return _pParent->getRoot(); +} + +const CElement* CElement::getRoot() const +{ + if (!_pParent) { + + return this; + } + return _pParent->getRoot(); +} + +string CElement::getPath() const +{ + // Take out root element from the path + if (_pParent && _pParent->_pParent) { + + return _pParent->getPath() + "/" + getPathName(); + } + return "/" + getPathName(); +} + +string CElement::getQualifiedPath() const +{ + return getPath() + " [" + getKind() + "]"; +} + +uint32_t CElement::getDepth() const +{ + if (_pParent) { + + return _pParent->getDepth() + 1; + } + + return 0; +} + +// Checksum for integrity checks +uint8_t CElement::computeStructureChecksum() const +{ + // Base checksum computation on element kind + string strKind = getKind(); + + // Get element kind + const char* pcData = strKind.c_str(); + + // Cumulate + uint8_t uiChecksum = 0; + + while (*pcData) { + + uiChecksum += *pcData++; + } + + // Propagate + uint32_t uiIndex; + for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { + + const CElement* pChild = _childArray[uiIndex]; + + uiChecksum += pChild->computeStructureChecksum(); + } + + return uiChecksum; +} + diff --git a/parameter/Element.h b/parameter/Element.h new file mode 100644 index 0000000..b3c3060 --- /dev/null +++ b/parameter/Element.h @@ -0,0 +1,145 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <string> +#include <vector> +#include <stdint.h> +#include "XmlSink.h" +#include "XmlSource.h" + +#include "PathNavigator.h" + +using namespace std; + +class CXmlElementSerializingContext; +class CErrorContext; + +class CElement : public IXmlSink, public IXmlSource +{ + friend class CAutoLog; +public: + CElement(const string& strName = ""); + virtual ~CElement(); + + // Logging + void log(const string& strMessage, ...) const; + + // Description + void setDescription(const string& strDescription); + const string& getDescription() const; + + // Name / Path + const string& getName() const; + bool rename(const string& strName, string& strError); + string getPath() const; + string getQualifiedPath() const; + + // Creation / build + virtual bool init(string& strError); + virtual void clean(); + + // Children management + void addChild(CElement* pChild); + bool removeChild(CElement* pChild); + void listChildren(string& strChildList) const; + string listQualifiedPaths(bool bDive, uint32_t uiLevel = 0) const; + void listChildrenPaths(string& strChildPathList) const; + + // Hierarchy query + uint32_t getNbChildren() const; + CElement* findChildOfKind(const string& strKind); + const CElement* findChildOfKind(const string& strKind) const; + const CElement* getParent() const; + const CElement* getChild(uint32_t uiIndex) const; + CElement* getChild(uint32_t uiIndex); + const CElement* findChild(const string& strName) const; + CElement* findChild(const string& strName); + const CElement* findDescendant(CPathNavigator& pathNavigator) const; + CElement* findDescendant(CPathNavigator& pathNavigator); + bool isDescendantOf(const CElement* pCandidateAscendant) const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // From IXmlSource + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Content structure dump + void dumpContent(string& strContent, CErrorContext& errorContext, const uint32_t uiDepth = 0) const; + + // Checksum for integrity checks + uint8_t computeStructureChecksum() const; + + // Class kind + virtual string getKind() const = 0; +protected: + // Content dumping + virtual void logValue(string& strValue, CErrorContext& errorContext) const; + // Name setting + void setName(const string& strName); + + // Hierarchy + CElement* getLastChild(); + CElement* getParent(); + CElement* findAscendantOfKind(const string& strKind); + CElement* getRoot(); + const CElement* getRoot() const; +private: + // Logging (done by root) + virtual void doLog(const string& strLog) const; + virtual void nestLog() const; + virtual void unnestLog() const; + // Returns Name or Kind if no Name + string getPathName() const; + // Returns true if children dynamic creation is to be dealt with + virtual bool childrenAreDynamic() const; + // House keeping + void removeChildren(); + // For logging + uint32_t getDepth() const; + // Fill XmlElement during XML composing + void setXmlNameAttribute(CXmlElement& xmlElement) const; + + // Name + string _strName; + + // Description + string _strDescription; + + // Child iterators + typedef vector<CElement*>::iterator ChildArrayIterator; + typedef vector<CElement*>::reverse_iterator ChildArrayReverseIterator; + // Children + vector<CElement*> _childArray; + // Parent + CElement* _pParent; +}; diff --git a/parameter/ElementBuilder.cpp b/parameter/ElementBuilder.cpp new file mode 100644 index 0000000..2b52692 --- /dev/null +++ b/parameter/ElementBuilder.cpp @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ElementBuilder.h" + +CElementBuilder::CElementBuilder(const string& strType) : _strType(strType) +{ +} + +CElementBuilder::~CElementBuilder() +{ +} + +const string& CElementBuilder::getType() const +{ + return _strType; +} diff --git a/parameter/ElementBuilder.h b/parameter/ElementBuilder.h new file mode 100644 index 0000000..da3a276 --- /dev/null +++ b/parameter/ElementBuilder.h @@ -0,0 +1,46 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CElementBuilder +{ +public: + CElementBuilder(const string& strType); + virtual ~CElementBuilder(); + + const string& getType() const; + + virtual CElement* createElement(const CXmlElement& xmlElement) const = 0; +private: + string _strType; +}; diff --git a/parameter/ElementBuilderTemplate.h b/parameter/ElementBuilderTemplate.h new file mode 100644 index 0000000..3a1c968 --- /dev/null +++ b/parameter/ElementBuilderTemplate.h @@ -0,0 +1,46 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ElementBuilder.h" + +template <class ElementType> +class CElementBuilderTemplate : public CElementBuilder +{ +public: + CElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + + virtual CElement* createElement(const CXmlElement& xmlElement) const + { + (void)xmlElement; + return new ElementType; + } +}; diff --git a/parameter/ElementLibrary.cpp b/parameter/ElementLibrary.cpp new file mode 100644 index 0000000..8b3ab8a --- /dev/null +++ b/parameter/ElementLibrary.cpp @@ -0,0 +1,75 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ElementLibrary.h" +#include "ElementBuilder.h" + + +CElementLibrary::CElementLibrary() +{ +} + +CElementLibrary::~CElementLibrary() +{ + clean(); +} + +void CElementLibrary::clean() +{ + ElementBuilderMapIterator it; + + for (it = _elementBuilderMap.begin(); it != _elementBuilderMap.end(); ++it) { + + delete it->second; + } + _elementBuilderMap.clear(); +} + +CElement* CElementLibrary::createElement(const CXmlElement& xmlElement) const +{ + ElementBuilderMapConstIterator it = _elementBuilderMap.find(getBuilderType(xmlElement)); + + if (it != _elementBuilderMap.end()) { + + return it->second->createElement(xmlElement); + } + return NULL; +} + +void CElementLibrary::addElementBuilder(CElementBuilder* pElementBuilder) +{ + _elementBuilderMap[pElementBuilder->getType()] = pElementBuilder; +} + +string CElementLibrary::getBuilderType(const CXmlElement& xmlElement) const +{ + // Defaulting to xml element name + return xmlElement.getType(); +} diff --git a/parameter/ElementLibrary.h b/parameter/ElementLibrary.h new file mode 100644 index 0000000..d41bf09 --- /dev/null +++ b/parameter/ElementLibrary.h @@ -0,0 +1,64 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <map> +#include <string> + +#include "Element.h" + +using namespace std; + +class CElementBuilder; + +class CElementLibrary +{ + typedef map<string, CElementBuilder*>::iterator ElementBuilderMapIterator; + typedef map<string, CElementBuilder*>::const_iterator ElementBuilderMapConstIterator; + +public: + CElementLibrary(); + virtual ~CElementLibrary(); + + // Filling + void addElementBuilder(CElementBuilder* pElementBuilder); + void clean(); + + // Instantiation + CElement* createElement(const CXmlElement& xmlElement) const; + +private: + // Builder type + virtual string getBuilderType(const CXmlElement& xmlElement) const; + + // Builders + map<string, CElementBuilder*> _elementBuilderMap; +}; diff --git a/parameter/ElementLibrarySet.cpp b/parameter/ElementLibrarySet.cpp new file mode 100644 index 0000000..5bb6fe4 --- /dev/null +++ b/parameter/ElementLibrarySet.cpp @@ -0,0 +1,58 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ElementLibrarySet.h" +#include <assert.h> + +CElementLibrarySet::CElementLibrarySet() +{ +} + +CElementLibrarySet::~CElementLibrarySet() +{ + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _elementLibraryArray.size(); uiIndex++) { + + delete _elementLibraryArray[uiIndex]; + } +} + +void CElementLibrarySet::addElementLibrary(CElementLibrary* pElementLibrary) +{ + _elementLibraryArray.push_back(pElementLibrary); +} + +CElementLibrary* CElementLibrarySet::getElementLibrary(uint32_t uiIndex) const +{ + assert(uiIndex <= _elementLibraryArray.size()); + + return _elementLibraryArray[uiIndex]; +} diff --git a/parameter/ElementLibrarySet.h b/parameter/ElementLibrarySet.h new file mode 100644 index 0000000..8ff625d --- /dev/null +++ b/parameter/ElementLibrarySet.h @@ -0,0 +1,45 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ElementLibrary.h" + +class CElementLibrarySet +{ +public: + CElementLibrarySet(); + ~CElementLibrarySet(); + + void addElementLibrary(CElementLibrary* pElementLibrary); + CElementLibrary* getElementLibrary(uint32_t uiIndex) const; + +private: + typedef vector<CElementLibrary*>::iterator CElementLibraryArrayIterator; + vector<CElementLibrary*> _elementLibraryArray; +}; diff --git a/parameter/ElementLocator.cpp b/parameter/ElementLocator.cpp new file mode 100644 index 0000000..71ed5ad --- /dev/null +++ b/parameter/ElementLocator.cpp @@ -0,0 +1,85 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ElementLocator.h" +#include "PathNavigator.h" + +CElementLocator::CElementLocator(CElement* pSubRootElement, bool bStrict) : _pSubRootElement(pSubRootElement), _bStrict(bStrict) +{ +} + + +// Locate element +bool CElementLocator::locate(const string& strPath, CElement** ppElement, string& strError) +{ + CPathNavigator pathNavigator(strPath); + + if (!pathNavigator.isPathValid()) { + + strError = "Invalid Path"; + + return false; + } + + // Sub root element? + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + if (_bStrict) { + + strError = "Path not found"; + + return false; + } + // Empty path + return true; + } + + if (*pStrChildName != _pSubRootElement->getName()) { + + strError = "Path not found"; + + return false; + } + + // Find in tree + *ppElement = _pSubRootElement->findDescendant(pathNavigator); + + if (!*ppElement) { + + strError = "Path not found"; + + return false; + } + + return true; +} + diff --git a/parameter/ElementLocator.h b/parameter/ElementLocator.h new file mode 100644 index 0000000..27757bf --- /dev/null +++ b/parameter/ElementLocator.h @@ -0,0 +1,50 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CElementLocator +{ +public: + CElementLocator(CElement* pSubRootElement, bool bStrict = true); + + // Locate element + bool locate(const string& strPath, CElement** ppElement, string& strError); + +private: + // Subroot element + CElement* _pSubRootElement; + + // Strict means empty path will cause path not found error to be returned + bool _bStrict; +}; + diff --git a/parameter/ErrorContext.cpp b/parameter/ErrorContext.cpp new file mode 100644 index 0000000..06ccf39 --- /dev/null +++ b/parameter/ErrorContext.cpp @@ -0,0 +1,52 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ErrorContext.h" + +CErrorContext::CErrorContext(string& strError) : _strError(strError) +{ +} + +// Error +void CErrorContext::setError(const string& strError) +{ + _strError = strError; +} + +void CErrorContext::appendToError(const string& strAppend) +{ + _strError += strAppend; +} + +const string& CErrorContext::getError() const +{ + return _strError; +} + diff --git a/parameter/ErrorContext.h b/parameter/ErrorContext.h new file mode 100644 index 0000000..919a226 --- /dev/null +++ b/parameter/ErrorContext.h @@ -0,0 +1,51 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <string> + +using namespace std; + +class CErrorContext +{ +public: + CErrorContext(string& strError); + + // Error + void setError(const string& strError); + void appendToError(const string& strAppend); + const string& getError() const; + +private: + // Error reference + string& _strError; +}; + diff --git a/parameter/FixedPointParameterType.cpp b/parameter/FixedPointParameterType.cpp new file mode 100644 index 0000000..86c9053 --- /dev/null +++ b/parameter/FixedPointParameterType.cpp @@ -0,0 +1,173 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "FixedPointParameterType.h" +#include <stdlib.h> +#include <sstream> +#include "Parameter.h" +#include "ParameterAccessContext.h" +#include "ConfigurationAccessContext.h" + +#define base CParameterType + +CFixedPointParameterType::CFixedPointParameterType(const string& strName) : base(strName), _uiIntegral(0), _uiFractional(0) +{ +} + +string CFixedPointParameterType::getKind() const +{ + return "FixedPointParameter"; +} + +// XML Serialization value space handling +// Value space handling for configuration import +void CFixedPointParameterType::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Direction? + if (!configurationAccessContext.serializeOut()) { + + // Get Value space from XML + if (xmlConfigurableElementSettingsElement.hasAttribute("ValueSpace")) { + + configurationAccessContext.setValueSpaceRaw(xmlConfigurableElementSettingsElement.getAttributeBoolean("ValueSpace", "Raw")); + } else { + + configurationAccessContext.setValueSpaceRaw(false); + } + } else { + // Provide value space only if not the default one + if (configurationAccessContext.valueSpaceIsRaw()) { + + xmlConfigurableElementSettingsElement.setAttributeString("ValueSpace", "Raw"); + } + } +} + +bool CFixedPointParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Size + uint32_t uiSizeInBits = xmlElement.getAttributeInteger("Size"); + + // Q notation + _uiIntegral = xmlElement.getAttributeInteger("Integral"); + _uiFractional = xmlElement.getAttributeInteger("Fractional"); + + // Size vs. Q notation integrity check + if (uiSizeInBits < getUtilSizeInBits()) { + + serializingContext.setError("Inconsistent Size vs. Q notation for " + getKind() + " " + xmlElement.getPath() + ": Summing (Integral + _uiFractional + 1) should be less than given Size (" + xmlElement.getAttributeString("Size") + ")"); + + return false; + } + + // Set the size + setSize(uiSizeInBits / 8); + + return base::fromXml(xmlElement, serializingContext); +} + +bool CFixedPointParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const +{ + int32_t iData; + + if (parameterAccessContext.valueSpaceIsRaw()) { + + iData = strtol(strValue.c_str(), NULL, 0); + + } else { + double dData = strtod(strValue.c_str(), NULL); + + // Do the conversion + iData = (int32_t)(dData * (1UL << _uiFractional) + 0.5F - (double)(dData < 0)); + } + + // Check for admitted range: [-2^m, 2^m - 2^n] + uint32_t uiSizeInBits = getUtilSizeInBits(); + + int32_t iMin = ((int32_t)1 << 31) >> (32 - uiSizeInBits); + int32_t iMax = -iMin - 1; + + if (iData < iMin || iData > iMax) { + ostringstream strStream; + + strStream << "Value " << strValue << " standing out of admitted "; + + if (!parameterAccessContext.valueSpaceIsRaw()) { + + strStream << "real range [" << (double)iMin / (1UL << _uiFractional) << ", "<< (double)iMax / (1UL << _uiFractional) << "]"; + } else { + + strStream << "raw range [" << iMin << ", " << iMax << "]"; + } + strStream << " for " << getKind(); + + parameterAccessContext.setError(strStream.str()); + + return false; + } + + uiValue = (uint32_t)iData; + + return true; +} + +void CFixedPointParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const +{ + int32_t iData = (int32_t)uiValue; + + // Sign extend + uint32_t uiShift = 32 - getUtilSizeInBits(); + + if (uiShift) { + + iData = (iData << uiShift) >> uiShift; + } + + // Format + ostringstream strStream; + + if (parameterAccessContext.valueSpaceIsRaw()) { + + strStream << iData; + } else { + + double dData = (double)iData / (1UL << _uiFractional); + + strStream << dData; + } + + strValue = strStream.str(); +} + +// Util size +uint32_t CFixedPointParameterType::getUtilSizeInBits() const +{ + return _uiIntegral + _uiFractional + 1; +} diff --git a/parameter/FixedPointParameterType.h b/parameter/FixedPointParameterType.h new file mode 100644 index 0000000..4aaf5a0 --- /dev/null +++ b/parameter/FixedPointParameterType.h @@ -0,0 +1,61 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterType.h" + +class CFixedPointParameterType : public CParameterType +{ +public: + CFixedPointParameterType(const string& strName); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // XML Serialization value space handling + // Value space handling for configuration import + virtual void handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + + // Conversion + virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; + virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; + + // CElement + virtual string getKind() const; +private: + // Util size + uint32_t getUtilSizeInBits() const; + + // Integral part in Q notation + uint32_t _uiIntegral; + // Fractional part in Q notation + uint32_t _uiFractional; +}; diff --git a/parameter/FrameworkConfigurationGroup.cpp b/parameter/FrameworkConfigurationGroup.cpp new file mode 100644 index 0000000..6e99369 --- /dev/null +++ b/parameter/FrameworkConfigurationGroup.cpp @@ -0,0 +1,43 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "FrameworkConfigurationGroup.h" + +#define base CKindElement + +CFrameworkConfigurationGroup::CFrameworkConfigurationGroup(const string& strName, const string& strKind) : base(strName, strKind) +{ +} + +bool CFrameworkConfigurationGroup::childrenAreDynamic() const +{ + return true; +} + diff --git a/parameter/FrameworkConfigurationGroup.h b/parameter/FrameworkConfigurationGroup.h new file mode 100644 index 0000000..a8a5dd3 --- /dev/null +++ b/parameter/FrameworkConfigurationGroup.h @@ -0,0 +1,42 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "KindElement.h" + +class CFrameworkConfigurationGroup : public CKindElement +{ +public: + CFrameworkConfigurationGroup(const string& strName, const string& strKind); + +private: + virtual bool childrenAreDynamic() const; +}; diff --git a/parameter/FrameworkConfigurationLocation.cpp b/parameter/FrameworkConfigurationLocation.cpp new file mode 100644 index 0000000..77c8d71 --- /dev/null +++ b/parameter/FrameworkConfigurationLocation.cpp @@ -0,0 +1,109 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "FrameworkConfigurationLocation.h" +#include <assert.h> + +#define base CKindElement + +CFrameworkConfigurationLocation::CFrameworkConfigurationLocation(const string& strName, const string& strKind) : base(strName, strKind) +{ +} + +// From IXmlSink +bool CFrameworkConfigurationLocation::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + _strPath = xmlElement.getAttributeString("Path"); + + if (_strPath.empty()) { + + serializingContext.setError("Empty Path attribute in elememnt " + xmlElement.getPath()); + + return false; + } + return true; +} + +string CFrameworkConfigurationLocation::getFilePath(const string& strBaseFolder) const +{ + if (isPathRelative()) { + + return strBaseFolder + "/" + _strPath; + } + return _strPath; +} + +bool CFrameworkConfigurationLocation::isPathRelative() const +{ + return _strPath[0] != '/'; +} + +string CFrameworkConfigurationLocation::getFolderPath(const string& strBaseFolder) const +{ + uint32_t uiSlashPos = _strPath.rfind('/', -1); + + string strFolderPath = "."; + + if (isPathRelative()) { + + if (uiSlashPos != (uint32_t)-1) { + + strFolderPath = _strPath.substr(0, uiSlashPos); + + return strBaseFolder + "/" + strFolderPath; + + } else { + + return strBaseFolder; + } + } else { + + assert(uiSlashPos != (uint32_t)-1); + + strFolderPath = _strPath.substr(0, uiSlashPos); + + return strFolderPath; + } +} + +#if 0 +string CFrameworkConfigurationLocation::getFileName() const +{ + uint32_t uiSlashPos = _strPath.rfind('/', -1); + + if (uiSlashPos != (uint32_t)-1) { + + return _strPath.substr(uiSlashPos + 1, _strPath.size() - uiSlashPos - 1); + } else { + + return _strPath; + } +} +#endif diff --git a/parameter/FrameworkConfigurationLocation.h b/parameter/FrameworkConfigurationLocation.h new file mode 100644 index 0000000..2b3bd9a --- /dev/null +++ b/parameter/FrameworkConfigurationLocation.h @@ -0,0 +1,49 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "KindElement.h" + +class CFrameworkConfigurationLocation : public CKindElement +{ +public: + CFrameworkConfigurationLocation(const string& strName, const string& strKind); + + string getFilePath(const string& strBaseFolder) const; + string getFolderPath(const string& strBaseFolder) const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); +private: + bool isPathRelative() const; + + string _strPath; +}; diff --git a/parameter/HardwareBackSynchronizer.cpp b/parameter/HardwareBackSynchronizer.cpp new file mode 100644 index 0000000..df2b41d --- /dev/null +++ b/parameter/HardwareBackSynchronizer.cpp @@ -0,0 +1,55 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "HardwareBackSynchronizer.h" +#include "ConfigurableElement.h" + +#define base CBackSynchronizer + +CHardwareBackSynchronizer::CHardwareBackSynchronizer(const CConfigurableElement* pConfigurableElement, string& strError, CParameterBlackboard* pParameterBlackboard) + : base(pConfigurableElement), _strError(strError), _pParameterBlackboard(pParameterBlackboard) +{ + // Fill back syncer set + list<const CConfigurableElement*>::const_iterator it; + + for (it = _needingBackSyncList.begin(); it != _needingBackSyncList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + pConfigurableElement->fillSyncerSet(_backSyncerSet); + } +} + +// Back synchronization +bool CHardwareBackSynchronizer::sync() +{ + // Perform back synchronization + return _backSyncerSet.sync(*_pParameterBlackboard, true, _strError); +} diff --git a/parameter/HardwareBackSynchronizer.h b/parameter/HardwareBackSynchronizer.h new file mode 100644 index 0000000..f2259b4 --- /dev/null +++ b/parameter/HardwareBackSynchronizer.h @@ -0,0 +1,52 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "BackSynchronizer.h" +#include "SyncerSet.h" + +class CHardwareBackSynchronizer : public CBackSynchronizer +{ +public: + CHardwareBackSynchronizer(const CConfigurableElement* pConfigurableElement, string& strError, CParameterBlackboard* pParameterBlackboard); + + // Back synchronization + virtual bool sync(); + +private: + // Back syncer set + CSyncerSet _backSyncerSet; + // Error + string& _strError; + // Parameter blackboard + CParameterBlackboard* _pParameterBlackboard; +}; + diff --git a/parameter/InstanceConfigurableElement.cpp b/parameter/InstanceConfigurableElement.cpp new file mode 100644 index 0000000..9dcc2ef --- /dev/null +++ b/parameter/InstanceConfigurableElement.cpp @@ -0,0 +1,171 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "InstanceConfigurableElement.h" +#include "Mapper.h" +#include "SyncerSet.h" +#include "Syncer.h" +#include "TypeElement.h" +#include "ParameterAccessContext.h" +#include <assert.h> + +#define base CConfigurableElement + +CInstanceConfigurableElement::CInstanceConfigurableElement(const string& strName, const CTypeElement* pTypeElement) : base(strName), _pTypeElement(pTypeElement), _pSyncer(NULL) +{ +} + +string CInstanceConfigurableElement::getKind() const +{ + // Delegate + return getTypeElement()->getKind(); +} + +// Type element +const CTypeElement* CInstanceConfigurableElement::getTypeElement() const +{ + return _pTypeElement; +} + +// Mapping +bool CInstanceConfigurableElement::getMappingData(const string& strKey, string& strValue) const +{ + // Delegate + return getTypeElement()->getMappingData(strKey, strValue); +} + +bool CInstanceConfigurableElement::map(IMapper& mapper, string& strError) +{ + bool bHasMappingData = getTypeElement()->hasMappingData(); + + // Begin + if (bHasMappingData) { + + if (!mapper.mapBegin(this, strError)) { + + return false; + } + } + + // Map children + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + CInstanceConfigurableElement* pInstanceConfigurableChildElement = static_cast<CInstanceConfigurableElement*>(getChild(uiChild)); + + if (!pInstanceConfigurableChildElement->map(mapper, strError)) { + + return false; + } + } + + // End + if (bHasMappingData) { + + mapper.mapEnd(); + } + return true; +} + +// Sync to HW +void CInstanceConfigurableElement::setSyncer(ISyncer* pSyncer) +{ + assert(!_pSyncer); + + _pSyncer = pSyncer; +} + +void CInstanceConfigurableElement::unsetSyncer() +{ + _pSyncer = NULL; +} + +// Syncer +ISyncer* CInstanceConfigurableElement::getSyncer() const +{ + if (_pSyncer) { + + return _pSyncer; + } + // Check parent + return base::getSyncer(); +} + +// Syncer set (descendant) +void CInstanceConfigurableElement::fillSyncerSetFromDescendant(CSyncerSet& syncerSet) const +{ + if (_pSyncer) { + + syncerSet += _pSyncer; + } else { + // Continue digging + base::fillSyncerSetFromDescendant(syncerSet); + } +} + +// Sync +bool CInstanceConfigurableElement::sync(CParameterAccessContext& parameterAccessContext) const +{ + ISyncer* pSyncer = getSyncer(); + + if (!pSyncer) { + + parameterAccessContext.setError("Unable to synchronize modification. No Syncer object assiciated to configurable element " + getPath()); + + return false; + } + string strError; + + if (!pSyncer->sync(*parameterAccessContext.getParameterBlackboard(), false, strError)) { + + parameterAccessContext.setError(strError); + + return false; + } + return true; +} + +// Check parameter access path well formed for leaf elements +bool CInstanceConfigurableElement::checkPathExhausted(CPathNavigator& pathNavigator, CErrorContext& errorContext) +{ + string* pStrChildName = pathNavigator.next(); + + if (pStrChildName) { + + // Should be leaf element + errorContext.setError("Path not found: " + pathNavigator.getCurrentPath()); + + return false; + } + return true; +} + diff --git a/parameter/InstanceConfigurableElement.h b/parameter/InstanceConfigurableElement.h new file mode 100644 index 0000000..517646c --- /dev/null +++ b/parameter/InstanceConfigurableElement.h @@ -0,0 +1,87 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ConfigurableElement.h" +#include "TypeElement.h" + +class IMapper; +class CParameterBlackboard; +class CParameterAccessContext; + +class CInstanceConfigurableElement : public CConfigurableElement +{ +public: + enum Type { + EBitParameter, + EBitParameterBlock, + EParameter, + EParameterBlock, + EComponent + }; + + CInstanceConfigurableElement(const string& strName, const CTypeElement* pTypeElement); + + // Instantiated type + const CTypeElement* getTypeElement() const; + + // Mapping info + bool getMappingData(const string& strKey, string& strValue) const; + + // From CElement + virtual string getKind() const; + + // Syncer to/from HW + void setSyncer(ISyncer* pSyncer); + void unsetSyncer(); + + // Type + virtual Type getType() const = 0; + + // Mapping execution + bool map(IMapper& mapper, string& strError); +protected: + // Syncer + virtual ISyncer* getSyncer() const; + // Syncer set (descendant) + virtual void fillSyncerSetFromDescendant(CSyncerSet& syncerSet) const; + // Sync + bool sync(CParameterAccessContext& parameterAccessContext) const; + // Check parameter access path well formed for leaf elements + static bool checkPathExhausted(CPathNavigator& pathNavigator, CErrorContext& errorContext); +private: + // Type Element + const CTypeElement* _pTypeElement; + + // Sync to HW + ISyncer* _pSyncer; +}; + diff --git a/parameter/InstanceDefinition.cpp b/parameter/InstanceDefinition.cpp new file mode 100644 index 0000000..46f52b0 --- /dev/null +++ b/parameter/InstanceDefinition.cpp @@ -0,0 +1,61 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "InstanceDefinition.h" +#include <assert.h> + +#define base CTypeElement + +CInstanceDefinition::CInstanceDefinition() +{ +} + +string CInstanceDefinition::getKind() const +{ + return "InstanceDefinition"; +} + +bool CInstanceDefinition::childrenAreDynamic() const +{ + return true; +} + +CInstanceConfigurableElement* CInstanceDefinition::doInstantiate() const +{ + // Element not supposed to be instantiated direcly + assert(0); + + return NULL; +} + +void CInstanceDefinition::createInstances(CElement* pFatherElement) +{ + populate(pFatherElement); +} diff --git a/parameter/InstanceDefinition.h b/parameter/InstanceDefinition.h new file mode 100644 index 0000000..98cba40 --- /dev/null +++ b/parameter/InstanceDefinition.h @@ -0,0 +1,46 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "TypeElement.h" + +class CInstanceDefinition : public CTypeElement +{ +public: + CInstanceDefinition(); + + void createInstances(CElement* pFatherElement); + + virtual string getKind() const; +private: + virtual bool childrenAreDynamic() const; + virtual CInstanceConfigurableElement* doInstantiate() const; +}; diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp new file mode 100644 index 0000000..14093ff --- /dev/null +++ b/parameter/IntegerParameterType.cpp @@ -0,0 +1,160 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "IntegerParameterType.h" +#include <stdlib.h> +#include <sstream> +#include "ParameterAccessContext.h" + +#define base CParameterType + +CIntegerParameterType::CIntegerParameterType(const string& strName) : base(strName), _uiMin(0), _uiMax(uint32_t(-1)) +{ +} + +string CIntegerParameterType::getKind() const +{ + return "IntegerParameter"; +} + +bool CIntegerParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Sign + _bSigned = xmlElement.getAttributeBoolean("Signed"); + + // Size + setSize(xmlElement.getAttributeInteger("Size") / 8); + + // Min / Max + if (_bSigned) { + if (xmlElement.hasAttribute("Min")) { + + _uiMin = (uint32_t)xmlElement.getAttributeSignedInteger("Min"); + } else { + + _uiMin = 1UL << 31; + } + if (xmlElement.hasAttribute("Max")) { + + _uiMax = (uint32_t)xmlElement.getAttributeSignedInteger("Max"); + } else { + + _uiMax = (1UL << 31) - 1; + } + } else { + if (xmlElement.hasAttribute("Min")) { + + _uiMin = xmlElement.getAttributeInteger("Min"); + } else { + + _uiMin = 0; + } + if (xmlElement.hasAttribute("Max")) { + + _uiMax = xmlElement.getAttributeInteger("Max"); + } else { + + _uiMax = (uint32_t)-1; + } + } + + // Base + return base::fromXml(xmlElement, serializingContext); +} + +bool CIntegerParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const +{ + uiValue = strtoul(strValue.c_str(), NULL, 0); + + // Check against Min / Max + if (_bSigned) { + + if (!checkValueAgainstRange<int32_t>(uiValue, parameterAccessContext)) { + + return false; + } + } else { + + if (!checkValueAgainstRange<uint32_t>(uiValue, parameterAccessContext)) { + + return false; + } + } + + return true; +} + +void CIntegerParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const +{ + (void)parameterAccessContext; + + // Format + ostringstream strStream; + + if (_bSigned) { + // Sign extend + uint32_t uiShift = (4 - getSize()) << 3; + + int32_t iValue = (int32_t)uiValue; + + if (uiShift) { + + iValue = (iValue << uiShift) >> uiShift; + } + + strStream << iValue; + } else { + + strStream << uiValue; + } + + strValue = strStream.str(); +} + +// Default value handling (simulation only) +uint32_t CIntegerParameterType::getDefaultValue() const +{ + return _uiMin; +} + +// Range checking +template <class type> bool CIntegerParameterType::checkValueAgainstRange(type value, CParameterAccessContext& parameterAccessContext) const +{ + if ((type)value < (type)_uiMin || (type)value > (type)_uiMax) { + ostringstream strStream; + + strStream << "Value " << value << " standing out of admitted range: [" << (type)_uiMin << ", " << (type)_uiMax << "] for " << getKind(); + + parameterAccessContext.setError(strStream.str()); + + return false; + } + return true; +} diff --git a/parameter/IntegerParameterType.h b/parameter/IntegerParameterType.h new file mode 100644 index 0000000..f1b3e64 --- /dev/null +++ b/parameter/IntegerParameterType.h @@ -0,0 +1,61 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterType.h" + +class CIntegerParameterType : public CParameterType +{ +public: + CIntegerParameterType(const string& strName); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Conversion + virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; + virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const; + + // Default value handling (simulation only) + virtual uint32_t getDefaultValue() const; + + // CElement + virtual string getKind() const; +private: + // Range checking + template <class type> bool checkValueAgainstRange(type value, CParameterAccessContext& parameterAccessContext) const; + + // Signing + bool _bSigned; + // Range + uint32_t _uiMin; + uint32_t _uiMax; +}; diff --git a/parameter/KindElement.cpp b/parameter/KindElement.cpp new file mode 100644 index 0000000..3a538f5 --- /dev/null +++ b/parameter/KindElement.cpp @@ -0,0 +1,42 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "KindElement.h" + +#define base CElement + +CKindElement::CKindElement(const string& strName, const string& strKind) : base(strName), _strKind(strKind) +{ +} + +string CKindElement::getKind() const +{ + return _strKind; +} diff --git a/parameter/KindElement.h b/parameter/KindElement.h new file mode 100644 index 0000000..3f1e75f --- /dev/null +++ b/parameter/KindElement.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CKindElement : public CElement +{ +public: + CKindElement(const string& strName, const string& strKind); + + virtual string getKind() const; +private: + + string _strKind; +}; diff --git a/parameter/KindElementBuilderTemplate.h b/parameter/KindElementBuilderTemplate.h new file mode 100644 index 0000000..3f6677b --- /dev/null +++ b/parameter/KindElementBuilderTemplate.h @@ -0,0 +1,45 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ElementBuilder.h" + +template <class ElementType> +class CKindElementBuilderTemplate : public CElementBuilder +{ +public: + CKindElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + + virtual CElement* createElement(const CXmlElement& xmlElement) const + { + return new ElementType(xmlElement.getNameAttribute(), xmlElement.getType()); + } +}; diff --git a/parameter/Mapper.h b/parameter/Mapper.h new file mode 100644 index 0000000..4f32ca8 --- /dev/null +++ b/parameter/Mapper.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <string> + +using namespace std; + +class CInstanceConfigurableElement; + +class IMapper +{ +public: + virtual bool mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, string& strError) = 0; + virtual void mapEnd() = 0; +}; diff --git a/parameter/MappingContext.cpp b/parameter/MappingContext.cpp new file mode 100644 index 0000000..2f36c97 --- /dev/null +++ b/parameter/MappingContext.cpp @@ -0,0 +1,100 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "MappingContext.h" +#include <string.h> +#include <stdlib.h> + +CMappingContext::CMappingContext(uint32_t uiNbItems) : _pstItemArray(new CMappingContext::SItem[uiNbItems]), _uiNbItems(uiNbItems) +{ + // Clear items + memset(_pstItemArray, 0, sizeof(*_pstItemArray) * uiNbItems); +} + +CMappingContext::~CMappingContext() +{ + delete [] _pstItemArray; +} + +// Copy constructor +CMappingContext::CMappingContext(const CMappingContext& from) : _pstItemArray(new CMappingContext::SItem[from._uiNbItems]), _uiNbItems(from._uiNbItems) +{ + // Copy content items + memcpy(_pstItemArray, from._pstItemArray, sizeof(*_pstItemArray) * _uiNbItems); +} + +// Affectation +const CMappingContext& CMappingContext::operator=(const CMappingContext& right) +{ + if (&right != this) { + + // Size + _uiNbItems = right._uiNbItems; + + // Content + // Delete previous array + delete [] _pstItemArray; + + // Reallocate it + _pstItemArray = new CMappingContext::SItem[_uiNbItems]; + + // Copy content items + memcpy(_pstItemArray, right._pstItemArray, sizeof(*_pstItemArray) * _uiNbItems); + } + return *this; +} + +// Item access +bool CMappingContext::setItem(uint32_t uiItemType, const string& strItem) +{ + // Do some checks + if (_pstItemArray[uiItemType].bSet) { + + // Already set! + return false; + } + // Get item value + _pstItemArray[uiItemType].uiItem = strtoul(strItem.c_str(), NULL, 0); + + // Now is set + _pstItemArray[uiItemType].bSet = true; + + return true; +} + +uint32_t CMappingContext::getItem(uint32_t uiItemType) const +{ + return _pstItemArray[uiItemType].uiItem; +} + +bool CMappingContext::iSet(uint32_t uiItemType) const +{ + return _pstItemArray[uiItemType].bSet; +} diff --git a/parameter/MappingContext.h b/parameter/MappingContext.h new file mode 100644 index 0000000..aca9349 --- /dev/null +++ b/parameter/MappingContext.h @@ -0,0 +1,67 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> +#include <string> + +using namespace std; + +class CMappingContext +{ + // Item structure + struct SItem { + uint32_t uiItem; + bool bSet; + }; + +public: + // Regular Constructor + CMappingContext(uint32_t uiNbItems); + ~CMappingContext(); + + // Copy constructor + CMappingContext(const CMappingContext& from); + + // Affectation + const CMappingContext& operator=(const CMappingContext& right); + + // Item access + bool setItem(uint32_t uiItemType, const string& strItem); + uint32_t getItem(uint32_t uiItemType) const; + bool iSet(uint32_t uiItemType) const; +private: + // Item array + SItem* _pstItemArray; + // Items array size + uint32_t _uiNbItems; +}; + diff --git a/parameter/MappingData.cpp b/parameter/MappingData.cpp new file mode 100644 index 0000000..7975eb8 --- /dev/null +++ b/parameter/MappingData.cpp @@ -0,0 +1,89 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "MappingData.h" +#include "Tokenizer.h" +#include <assert.h> + +CMappingData::CMappingData() +{ +} + +bool CMappingData::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + assert(xmlElement.hasAttribute("Mapping")); + + string strMapping = xmlElement.getAttributeString("Mapping"); + + Tokenizer mappingTok(strMapping, ", "); + + string strMappingElement; + + while (!(strMappingElement = mappingTok.next()).empty()) { + + Tokenizer keyValueTok(strMappingElement, ":"); + + string strKey = keyValueTok.next(); + string strValue = keyValueTok.next(); + + if (!addValue(strKey, strValue)) { + + serializingContext.setError("Duplicate Mapping data: Unable to process Mapping element key = " + strKey + ", value = " + strValue + " from XML element " + xmlElement.getPath()); + + return false; + } + } + return true; +} + +bool CMappingData::getValue(const string& strkey, string& strValue) const +{ + KeyToValueMapConstIterator it = _keyToValueMap.find(strkey); + + if (it != _keyToValueMap.end()) { + + strValue = it->second; + + return true; + } + return false; +} + +bool CMappingData::addValue(const string& strkey, const string& strValue) +{ + if (_keyToValueMap.find(strkey) != _keyToValueMap.end()) { + + return false; + } + _keyToValueMap[strkey] = strValue; + + return true; +} + diff --git a/parameter/MappingData.h b/parameter/MappingData.h new file mode 100644 index 0000000..99be431 --- /dev/null +++ b/parameter/MappingData.h @@ -0,0 +1,55 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "XmlSink.h" +#include <string> +#include <map> + +using namespace std; + +class CMappingData : public IXmlSink +{ + typedef map<string, string>::const_iterator KeyToValueMapConstIterator; +public: + CMappingData(); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Query + bool getValue(const string& strkey, string& strValue) const; + +private: + bool addValue(const string& strkey, const string& strValue); + + map<string, string> _keyToValueMap; +}; diff --git a/parameter/NamedElementBuilderTemplate.h b/parameter/NamedElementBuilderTemplate.h new file mode 100644 index 0000000..82bf2e1 --- /dev/null +++ b/parameter/NamedElementBuilderTemplate.h @@ -0,0 +1,45 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ElementBuilder.h" + +template <class ElementType> +class CNamedElementBuilderTemplate : public CElementBuilder +{ +public: + CNamedElementBuilderTemplate(const string& strType) : CElementBuilder(strType) {} + + virtual CElement* createElement(const CXmlElement& xmlElement) const + { + return new ElementType(xmlElement.getNameAttribute()); + } +}; diff --git a/parameter/Parameter.cpp b/parameter/Parameter.cpp new file mode 100644 index 0000000..5f1f389 --- /dev/null +++ b/parameter/Parameter.cpp @@ -0,0 +1,213 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "Parameter.h" +#include "ParameterType.h" +#include "ParameterAccessContext.h" +#include "ConfigurationAccessContext.h" +#include "ParameterBlackboard.h" + +#define base CInstanceConfigurableElement + +CParameter::CParameter(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement) +{ +} + +CParameter::~CParameter() +{ +} + +CInstanceConfigurableElement::Type CParameter::getType() const +{ + return EParameter; +} + +// XML configuration settings parsing/composing +bool CParameter::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Check for value space + handleValueSpaceAttribute(xmlConfigurableElementSettingsElement, configurationAccessContext); + + // Handle access + if (!configurationAccessContext.serializeOut()) { + + // Write to blackboard + if (!doSetValue(xmlConfigurableElementSettingsElement.getTextContent(), getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext)) { + + // Append parameter path to error + configurationAccessContext.appendToError(" " + getPath()); + + return false; + } + } else { + + // Get string value + string strValue; + + doGetValue(strValue, getOffset() - configurationAccessContext.getBaseOffset(), configurationAccessContext); + + // Populate value into xml text node + xmlConfigurableElementSettingsElement.setTextContent(strValue); + } + + // Done + return true; +} + +// Value space handling for configuration import +void CParameter::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Delegate to type + static_cast<const CParameterType*>(getTypeElement())->handleValueSpaceAttribute(xmlConfigurableElementSettingsElement, configurationAccessContext); +} + +uint32_t CParameter::getFootPrint() const +{ + return getSize(); +} + +uint32_t CParameter::getSize() const +{ + return static_cast<const CParameterType*>(getTypeElement())->getSize(); +} + +// Dump +void CParameter::logValue(string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Dump value + doGetValue(strValue, getOffset(), parameterContext); + + // Prepend unit if any + prependUnit(strValue); +} + +// Used for simulation only +void CParameter::setDefaultValues(CParameterAccessContext& parameterAccessContext) const +{ + // Get default value from type + uint32_t uiDefaultValue = static_cast<const CParameterType*>(getTypeElement())->getDefaultValue(); + + // Write blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->write(&uiDefaultValue, getSize(), getOffset(), parameterAccessContext.isBigEndianSubsystem()); +} + +// Unit +void CParameter::prependUnit(string& strValue) const +{ + string strUnit = static_cast<const CParameterType*>(getTypeElement())->getUnit(); + + if (!strUnit.empty()) { + + strValue = "(" + strUnit + ") " + strValue; + } +} + +// Parameter Access +bool CParameter::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const +{ + // Check path validity + if (!checkPathExhausted(pathNavigator, errorContext)) { + + return false; + } + // Parameter context + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Set Value + if (!doSetValue(strValue, getOffset(), parameterContext)) { + + // Append parameter path to error + parameterContext.appendToError(" " + getPath()); + + return false; + } + // Synchronize + if (parameterContext.getAutoSync() && !sync(parameterContext)) { + + // Append parameter path to error + parameterContext.appendToError(" " + getPath()); + + return false; + } + return true; +} + +bool CParameter::getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const +{ + // Check path validity + if (!checkPathExhausted(pathNavigator, errorContext)) { + + return false; + } + // Parameter context + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Get Value + doGetValue(strValue, getOffset(), parameterContext); + + return true; +} + +bool CParameter::doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const +{ + uint32_t uiData; + + if (!static_cast<const CParameterType*>(getTypeElement())->asInteger(strValue, uiData, parameterAccessContext)) { + + return false; + } + + // Write blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->write(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); + + return true; +} + +void CParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const +{ + uint32_t uiData = 0; + + // Read blackboard + CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); + + // Beware this code works on little endian architectures only! + pBlackboard->read(&uiData, getSize(), uiOffset, parameterAccessContext.isBigEndianSubsystem()); + + static_cast<const CParameterType*>(getTypeElement())->asString(uiData, strValue, parameterAccessContext); +} + diff --git a/parameter/Parameter.h b/parameter/Parameter.h new file mode 100644 index 0000000..dcb535f --- /dev/null +++ b/parameter/Parameter.h @@ -0,0 +1,74 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> + +#include "InstanceConfigurableElement.h" + +class CParameterAccessContext; +class CConfigurationAccessContext; + +class CParameter : public CInstanceConfigurableElement +{ +public: + CParameter(const string& strName, const CTypeElement* pTypeElement); + virtual ~CParameter(); + + // Instantiation, allocation + virtual uint32_t getFootPrint() const; + + // Type + virtual Type getType() const; + + // XML configuration settings parsing/composing + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; +protected: + // Parameter Access + virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; + virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; + virtual void logValue(string& strValue, CErrorContext& errorContext) const; + // Used for simulation only + virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; + + // To be implemented by derived + virtual bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + virtual void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const; + + // Value space handling for configuration import + void handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + + // Size + uint32_t getSize() const; + + // Unit + void prependUnit(string& strValue) const; +}; diff --git a/parameter/ParameterAccessContext.cpp b/parameter/ParameterAccessContext.cpp new file mode 100644 index 0000000..1508d73 --- /dev/null +++ b/parameter/ParameterAccessContext.cpp @@ -0,0 +1,87 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterAccessContext.h" + +#define base CErrorContext + +CParameterAccessContext::CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw) : + base(strError), _pParameterBlackboard(pParameterBlackboard), _bValueSpaceIsRaw(bValueSpaceIsRaw), _bBigEndianSubsystem(false), _bAutoSync(true) +{ +} + +CParameterAccessContext::CParameterAccessContext(string& strError) : + base(strError), _pParameterBlackboard(NULL), _bValueSpaceIsRaw(false), _bBigEndianSubsystem(false), _bAutoSync(true) +{ +} + +// ParameterBlackboard +CParameterBlackboard* CParameterAccessContext::getParameterBlackboard() +{ + return _pParameterBlackboard; +} + +void CParameterAccessContext::setParameterBlackboard(CParameterBlackboard* pBlackboard) +{ + _pParameterBlackboard = pBlackboard; +} + +// Value Space +void CParameterAccessContext::setValueSpaceRaw(bool bIsRaw) +{ + _bValueSpaceIsRaw = bIsRaw; +} + +bool CParameterAccessContext::valueSpaceIsRaw() const +{ + return _bValueSpaceIsRaw; +} + +// Endianness +void CParameterAccessContext::setBigEndianSubsystem(bool bBigEndian) +{ + _bBigEndianSubsystem = bBigEndian; +} + +bool CParameterAccessContext::isBigEndianSubsystem() const +{ + return _bBigEndianSubsystem; +} + +// Automatic synchronization to HW +void CParameterAccessContext::setAutoSync(bool bAutoSync) +{ + _bAutoSync = bAutoSync; +} + +bool CParameterAccessContext::getAutoSync() const +{ + return _bAutoSync; +} diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h new file mode 100644 index 0000000..dbeb730 --- /dev/null +++ b/parameter/ParameterAccessContext.h @@ -0,0 +1,69 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ErrorContext.h" + +class CParameterBlackboard; + +class CParameterAccessContext : public CErrorContext +{ +public: + CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw); + CParameterAccessContext(string& strError); + + // ParameterBlackboard + CParameterBlackboard* getParameterBlackboard(); + void setParameterBlackboard(CParameterBlackboard* pBlackboard); + + // Value interpretation as Real or Raw (usefull for Fixed point parameters) + void setValueSpaceRaw(bool bIsRaw); + bool valueSpaceIsRaw() const; + + // Endianness + void setBigEndianSubsystem(bool bBigEndian); + bool isBigEndianSubsystem() const; + + // Automatic synchronization to HW + void setAutoSync(bool bAutoSync); + bool getAutoSync() const; + +private: + // Blackboard + CParameterBlackboard* _pParameterBlackboard; + // Value space + bool _bValueSpaceIsRaw; + // Subsystem Endianness + bool _bBigEndianSubsystem; + // Automatic synchronization to HW + bool _bAutoSync; +}; + diff --git a/parameter/ParameterBlackboard.cpp b/parameter/ParameterBlackboard.cpp new file mode 100644 index 0000000..ecf4476 --- /dev/null +++ b/parameter/ParameterBlackboard.cpp @@ -0,0 +1,139 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterBlackboard.h" +#include <string.h> +#include <assert.h> + +CParameterBlackboard::CParameterBlackboard() : _puiData(NULL), _uiSize(0) +{ +} + +CParameterBlackboard::~CParameterBlackboard() +{ + delete [] _puiData; +} + +// Size +void CParameterBlackboard::setSize(uint32_t uiSize) +{ + if (_puiData) { + + delete [] _puiData; + } + + _puiData = new uint8_t[uiSize]; + + memset(_puiData, 0, uiSize); + + _uiSize = uiSize; +} + +uint32_t CParameterBlackboard::getSize() const +{ + return _uiSize; +} + +// Single parameter access +void CParameterBlackboard::write(const void* pvSrcData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian) +{ + assert(uiSize + uiOffset <= _uiSize); + + if (!bBigEndian) { + + memcpy(_puiData + uiOffset, pvSrcData, uiSize); + } else { + + uint32_t uiIndex; + const uint8_t* puiSrcData = (const uint8_t*)pvSrcData; + + for (uiIndex = 0; uiIndex < uiSize; uiIndex++) { + + _puiData[uiIndex + uiOffset] = puiSrcData[uiSize - uiIndex - 1]; + } + } +} + +void CParameterBlackboard::read(void* pvDstData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian) const +{ + assert(uiSize + uiOffset <= _uiSize); + + if (!bBigEndian) { + + memcpy(pvDstData, _puiData + uiOffset, uiSize); + } else { + + uint32_t uiIndex; + uint8_t* puiDstData = (uint8_t*)pvDstData; + + for (uiIndex = 0; uiIndex < uiSize; uiIndex++) { + + puiDstData[uiSize - uiIndex - 1] = _puiData[uiIndex + uiOffset]; + } + } +} + +// Access from/to subsystems +void CParameterBlackboard::rawRead(void* pvDstData, uint32_t uiSize, uint32_t uiOffset) const +{ + assert(uiSize + uiOffset <= _uiSize); + + memcpy(pvDstData, _puiData + uiOffset, uiSize); +} + +void CParameterBlackboard::rawWrite(const void* pvDstData, uint32_t uiSize, uint32_t uiOffset) +{ + assert(uiSize + uiOffset <= _uiSize); + + memcpy(_puiData + uiOffset, pvDstData, uiSize); +} + +// Configuration handling +void CParameterBlackboard::restoreFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset) +{ + memcpy(_puiData + uiOffset, pFromBlackboard->_puiData, pFromBlackboard->_uiSize); +} + +void CParameterBlackboard::saveTo(CParameterBlackboard* pToBlackboard, uint32_t uiOffset) const +{ + memcpy(pToBlackboard->_puiData, _puiData + uiOffset, pToBlackboard->_uiSize); +} + +// Serialization +void CParameterBlackboard::serialize(CBinaryStream& binaryStream) +{ + if (binaryStream.isOut()) { + + binaryStream.write(_puiData, _uiSize); + } else { + + binaryStream.read(_puiData, _uiSize); + } +} diff --git a/parameter/ParameterBlackboard.h b/parameter/ParameterBlackboard.h new file mode 100644 index 0000000..5812d0b --- /dev/null +++ b/parameter/ParameterBlackboard.h @@ -0,0 +1,66 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> +#include "BinaryStream.h" + +using namespace std; + +class CParameterBlackboard +{ +public: + CParameterBlackboard(); + ~CParameterBlackboard(); + + // Size + void setSize(uint32_t uiSize); + uint32_t getSize() const; + + // Single parameter access + void write(const void* pvSrcData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian); + void read(void* pvDstData, uint32_t uiSize, uint32_t uiOffset, bool bBigEndian) const; + + // Access from/to subsystems + void rawRead(void* pvDstData, uint32_t uiSize, uint32_t uiOffset) const; + void rawWrite(const void* pvDstData, uint32_t uiSize, uint32_t uiOffset); + + // Configuration handling + void restoreFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset); + void saveTo(CParameterBlackboard* pToBlackboard, uint32_t uiOffset) const; + + // Serialization + void serialize(CBinaryStream& binaryStream); +private: + uint8_t* _puiData; + uint32_t _uiSize; +}; + diff --git a/parameter/ParameterBlock.cpp b/parameter/ParameterBlock.cpp new file mode 100644 index 0000000..7b1bc64 --- /dev/null +++ b/parameter/ParameterBlock.cpp @@ -0,0 +1,42 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterBlock.h" + +#define base CInstanceConfigurableElement + +CParameterBlock::CParameterBlock(const string& strName, const CTypeElement* pTypeElement) : base(strName, pTypeElement) +{ +} + +CInstanceConfigurableElement::Type CParameterBlock::getType() const +{ + return EParameterBlock; +} diff --git a/parameter/ParameterBlock.h b/parameter/ParameterBlock.h new file mode 100644 index 0000000..f2a8000 --- /dev/null +++ b/parameter/ParameterBlock.h @@ -0,0 +1,43 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "InstanceConfigurableElement.h" + +class CParameterBlock : public CInstanceConfigurableElement +{ +public: + CParameterBlock(const string& strName, const CTypeElement* pTypeElement); + + // Type + virtual Type getType() const; +}; + diff --git a/parameter/ParameterBlockType.cpp b/parameter/ParameterBlockType.cpp new file mode 100644 index 0000000..57cd3c0 --- /dev/null +++ b/parameter/ParameterBlockType.cpp @@ -0,0 +1,86 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterBlockType.h" +#include "ParameterBlock.h" +#include <sstream> + +#define base CTypeElement + +CParameterBlockType::CParameterBlockType(const string& strName) : base(strName) +{ +} + +string CParameterBlockType::getKind() const +{ + return "ParameterBlock"; +} + +bool CParameterBlockType::childrenAreDynamic() const +{ + return true; +} + +CInstanceConfigurableElement* CParameterBlockType::doInstantiate() const +{ + return new CParameterBlock(getName(), this); +} + +void CParameterBlockType::populate(CElement* pElement) const +{ + uint32_t uiArrayLength = getArrayLength(); + + if (uiArrayLength) { + + // Create child elements + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiArrayLength; uiChild++) { + + CParameterBlock* pChildParameterBlock = new CParameterBlock(computeChildName(uiChild), this); + + pElement->addChild(pChildParameterBlock); + + base::populate(pChildParameterBlock); + } + } else { + // Regular block + base::populate(pElement); + } +} + +string CParameterBlockType::computeChildName(uint32_t uiChild) +{ + ostringstream strStream; + + strStream << uiChild; + + return strStream.str(); +} diff --git a/parameter/ParameterBlockType.h b/parameter/ParameterBlockType.h new file mode 100644 index 0000000..b3577d8 --- /dev/null +++ b/parameter/ParameterBlockType.h @@ -0,0 +1,51 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "TypeElement.h" + +class CParameterBlockType : public CTypeElement +{ +public: + CParameterBlockType(const string& strName); + + // CElement + virtual string getKind() const; +private: + virtual bool childrenAreDynamic() const; + // Instantiation + virtual CInstanceConfigurableElement* doInstantiate() const; + // Population + virtual void populate(CElement* pElement) const; + // Creating sub blocks with indexes + static string computeChildName(uint32_t uiChild); +}; + diff --git a/parameter/ParameterFrameworkConfiguration.cpp b/parameter/ParameterFrameworkConfiguration.cpp new file mode 100644 index 0000000..388e375 --- /dev/null +++ b/parameter/ParameterFrameworkConfiguration.cpp @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterFrameworkConfiguration.h" + +#define base CElement + +CParameterFrameworkConfiguration::CParameterFrameworkConfiguration() +{ +} + +string CParameterFrameworkConfiguration::getKind() const +{ + return "ParameterFrameworkConfiguration"; +} + +bool CParameterFrameworkConfiguration::childrenAreDynamic() const +{ + return true; +} diff --git a/parameter/ParameterFrameworkConfiguration.h b/parameter/ParameterFrameworkConfiguration.h new file mode 100644 index 0000000..e0891e3 --- /dev/null +++ b/parameter/ParameterFrameworkConfiguration.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CParameterFrameworkConfiguration : public CElement +{ +public: + CParameterFrameworkConfiguration(); + + virtual string getKind() const; + +private: + virtual bool childrenAreDynamic() const; +}; diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp new file mode 100644 index 0000000..b9e9f30 --- /dev/null +++ b/parameter/ParameterMgr.cpp @@ -0,0 +1,1740 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterMgr.h" +#include "XmlParser.h" +#include "XmlParameterSerializingContext.h" +#include "XmlElementSerializingContext.h" +#include "SystemClass.h" +#include "ElementLibrarySet.h" +#include "SubsystemLibrary.h" +#include "NamedElementBuilderTemplate.h" +#include "KindElementBuilderTemplate.h" +#include "ElementBuilderTemplate.h" +#include "SelectionCriterionType.h" +#include "SelectionCriterionDefinition.h" +#include "SubsystemElementBuilder.h" +#include "SelectionCriteria.h" +#include "ComponentType.h" +#include "ComponentInstance.h" +#include "ParameterBlockType.h" +#include "BooleanParameterType.h" +#include "IntegerParameterType.h" +#include "FixedPointParameterType.h" +#include "ParameterBlackboard.h" +#include "Parameter.h" +#include "ComputedSizeParameterType.h" +#include "ParameterBlackboard.h" +#include "ParameterAccessContext.h" +#include "XmlFileIncluderElement.h" +#include "ParameterFrameworkConfiguration.h" +#include "FrameworkConfigurationGroup.h" +#include "FrameworkConfigurationLocation.h" +#include "SystemClassConfiguration.h" +#include "ConfigurableDomains.h" +#include "ConfigurableDomain.h" +#include "DomainConfiguration.h" +#include "XmlComposer.h" +#include "XmlDomainSerializingContext.h" +#include "BitParameterBlockType.h" +#include "BitParameterType.h" +#include "RemoteProcessorServerInterface.h" +#include "ElementLocator.h" +#include "AutoLog.h" +#include "CompoundRule.h" +#include "SelectionCriterionRule.h" +#include "SimulatedBackSynchronizer.h" +#include "HardwareBackSynchronizer.h" +#include <strings.h> +#include <dlfcn.h> +#include <assert.h> +#include <sstream> + +#define base CElement + +// Used for remote processor server creation +typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler); + +// Global configuration file name (fixed) +const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml"; +const char* gacSystemSchemasSubFolder = "Schemas"; + +// Config File System looks normally like this: +// --------------------------------------------- +//├── ParameterFrameworkConfiguration.xml +//├── Schemas +//│ └── *.xsd +//├── Settings +//│ └── <SystemClassName folder>* +//│ ├── <ConfigurableDomains>.xml +//│ └── <Settings>.bin? +//└── Structure +// └── <SystemClassName folder>* +// ├── <SystemClassName>Class.xml +// └── <Subsystem>.xml* +// -------------------------------------------- + + +// Remote command parser array +const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gaRemoteCommandParserItems[] = { + /// Help + { "help", &CParameterMgr::helpCommandProcess, 0, "", "Show commands description and usage" }, + /// Status + { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" }, + /// Tuning Mode + { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" }, + { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" }, + /// Value Space + { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for fixed point integer value interpretation" }, + { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" }, + /// Sync + { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" }, + { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" }, + { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" }, + /// Domains + { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" }, + { "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" }, + { "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" }, + { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" }, + /// Configurations + { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" }, + { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" }, + { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" }, + { "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" }, + /// Elements/Parameters + { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" }, + { "listElementsRecursive", &CParameterMgr::listElementsRecursiveCommmandProcess, 1, "<elem path>|/", "Recursively list elements under element at given path or root" }, + { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" }, + { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" }, + { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<elem ath>", "Get value for parameter at given path" }, + { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<elem path> <value>", "Set value for parameter at given path" }, + { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is contained in" }, + { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" }, + /// Browse + { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" }, + { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" }, + { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" }, + /// Settings Import/Export + { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" }, + { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" }, + { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" }, + { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" }, + { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" }, + { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" } +}; +// Remote command parsers array Size +const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gaRemoteCommandParserItems) / sizeof(gaRemoteCommandParserItems[0]); + +CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) : + _bTuningModeIsOn(false), + _bValueSpaceIsRaw(false), + _bAutoSyncOn(true), + _pMainParameterBlackboard(new CParameterBlackboard), + _pElementLibrarySet(new CElementLibrarySet), + _strParameterFrameworkConfigurationFolderPath(strParameterFrameworkConfigurationFolderPath), + _strSchemaFolderLocation(strParameterFrameworkConfigurationFolderPath + "/" + gacSystemSchemasSubFolder), + _pSystemClassConfiguration(NULL), + _uiStructureChecksum(0), + _pRemoteProcessorServer(NULL), + _uiMaxCommandUsageLength(0), + _pLogger(NULL), + _uiLogDepth(0) +{ + // Tuning Mode Mutex + bzero(&_tuningModeMutex, sizeof(_tuningModeMutex)); + pthread_mutex_init(&_tuningModeMutex, NULL); + + // Deal with children + addChild(new CParameterFrameworkConfiguration); + addChild(new CSelectionCriteria); + addChild(new CSystemClass(strSystemClassName)); + addChild(new CConfigurableDomains(strSystemClassName)); + + // Feed element library + feedElementLibraries(); +} + +CParameterMgr::~CParameterMgr() +{ + // Children + delete _pRemoteProcessorServer; + delete _pMainParameterBlackboard; + delete _pElementLibrarySet; + + // Tuning Mode Mutex + pthread_mutex_destroy(&_tuningModeMutex); +} + +string CParameterMgr::getKind() const +{ + return "ParameterMgr"; +} + +// Logging +void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger) +{ + _pLogger = pLogger; +} + +// Logging +void CParameterMgr::doLog(const string& strLog) const +{ + if (_pLogger) { + + // Nest + string strIndent; + + // Level + uint32_t uiNbIndents = _uiLogDepth; + + while (uiNbIndents--) { + + strIndent += " "; + } + + // Log + _pLogger->log(strIndent + strLog); + } +} + +void CParameterMgr::nestLog() const +{ + ((uint32_t&)_uiLogDepth)++; +} + +void CParameterMgr::unnestLog() const +{ + ((uint32_t&)_uiLogDepth)--; +} + +bool CParameterMgr::load(string& strError) +{ + CAutoLog autoLog(this, "Loading"); + + // Load Framework configuration + if (!loadFrameworkConfiguration(strError)) { + + return false; + } + + // Load subsystems + if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) { + + return false; + } + + // Load structure + if (!loadStructure(strError)) { + + return false; + } + + // Load settings + if (!loadSettings(strError)) { + + return false; + } + + // All is loaded, we're ready to observe selection criteria events + getSelectionCriteria()->setObserver(this); + + // Load and start Remote processor server if appropriate + if (!handleRemoteProcessingInterface(strError)) { + + return false; + } + + return true; +} + +bool CParameterMgr::loadFrameworkConfiguration(string& strError) +{ + CAutoLog autoLog(this, "Loading framework configuration"); + + // Get Xml config file name + string strXmlConfigurationFilePath = _strParameterFrameworkConfigurationFolderPath + "/" + gacParameterFrameworkConfigurationFileName; + + // Parse Structure XML file + CXmlElementSerializingContext elementSerializingContext(strError); + + if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), strXmlConfigurationFilePath, _strParameterFrameworkConfigurationFolderPath, EFrameworkConfigurationLibrary)) { + + return false; + } + // Get subsystem plugins folders element + const CFrameworkConfigurationGroup* pSubsystemPluginFolders= static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders")); + + if (!pSubsystemPluginFolders) { + + strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element"; + + return false; + } + // Get plugin locations + uint32_t uiPluginFolderLocation; + uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren(); + + if (!uiNbPluginFolderLocations) { + + strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element"; + + return false; + } + + for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) { + + const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation)); + + _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath)); + } + + // Get configuration for current system class + const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("ParameterConfiguration")); + + if (!pParameterConfigurationGroup) { + + strError = "Parameter Framework Configuration: couldn't find ParameterConfiguration element"; + + return false; + } + _pSystemClassConfiguration = static_cast<const CSystemClassConfiguration*>(pParameterConfigurationGroup->findChild(getSystemClass()->getName())); + + if (!_pSystemClassConfiguration) { + + strError = "No framework configuration found for SystemClass " + getSystemClass()->getName(); + + return false; + } + // Log tuning availability + log("Tuning %s", _pSystemClassConfiguration->isTuningAllowed() ? "allowed" : "prohibited"); + + return true; +} + +bool CParameterMgr::loadStructure(string& strError) +{ + // Retrieve system to load structure to + CSystemClass* pSystemClass = getSystemClass(); + + CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure"); + + // Get structure description element + const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(_pSystemClassConfiguration->findChildOfKind("StructureDescriptionFileLocation")); + + if (!pStructureDescriptionFileLocation) { + + strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName(); + + return false; + } + + // Get Xml structure folder + string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath); + + // Get Xml structure file name + string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); + + // Parse Structure XML file + CXmlParameterSerializingContext parameterBuildContext(strError); + + if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { + + return false; + } + + // Initialize offsets + pSystemClass->setOffset(0); + + // Initialize main blackboard's size + _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint()); + + return true; +} + +bool CParameterMgr::loadSettings(string& strError) +{ + CAutoLog autoLog(this, "Loading settings"); + + // Get settings configuration element + const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(_pSystemClassConfiguration->findChildOfKind("SettingsConfiguration")); + + if (!pParameterConfigurationGroup) { + + // No settings to load + + return true; + } + // Get binary settings file location + const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation")); + + string strXmlBinarySettingsFilePath; + + if (pBinarySettingsFileLocation) { + + // Get Xml binary settings file name + strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); + } + + // Get configurable domains element + const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation")); + + if (!pConfigurableDomainsFileLocation) { + + strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); + + return false; + } + // Get destination root element + CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); + + // Get Xml configuration domains file name + string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); + + // Get Xml configuration domains folder + string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath); + + // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary) + CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation); + + // Selection criteria definition for rule creation + xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + + // Do parse + if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { + + return false; + } + // We have loaded the whole system structure, compute checksum + const CSystemClass* pSystemClass = getConstSystemClass(); + _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum(); + + // Load binary settings if any provided + if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { + + return false; + } + + // Back synchronization for areas in parameter blackboard no covered by any domain + CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError); + + log("Main blackboard back synchronization"); + + // Back-synchronize + if (!pBackSynchronizer->sync()) { + // Get rif of back synchronizer + delete pBackSynchronizer; + + strError = "Main blackboard back synchronization failed: " + strError; + + return false; + } + // Get rif of back synchronizer + delete pBackSynchronizer; + + // We're done loading the settings + // We need to ensure all domains are valid + pConfigurableDomains->validate(_pMainParameterBlackboard); + + // Ensure application of currently selected configurations + // Force-apply configuration(s) + return pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError); +} + +// XML parsing +bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName) +{ + // Init serializing context + elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation); + + // Get Schema file associated to root element + string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd"; + + // Parse Structure XML file + CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext); + + if (!parser.open()) { + + return false; + } + + // Check Root element name attribute (if any) + string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName); + + if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) { + + elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath); + elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName()); + + return false; + } + + // Start clean + pRootElement->clean(); + + // Parse + if (!parser.parse(pRootElement)) { + + // Cleanup + pRootElement->clean(); + + return false; + } + + // Close parser + if (!parser.close()) { + + return false; + } + + return true; +} + +// Init +bool CParameterMgr::init(string& strError) +{ + return base::init(strError); +} + +// Selection criteria interface +CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) +{ + // Propagate + return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive); +} + +CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) +{ + // Propagate + return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType); +} + +// Selection criteria changed event +void CParameterMgr::selectionCriterionChanged(const CSelectionCriterion* pSelectionCriterion) +{ + CAutoLog autoLog(this, pSelectionCriterion->getName() + " selection criterion changed event"); + + // Lock state + pthread_mutex_lock(&_tuningModeMutex); + + if (!_bTuningModeIsOn) { + + // Apply configuration(s) + string strError; + + if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) { + + log("Failed to apply configurations!"); + } + } + // Unlock state + pthread_mutex_unlock(&_tuningModeMutex); +} + +// 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 = &gaRemoteCommandParserItems[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 = &gaRemoteCommandParserItems[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 = &gaRemoteCommandParserItems[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; +} + +/// Status +CParameterMgr::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + // System class + const CSystemClass* pSystemClass = getSystemClass(); + + strResult = "\n"; + + // Show status + /// System class + strResult += "System Class: "; + strResult += pSystemClass->getName(); + strResult += "\n"; + + /// Tuning mode + strResult += "Tuning Mode: "; + strResult += tuningModeOn() ? "on" : "off"; + strResult += "\n"; + + /// Value space + strResult += "Value Space: "; + strResult += valueSpaceIsRaw() ? "raw" : "real"; + strResult += "\n"; + + /// Value space + strResult += "Auto Sync: "; + strResult += autoSyncOn() ? "on" : "off"; + strResult += "\n"; + + /// Subsystem list + strResult += "\nSubsystems:"; + string strSubsystemList; + pSystemClass->listChildrenPaths(strSubsystemList); + strResult += strSubsystemList; + + /// Last applied configurations + strResult += "\nLast applied configurations:"; + string strLastAppliedConfigurations; + getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); + strResult += strLastAppliedConfigurations; + + return ESucceeded; +} + +/// Tuning Mode +CParameterMgr::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + if (remoteCommand.getArgument(0) == "on") { + + if (setTuningMode(true, strResult)) { + + return EDone; + } + } else if (remoteCommand.getArgument(0) == "off") { + + if (setTuningMode(false, strResult)) { + + return EDone; + } + } else { + // Show usage + return EShowUsgae; + } + return EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + strResult = tuningModeOn() ? "on" : "off"; + + return ESucceeded; +} + +/// Value Space +CParameterMgr::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)strResult; + + if (remoteCommand.getArgument(0) == "raw") { + + setValueSpace(true); + + return EDone; + + } else if (remoteCommand.getArgument(0) == "real") { + + setValueSpace(false); + + return EDone; + + } else { + // Show usage + return EShowUsgae; + } + return EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + strResult = valueSpaceIsRaw() ? "raw" : "real"; + + return ESucceeded; +} + +/// Sync +CParameterMgr::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + if (remoteCommand.getArgument(0) == "on") { + + if (setAutoSync(true, strResult)) { + + return EDone; + } + } else if (remoteCommand.getArgument(0) == "off") { + + if (setAutoSync(false, strResult)) { + + return EDone; + } + } else { + // Show usage + return EShowUsgae; + } + return EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + strResult = autoSyncOn() ? "on" : "off"; + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + return sync(strResult) ? EDone : EFailed; +} + + +/// Domains +CParameterMgr::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + getConfigurableDomains()->listChildren(strResult); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return createDomain(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return deleteDomain(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? ESucceeded : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +/// Configurations +CParameterMgr::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? ESucceeded : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +/// Elements/Parameters +CParameterMgr::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass(), false); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + strResult = string("\n"); + + if (!pLocatedElement) { + + // List from root folder + + // Return system class qualified name + pLocatedElement = getSystemClass(); + } + + // Return sub-elements + strResult += pLocatedElement->listQualifiedPaths(false); + + return ESucceeded; +} + +/// Elements/Parameters +CParameterMgr::CommandStatus CParameterMgr::listElementsRecursiveCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass(), false); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + strResult = string("\n"); + + if (!pLocatedElement) { + + // List from root folder + + // Return system class qualified name + pLocatedElement = getSystemClass(); + } + + // Return sub-elements + strResult += pLocatedElement->listQualifiedPaths(true); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + string strError; + + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + + // Dump elements + pLocatedElement->dumpContent(strResult, parameterAccessContext); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + // Converted to actual sizable element + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Get size as string + ostringstream str; + + str << endl << pConfigurableElement->getFootPrint() << " bytes" << endl; + + strResult = str.str(); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + string strValue; + + if (!getValue(remoteCommand.getArgument(0), strValue, strResult)) { + + return EFailed; + } + // Succeeded + strResult = strValue; + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return setValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + // Convert element + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Return element belonging domains + pConfigurableElement->listBelongingDomains(strResult); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { + + return EFailed; + } + + // Convert element + const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Return element belonging domains + pConfigurableElement->listAssociatedDomains(strResult); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + getConfigurableDomains()->listAssociatedElements(strResult); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + getConfigurableDomains()->listConflictingElements(strResult); + + return ESucceeded; +} + +CParameterMgr::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + (void)remoteCommand; + + getSystemClass()->listRogueElements(strResult); + + return ESucceeded; +} + +/// Settings Import/Export +CParameterMgr::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; +} + +CParameterMgr::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? EDone : EFailed; +} + +// User set/get parameters +bool CParameterMgr::setValue(const string& strPath, const string& strValue, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + CPathNavigator pathNavigator(strPath); + + if (!pathNavigator.isPathValid()) { + + strError = "Path not well formed"; + + return false; + } + + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + strError = "Non settable element"; + + return false; + } + + if (*pStrChildName != getSystemClass()->getName()) { + + strError = "Path not found"; + + return false; + } + + // Define context + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + + // Set auto sync + parameterAccessContext.setAutoSync(_bAutoSyncOn); + + // Do the set + return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext); +} + +bool CParameterMgr::getValue(const string& strPath, string& strValue, string& strError) const +{ + CPathNavigator pathNavigator(strPath); + + if (!pathNavigator.isPathValid()) { + + strError = "Path not well formed"; + + return false; + } + + string* pStrChildName = pathNavigator.next(); + + if (!pStrChildName) { + + strError = "Non settable element"; + + return false; + } + + if (*pStrChildName != getConstSystemClass()->getName()) { + + strError = "Path not found"; + + return false; + } + + // Define context + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + + // Do the get + return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext); +} + +// Tuning mode +bool CParameterMgr::setTuningMode(bool bOn, string& strError) +{ + // Tuning allowed? + if (bOn && !_pSystemClassConfiguration->isTuningAllowed()) { + + strError = "Tuning prohibited"; + + return false; + } + // Lock state + pthread_mutex_lock(&_tuningModeMutex); + + // Warn domains about exiting tuning mode + if (!bOn && _bTuningModeIsOn) { + + // Ensure application of currently selected configurations + // Force-apply configuration(s) + if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) { + + return false; + } + // Turn auto sync back on + _bAutoSyncOn = true; + } + + // Store + _bTuningModeIsOn = bOn; + + // Unlock state + pthread_mutex_unlock(&_tuningModeMutex); + + return true; +} + +bool CParameterMgr::tuningModeOn() const +{ + return _bTuningModeIsOn; +} + +// Current value space for user set/get value interpretation +void CParameterMgr::setValueSpace(bool bIsRaw) +{ + _bValueSpaceIsRaw = bIsRaw; +} + +bool CParameterMgr::valueSpaceIsRaw() +{ + return _bValueSpaceIsRaw; +} + +/// Sync +// Automatic hardware synchronization control (during tuning session) +bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + // Warn domains about turning auto sync back on + if (bAutoSyncOn && !_bAutoSyncOn) { + + // Ensure application of currently selected configurations + // Force-apply configuration(s) + if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) { + + return false; + } + } + + // Set Auto sync + _bAutoSyncOn = bAutoSyncOn; + + return true; +} + +bool CParameterMgr::autoSyncOn() const +{ + return _bAutoSyncOn; +} + +// Manual hardware synchronization control (during tuning session) +bool CParameterMgr::sync(string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + // Warn domains about turning auto sync back on + if (_bAutoSyncOn) { + + strError = "Feature unavailable when Auto Sync is on"; + + return false; + } + + // Get syncer set + CSyncerSet syncerSet; + // ... from system class + getConstSystemClass()->fillSyncerSet(syncerSet); + // Sync + return syncerSet.sync(*_pMainParameterBlackboard, false, strError); +} + +// Content dump +void CParameterMgr::logStructureContent(string& strContent) const +{ + string strError; + + CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw); + + dumpContent(strContent, parameterAccessContext); +} + +// Configuration/Domains handling +bool CParameterMgr::createDomain(const string& strName, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->createDomain(strName, strError); +} + +bool CParameterMgr::deleteDomain(const string& strName, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->deleteDomain(strName, strError); +} + +bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); +} + +bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError); +} + +bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError); +} + +bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // Delegate to configurable domains + return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); +} + +// Configurable element - domain association +bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { + + return false; + } + + // Convert element + CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Delegate + return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError); +} + +bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { + + return EFailed; + } + + // Convert element + CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Delegate + return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError); +} + +bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + CElementLocator elementLocator(getSystemClass()); + + CElement* pLocatedElement = NULL; + + if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { + + return EFailed; + } + + // Convert element + CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); + + // Delegate + return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError); +} + +// XML Import/Export +bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + + // check path is absolute + if (strFileName[0] != '/') { + + strError = "Please provide absolute path"; + + return false; + } + // Root element + CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); + + // Context + CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); + + // Secltion criteria definition for rule creation + xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + + // Parse + if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) { + + return false; + } + + // Validate domains after XML import + pConfigurableDomains->validate(_pMainParameterBlackboard); + + return true; +} + +bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const +{ + // check path is absolute + if (strFileName[0] != '/') { + + strError = "Please provide absolute path"; + + return false; + } + + // Root element + const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); + + // Get Schema file associated to root element + string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd"; + + // Context + CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); + + // Value space + xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); + + // Instantiate composer + CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext); + + // Open composer + if (!xmlComposer.open()) { + + return false; + } + + // Compose + xmlComposer.compose(pConfigurableDomains); + + // Close composer + if (!xmlComposer.close()) { + + return false; + } + + return true; +} + +// Binary Import/Export +bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError) +{ + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + // check path is absolute + if (strFileName[0] != '/') { + + strError = "Please provide absolute path"; + + return false; + } + // Root element + CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); + + // Serialize in + return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError); +} + +bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError) +{ + // check path is absolute + if (strFileName[0] != '/') { + + strError = "Please provide absolute path"; + + return false; + } + // Check tuning mode + if (!checkTuningModeOn(strError)) { + + return false; + } + // Root element + CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); + + // Serialize out + return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError); +} + +// For tuning, check we're in tuning mode +bool CParameterMgr::checkTuningModeOn(string& strError) const +{ + // Tuning Mode on? + if (!_bTuningModeIsOn) { + + strError = "Tuning Mode must be on"; + + return false; + } + return true; +} + +// Dynamic creation library feeding +void CParameterMgr::feedElementLibraries() +{ + // Global Configuration handling + CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary; + + pFrameworkConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation")); + pFrameworkConfigurationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation")); + + _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary); + + // Parameter creation + CElementLibrary* pParameterCreationLibrary = new CElementLibrary; + + pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComponentType>("ComponentType")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComponentInstance>("Component")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBitParameterType>("BitParameter")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter")); + pParameterCreationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CComputedSizeParameterType>("ComputedSizeParameter")); + pParameterCreationLibrary->addElementBuilder(new CKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude")); + + _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary); + + // Parameter Configuration Domains creation + CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary; + + pParameterConfigurationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain")); + pParameterConfigurationLibrary->addElementBuilder(new CNamedElementBuilderTemplate<CDomainConfiguration>("Configuration")); + pParameterConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CCompoundRule>("CompoundRule")); + pParameterConfigurationLibrary->addElementBuilder(new CElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule")); + + _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary); +} + +// Remote Processor Server connection handling +bool CParameterMgr::handleRemoteProcessingInterface(string& strError) +{ + CAutoLog autoLog(this, "Handling remote processing interface"); + + // Start server if tuning allowed + if (_pSystemClassConfiguration->isTuningAllowed()) { + + log("Loading remote processor library"); + + // Load library + void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW); + + if (!lib_handle) { + + // Return error + const char* pcError = dlerror(); + + if (pcError) { + + strError = pcError; + } else { + + strError = "Unable to load libremote-processor.so library"; + } + + return false; + } + + CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer"); + + if (!pfnCreateRemoteProcessorServer) { + + strError = "libremote-process.so does not contain createRemoteProcessorServer symbol."; + + return false; + } + + // Create server + _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), this); + + // Compute max command usage length + setMaxCommandUsageLength(); + + log("Starting remote processor server on port %d", _pSystemClassConfiguration->getServerPort()); + // Start + if (!_pRemoteProcessorServer->start()) { + + strError = "Unable to start remote processor server"; + + return false; + } + } + + return true; +} + +// Back synchronization +CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const +{ +#ifdef SIMULATION + // In simulation, back synchronization of the blackboard won't probably work + // We need to ensure though the blackboard is initialized with valid data + return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); +#else + // Real back synchronizer from subsystems + return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); +#endif +} + +// Children typwise access +CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration() +{ + return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration)); +} + +const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration() +{ + return getFrameworkConfiguration(); +} + +CSelectionCriteria* CParameterMgr::getSelectionCriteria() +{ + return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria)); +} + +const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria() +{ + return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria)); +} + +CSystemClass* CParameterMgr::getSystemClass() +{ + return static_cast<CSystemClass*>(getChild(ESystemClass)); +} + +const CSystemClass* CParameterMgr::getConstSystemClass() const +{ + return static_cast<const CSystemClass*>(getChild(ESystemClass)); +} + +// Configurable Domains +CConfigurableDomains* CParameterMgr::getConfigurableDomains() +{ + return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains)); +} + +const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() +{ + return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); +} + +const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const +{ + return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); +} diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h new file mode 100644 index 0000000..a4ef01a --- /dev/null +++ b/parameter/ParameterMgr.h @@ -0,0 +1,318 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <pthread.h> +#include "RemoteCommandHandler.h" +#include "PathNavigator.h" +#include "SelectionCriterionType.h" +#include "SelectionCriterion.h" +#include "Element.h" +#include "SelectionCriterionObserver.h" +#include <map> +#include <vector> + +class CElementLibrarySet; +class CSubsystemLibrary; +class CSystemClass; +class CSelectionCriteria; +class CParameterFrameworkConfiguration; +class CSystemClassConfiguration; +class CParameterBlackboard; +class CConfigurableDomains; +class IRemoteProcessorServerInterface; +class CBackSynchronizer; + +class CParameterMgr : private CElement, private IRemoteCommandHandler, private ISelectionCriterionObserver +{ + enum ChildElement { + EFrameworkConfiguration, + ESelectionCriteria, + ESystemClass, + EConfigurableDomains + }; + enum ElementLibrary { + EFrameworkConfigurationLibrary, + EParameterCreationLibrary, + EParameterConfigurationLibrary + }; + // Remote command execution status + enum CommandStatus { + EDone, + ESucceeded, + EFailed, + EShowUsgae + }; + + // Remote command parsers + typedef CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, string& strResult); + + // Parser descriptions + struct SRemoteCommandParserItem + { + const char* _pcCommandName; + CParameterMgr::RemoteCommandParser _pfnParser; + uint32_t _uiMinArgumentCount; + const char* _pcHelp; + const char* _pcDescription; + + // Usage + string usage() const + { + return string(_pcCommandName) + " " + _pcHelp; + } + }; +public: + // Logger interface + class ILogger + { + public: + virtual void log(const std::string& strLog) = 0; + }; + + // Construction + CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName); + virtual ~CParameterMgr(); + + // Logging + void setLogger(ILogger* pLogger); + + // Init + bool load(string& strError); + virtual bool init(string& strError); + + // Selection Criteria + CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); + CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); + + //////////// Tuning ///////////// + // Tuning mode + bool setTuningMode(bool bOn, string& strError); + bool tuningModeOn() const; + + // Current value space for user set/get value interpretation + void setValueSpace(bool bIsRaw); + bool valueSpaceIsRaw(); + + // Automatic hardware synchronization control (during tuning session) + bool setAutoSync(bool bAutoSyncOn, string& strError); + bool autoSyncOn() const; + bool sync(string& strError); + + // User set/get parameters + bool setValue(const string& strPath, const string& strValue, string& strError); + bool getValue(const string& strPath, string& strValue, string& strError) const; + + ////////// Configuration/Domains handling ////////////// + // Creation/Deletion + bool createDomain(const string& strName, string& strError); + bool deleteDomain(const string& strName, string& strError); + bool createConfiguration(const string& strDomain, const string& strConfiguration, string& strError); + bool deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError); + + // Save/Restore + bool restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError); + bool saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError); + + // Configurable element - domain association + bool addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError); + bool removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError); + bool split(const string& strDomain, const string& strConfigurableElementPath, string& strError); + + // XML Import/Export + bool importDomainsXml(const string& strFileName, bool bWithSettings, string& strError); + bool exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const; + + // Binary Import/Export + bool importDomainsBinary(const string& strFileName, string& strError); + bool exportDomainsBinary(const string& strFileName, string& strError); + + // Introspect + void logStructureContent(string& strContent) const; + + // CElement + virtual string getKind() const; +private: + // Logging (done by root) + virtual void doLog(const string& strLog) const; + virtual void nestLog() const; + virtual void unnestLog() const; + + // From ISelectionCriterionObserver: selection criteria changed event + virtual void selectionCriterionChanged(const CSelectionCriterion* pSelectionCriterion); + + // From IRemoteCommandHandler: return true on success, fill result in any cases + virtual bool remoteCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + + ////////////////:: Remote command parsers + /// Help + CommandStatus helpCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + /// Status + CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + /// Tuning Mode + CommandStatus setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + /// Value Space + CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus getValueSpaceCommmandProcess(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); + /// 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); + /// 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); + /// Elements/Parameters + CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus listElementsRecursiveCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus getElementSizeCommmandProcess(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); + /// Browse + CommandStatus listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CommandStatus listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); + 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); + + // Max command usage length, use for formatting + void setMaxCommandUsageLength(); + + // For tuning, check we're in tuning mode + bool checkTuningModeOn(string& strError) const; + + // Framework global configuration loading + bool loadFrameworkConfiguration(string& strError); + + // System class Structure loading + bool loadStructure(string& strError); + + // System class Structure loading + bool loadSettings(string& strError); + + // Parse XML file into Root element + bool xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, ElementLibrary eElementLibrary, const string& strNameAttrituteName = "Name"); + + // Framework Configuration + CParameterFrameworkConfiguration* getFrameworkConfiguration(); + const CParameterFrameworkConfiguration* getConstFrameworkConfiguration(); + + // Selection Criteria + CSelectionCriteria* getSelectionCriteria(); + const CSelectionCriteria* getConstSelectionCriteria(); + + // System Class + CSystemClass* getSystemClass(); + const CSystemClass* getConstSystemClass() const; + + // Configurable Domains + CConfigurableDomains* getConfigurableDomains(); + const CConfigurableDomains* getConstConfigurableDomains(); + const CConfigurableDomains* getConstConfigurableDomains() const; + + // Dynamic object creation libraries feeding + void feedElementLibraries(); + + // Remote Processor Server connection handling + bool handleRemoteProcessingInterface(string& strError); + + // Back synchronization + CBackSynchronizer* createBackSynchronizer(string& strError) const; + + // Tuning + bool _bTuningModeIsOn; + + // Value Space + bool _bValueSpaceIsRaw; + + // Automatic synchronization to HW during Tuning session + bool _bAutoSyncOn; + + // Current Parameter Settings + CParameterBlackboard* _pMainParameterBlackboard; + + // Dynamic object creation + CElementLibrarySet* _pElementLibrarySet; + + // XML parsing, object creation handling + string _strParameterFrameworkConfigurationFolderPath; // Root folder for framework configuration + string _strSchemaFolderLocation; // Place where schemas stand + + // Subsystem plugin location + vector<string> _astrPluginFolderPaths; + + // System Class Configuration + const CSystemClassConfiguration* _pSystemClassConfiguration; + + // Whole system structure checksum + uint8_t _uiStructureChecksum; + + // Remote Processor Server + IRemoteProcessorServerInterface* _pRemoteProcessorServer; + + // Parser description array + static const SRemoteCommandParserItem gaRemoteCommandParserItems[]; + + // Parser description array size + static const uint32_t guiNbRemoteCommandParserItems; + + // Maximum command usage length + uint32_t _uiMaxCommandUsageLength; + + // Tuning mode mutex + pthread_mutex_t _tuningModeMutex; + + // Logging + ILogger* _pLogger; + uint32_t _uiLogDepth; +}; + diff --git a/parameter/ParameterMgrLogger.cpp b/parameter/ParameterMgrLogger.cpp new file mode 100644 index 0000000..c3dcda4 --- /dev/null +++ b/parameter/ParameterMgrLogger.cpp @@ -0,0 +1,42 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterMgrLogger.h" +#include "ParameterMgrPlatformConnector.h" + + +CParameterMgrLogger::CParameterMgrLogger(CParameterMgrPlatformConnector *pParameterMgrPlatformConnector) : _pParameterMgrPlatformConnector(pParameterMgrPlatformConnector) +{ +} + +void CParameterMgrLogger::log(const string &strLog) +{ + _pParameterMgrPlatformConnector->doLog(strLog); +} diff --git a/parameter/ParameterMgrLogger.h b/parameter/ParameterMgrLogger.h new file mode 100644 index 0000000..d99584d --- /dev/null +++ b/parameter/ParameterMgrLogger.h @@ -0,0 +1,49 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ParameterMgr.h" + +class CParameterMgrPlatformConnector; + +class CParameterMgrLogger : public CParameterMgr::ILogger +{ +public: + CParameterMgrLogger(CParameterMgrPlatformConnector* pParameterMgrPlatformConnector); + + // Logging + virtual void log(const string& strLog); + +private: + // Log destination + CParameterMgrPlatformConnector* _pParameterMgrPlatformConnector; +}; + diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp new file mode 100644 index 0000000..9da41dd --- /dev/null +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -0,0 +1,101 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterMgrPlatformConnector.h" +#include "ParameterMgr.h" +#include "ParameterMgrLogger.h" +#include <assert.h> + +#ifdef SIMULATION +const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/projects/qt/parameter-framework/XML"; +#else +const char* gpcParameterFrameworkConfigurationFolderPath = "/etc/parameter-framework"; +#endif + +// Construction +CParameterMgrPlatformConnector::CParameterMgrPlatformConnector(const string& strSystemClassName) + : _pParameterMgr(new CParameterMgr(gpcParameterFrameworkConfigurationFolderPath, strSystemClassName)), _bStarted(false), _pLogger(NULL) +{ + // Logging + _pParameterMgrLogger = new CParameterMgrLogger(this); + _pParameterMgr->setLogger(_pParameterMgrLogger); +} + +CParameterMgrPlatformConnector::~CParameterMgrPlatformConnector() +{ + delete _pParameterMgr; + delete _pParameterMgrLogger; +} + +ISelectionCriterionTypeInterface* CParameterMgrPlatformConnector::createSelectionCriterionType(bool bIsInclusive) +{ + assert(!_bStarted); + + return _pParameterMgr->createSelectionCriterionType(bIsInclusive); +} + +ISelectionCriterionInterface* CParameterMgrPlatformConnector::createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType) +{ + assert(!_bStarted); + + return _pParameterMgr->createSelectionCriterion(strName, static_cast<const CSelectionCriterionType*>(pSelectionCriterionType)); +} + +// Logging +void CParameterMgrPlatformConnector::setLogger(CParameterMgrPlatformConnector::ILogger* pLogger) +{ + _pLogger = pLogger; +} + +// Start +bool CParameterMgrPlatformConnector::start(std::string& strError) +{ + // Create data structure + if (!_pParameterMgr->load(strError)) { + + return false; + } + // Init flow + if (!_pParameterMgr->init(strError)) { + + return false; + } + + return true; +} + +// Private logging +void CParameterMgrPlatformConnector::doLog(const std::string& strLog) +{ + if (_pLogger) { + + _pLogger->log(strLog); + } +} diff --git a/parameter/ParameterMgrPlatformConnector.h b/parameter/ParameterMgrPlatformConnector.h new file mode 100644 index 0000000..91679b7 --- /dev/null +++ b/parameter/ParameterMgrPlatformConnector.h @@ -0,0 +1,70 @@ +/* ParameterMgrPlatformConnector.h + ** + ** Copyright © 2011 Intel + ** + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** + ** AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + ** CREATED: 2011-06-01 + ** UPDATED: 2011-07-27 + ** + */ +#pragma once + +#include "SelectionCriterionTypeInterface.h" +#include "SelectionCriterionInterface.h" + +class CParameterMgr; +class CParameterMgrLogger; + +class CParameterMgrPlatformConnector +{ + friend class CParameterMgrLogger; +public: + // Logger interface + class ILogger + { + public: + virtual void log(const std::string& strLog) = 0; + }; + + // Construction + CParameterMgrPlatformConnector(const std::string& strSystemClassName); + ~CParameterMgrPlatformConnector(); // Not virtual since supposed to be derived! + + // Selection Criteria interface. Beware returned objects are lent, clients shall not delete them! + // Should be called before start + ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive = false); + ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType); + + // Logging + // Should be called before start + void setLogger(ILogger* pLogger); + + // Start + bool start(std::string& strError); + +private: + // Private logging + void doLog(const std::string& strLog); + + // Implementation + CParameterMgr* _pParameterMgr; + // State + bool _bStarted; + // Logging + ILogger* _pLogger; + // Private logging + CParameterMgrLogger* _pParameterMgrLogger; +}; + diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp new file mode 100644 index 0000000..9a23c40 --- /dev/null +++ b/parameter/ParameterType.cpp @@ -0,0 +1,97 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "ParameterType.h" +#include "Parameter.h" +#include "ArrayParameter.h" + +#define base CTypeElement + +CParameterType::CParameterType(const string& strName) : base(strName), _uiSize(0) +{ +} + +CParameterType::~CParameterType() +{ +} + +// Size +void CParameterType::setSize(uint32_t uiSize) +{ + _uiSize = uiSize; +} + +uint32_t CParameterType::getSize() const +{ + return _uiSize; +} + +// Unit +string CParameterType::getUnit() const +{ + return _strUnit; +} + +// From IXmlSink +bool CParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Unit + _strUnit = xmlElement.getAttributeString("Unit"); + + return base::fromXml(xmlElement, serializingContext); +} + +// XML Serialization value space handling +// Value space handling for configuration import +void CParameterType::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + (void)xmlConfigurableElementSettingsElement; + (void)configurationAccessContext; + // Do nothing by default +} + +// Default value handling (simulation only) +uint32_t CParameterType::getDefaultValue() const +{ + return 0; +} + +// Parameter instantiation +CInstanceConfigurableElement* CParameterType::doInstantiate() const +{ + if (isScalar()) { + // Scalar parameter + return new CParameter(getName(), this); + } else { + // Array Parameter + return new CArrayParameter(getName(), this, getArrayLength()); + } +} + diff --git a/parameter/ParameterType.h b/parameter/ParameterType.h new file mode 100644 index 0000000..9f136a9 --- /dev/null +++ b/parameter/ParameterType.h @@ -0,0 +1,76 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <stdint.h> + +#include "TypeElement.h" + +class CParameterAccessContext; +class CConfigurationAccessContext; + +class CParameterType : public CTypeElement +{ +public: + CParameterType(const string& strName); + virtual ~CParameterType(); + + // Size + uint32_t getSize() const; + + // Unit + string getUnit() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Conversion + virtual bool asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const = 0; + virtual void asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const = 0; + + // XML Serialization value space handling + // Value space handling for configuration import + virtual void handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + + // Default value handling (simulation only) + virtual uint32_t getDefaultValue() const; +protected: + // Size + void setSize(uint32_t uiSize); + +private: + virtual CInstanceConfigurableElement* doInstantiate() const; + + // Size in bytes + uint32_t _uiSize; + // Unit + string _strUnit; +}; diff --git a/parameter/PathNavigator.cpp b/parameter/PathNavigator.cpp new file mode 100644 index 0000000..1911002 --- /dev/null +++ b/parameter/PathNavigator.cpp @@ -0,0 +1,88 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "PathNavigator.h" +#include "Tokenizer.h" + +CPathNavigator::CPathNavigator(const string& strPath) : _uiCurrentIndex(0) +{ + init(strPath); +} + +void CPathNavigator::init(const string& strPath) +{ + Tokenizer tokenizer(strPath, "/"); + + _astrItems = tokenizer.split(); + + _bValid = checkPathFormat(strPath); +} + +bool CPathNavigator::isPathValid() const +{ + return _bValid; +} + +string* CPathNavigator::next() +{ + if (_uiCurrentIndex < _astrItems.size()) { + + return &_astrItems[_uiCurrentIndex++]; + } + + return NULL; +} + +string CPathNavigator::getCurrentPath() const +{ + string strPath = "/"; + + if (!_uiCurrentIndex) { + + return strPath; + } + + uint32_t uiItem; + + for (uiItem = 0; uiItem < _uiCurrentIndex - 1; uiItem++) { + + strPath += _astrItems[uiItem] + "/"; + } + + strPath += _astrItems[uiItem]; + + return strPath; +} + + +bool CPathNavigator::checkPathFormat(const string& strUpl) +{ + return strUpl[0] == '/'; +} diff --git a/parameter/PathNavigator.h b/parameter/PathNavigator.h new file mode 100644 index 0000000..ae3a901 --- /dev/null +++ b/parameter/PathNavigator.h @@ -0,0 +1,57 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <vector> +#include <string> +#include <stdint.h> + +using namespace std; + +class CPathNavigator +{ +public: + CPathNavigator(const string& strPath); + + bool isPathValid() const; + + string* next(); + + string getCurrentPath() const; + +private: + void init(const string& strPath); + static bool checkPathFormat(const string& strUpl); + + bool _bValid; + vector<string> _astrItems; + uint32_t _uiCurrentIndex; +}; diff --git a/parameter/Rule.cpp b/parameter/Rule.cpp new file mode 100644 index 0000000..83c5177 --- /dev/null +++ b/parameter/Rule.cpp @@ -0,0 +1,38 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "Rule.h" + +#define base CElement + +CRule::CRule() +{ +} + diff --git a/parameter/Rule.h b/parameter/Rule.h new file mode 100644 index 0000000..95b9de3 --- /dev/null +++ b/parameter/Rule.h @@ -0,0 +1,43 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CRule : public CElement +{ + +public: + CRule(); + + // Rule check + virtual bool matches() const = 0; +}; diff --git a/parameter/SelectionCriteria.cpp b/parameter/SelectionCriteria.cpp new file mode 100644 index 0000000..f92807c --- /dev/null +++ b/parameter/SelectionCriteria.cpp @@ -0,0 +1,80 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriteria.h" +#include "SelectionCriterionLibrary.h" +#include "SelectionCriteriaDefinition.h" + +#define base CElement + +CSelectionCriteria::CSelectionCriteria() +{ + addChild(new CSelectionCriterionLibrary); + addChild(new CSelectionCriteriaDefinition); +} + +string CSelectionCriteria::getKind() const +{ + return "SelectionCriteria"; +} + +// Selection Criteria/Type creation +CSelectionCriterionType* CSelectionCriteria::createSelectionCriterionType(bool bIsInclusive) +{ + return getSelectionCriterionLibrary()->createSelectionCriterionType(bIsInclusive); +} + +CSelectionCriterion* CSelectionCriteria::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) +{ + return getSelectionCriteriaDefinition()->createSelectionCriterion(strName, pSelectionCriterionType); +} + +// Subscription +void CSelectionCriteria::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) +{ + // Delegate + getSelectionCriteriaDefinition()->setObserver(pSelectionCriterionObserver); +} + +// Children access +CSelectionCriterionLibrary* CSelectionCriteria::getSelectionCriterionLibrary() +{ + return static_cast<CSelectionCriterionLibrary*>(getChild(ESelectionCriterionLibrary)); +} + +CSelectionCriteriaDefinition* CSelectionCriteria::getSelectionCriteriaDefinition() +{ + return static_cast<CSelectionCriteriaDefinition*>(getChild(ESelectionCriteriaDefinition)); +} + +const CSelectionCriteriaDefinition* CSelectionCriteria::getSelectionCriteriaDefinition() const +{ + return static_cast<const CSelectionCriteriaDefinition*>(getChild(ESelectionCriteriaDefinition)); +} diff --git a/parameter/SelectionCriteria.h b/parameter/SelectionCriteria.h new file mode 100644 index 0000000..70528a9 --- /dev/null +++ b/parameter/SelectionCriteria.h @@ -0,0 +1,66 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include "SelectionCriterionType.h" +#include "SelectionCriterion.h" + +class CSelectionCriterionLibrary; +class CSelectionCriteriaDefinition; +class ISelectionCriterionObserver; + +class CSelectionCriteria : public CElement +{ + enum ChildElementType { + ESelectionCriterionLibrary, + ESelectionCriteriaDefinition + }; +public: + CSelectionCriteria(); + + // Selection Criteria/Type creation + CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); + CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); + + // Selection Criterion definition + const CSelectionCriteriaDefinition* getSelectionCriteriaDefinition() const; + + // Subscription + void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + + // Base + virtual string getKind() const; +private: + // Children access + CSelectionCriterionLibrary* getSelectionCriterionLibrary(); + CSelectionCriteriaDefinition* getSelectionCriteriaDefinition(); +}; diff --git a/parameter/SelectionCriteriaDefinition.cpp b/parameter/SelectionCriteriaDefinition.cpp new file mode 100644 index 0000000..eae8944 --- /dev/null +++ b/parameter/SelectionCriteriaDefinition.cpp @@ -0,0 +1,72 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriteriaDefinition.h" +#include "SelectionCriterion.h" + +CSelectionCriteriaDefinition::CSelectionCriteriaDefinition() +{ +} + +string CSelectionCriteriaDefinition::getKind() const +{ + return "SelectionCriteriaDefinition"; +} + +// Selection Criterion creation +CSelectionCriterion* CSelectionCriteriaDefinition::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) +{ + CSelectionCriterion* pSelectionCriterion = new CSelectionCriterion(strName, pSelectionCriterionType); + + addChild(pSelectionCriterion); + + return pSelectionCriterion; +} + +// Selection Criterion access +const CSelectionCriterion* CSelectionCriteriaDefinition::getSelectionCriterion(const string& strName) const +{ + return static_cast<const CSelectionCriterion*>(findChild(strName)); +} + +// Subscription +void CSelectionCriteriaDefinition::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) +{ + // Propagate + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + CSelectionCriterion* pSelectionCriterion = static_cast<CSelectionCriterion*>(getChild(uiChild)); + + pSelectionCriterion->setObserver(pSelectionCriterionObserver); + } +} diff --git a/parameter/SelectionCriteriaDefinition.h b/parameter/SelectionCriteriaDefinition.h new file mode 100644 index 0000000..2e1a2d6 --- /dev/null +++ b/parameter/SelectionCriteriaDefinition.h @@ -0,0 +1,55 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include "SelectionCriterion.h" + +class ISelectionCriterionObserver; + +class CSelectionCriteriaDefinition : public CElement +{ +public: + CSelectionCriteriaDefinition(); + + // Selection Criterion creation + CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); + + // Selection Criterion access + const CSelectionCriterion* getSelectionCriterion(const string& strName) const; + + // Subscription + void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + + // Base + virtual string getKind() const; +}; + diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp new file mode 100644 index 0000000..4c032bb --- /dev/null +++ b/parameter/SelectionCriterion.cpp @@ -0,0 +1,93 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriterion.h" + +#define base CElement + +CSelectionCriterion::CSelectionCriterion(const string& strName, const CSelectionCriterionType* pType) : base(strName), _iState(0), _pType(pType), _pObserver(NULL) +{ +} + +string CSelectionCriterion::getKind() const +{ + return "SelectionCriterion"; +} + +/// From ISelectionCriterionInterface +// State +void CSelectionCriterion::setCriterionState(int iState, bool bUpdate) +{ + // Check for a change + if (_iState != iState) { + + _iState = iState; + + // Update if required + if (bUpdate && _pObserver) { + + _pObserver->selectionCriterionChanged(this); + } + } +} + +int CSelectionCriterion::getCriterionState() const +{ + return _iState; +} + +// Name +string CSelectionCriterion::getCriterionName() const +{ + return getName(); +} + +// Type +const ISelectionCriterionTypeInterface* CSelectionCriterion::getCriterionType() const +{ + return _pType; +} + +/// Observer +void CSelectionCriterion::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) +{ + _pObserver = pSelectionCriterionObserver; +} + +/// Match methods +bool CSelectionCriterion::equals(int iState) const +{ + return _iState == iState; +} + +bool CSelectionCriterion::contains(int iState) const +{ + return (_iState & iState) != 0; +} diff --git a/parameter/SelectionCriterion.h b/parameter/SelectionCriterion.h new file mode 100644 index 0000000..8bdca68 --- /dev/null +++ b/parameter/SelectionCriterion.h @@ -0,0 +1,73 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include "SelectionCriterionType.h" +#include "SelectionCriterionObserver.h" +#include "SelectionCriterionInterface.h" + +#include <list> + +using namespace std; + +class CSelectionCriterion : public CElement, public ISelectionCriterionInterface +{ +public: + CSelectionCriterion(const string& strName, const CSelectionCriterionType* pType); + + /// From ISelectionCriterionInterface + // State + virtual void setCriterionState(int iState, bool bUpdate); + virtual int getCriterionState() const; + // Name + virtual string getCriterionName() const; + // Type + virtual const ISelectionCriterionTypeInterface* getCriterionType() const; + + /// Subscription + void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + + /// Match methods + bool equals(int iState) const; + bool contains(int iState) const; + + /// From CElement + virtual string getKind() const; +private: + // Current state + int _iState; + // Type + const CSelectionCriterionType* _pType; + // Observer + ISelectionCriterionObserver* _pObserver; +}; + diff --git a/parameter/SelectionCriterionDefinition.cpp b/parameter/SelectionCriterionDefinition.cpp new file mode 100644 index 0000000..58c5485 --- /dev/null +++ b/parameter/SelectionCriterionDefinition.cpp @@ -0,0 +1,40 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriterionDefinition.h" + +CSelectionCriterionDefinition::CSelectionCriterionDefinition(const string& strName) : CElement(strName) +{ +} + +string CSelectionCriterionDefinition::getKind() const +{ + return "SelectionCriterionDefinition"; +} diff --git a/parameter/SelectionCriterionDefinition.h b/parameter/SelectionCriterionDefinition.h new file mode 100644 index 0000000..4532010 --- /dev/null +++ b/parameter/SelectionCriterionDefinition.h @@ -0,0 +1,43 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CSelectionCriterionDefinition : public CElement +{ +public: + CSelectionCriterionDefinition(const string& strName); + + virtual string getKind() const; +private: +}; + diff --git a/parameter/SelectionCriterionInterface.h b/parameter/SelectionCriterionInterface.h new file mode 100644 index 0000000..134de01 --- /dev/null +++ b/parameter/SelectionCriterionInterface.h @@ -0,0 +1,35 @@ +/* SelectionCriterionInterface.h + ** + ** Copyright © 2011 Intel + ** + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** + ** AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + ** CREATED: 2011-06-01 + ** UPDATED: 2011-07-27 + ** + */ +#pragma once + +#include <string> + +#include "SelectionCriterionTypeInterface.h" + +class ISelectionCriterionInterface +{ +public: + virtual void setCriterionState(int iState, bool bUpdate = true) = 0; + virtual int getCriterionState() const = 0; + virtual std::string getCriterionName() const = 0; + virtual const ISelectionCriterionTypeInterface* getCriterionType() const = 0; +}; diff --git a/parameter/SelectionCriterionLibrary.cpp b/parameter/SelectionCriterionLibrary.cpp new file mode 100644 index 0000000..f15cd47 --- /dev/null +++ b/parameter/SelectionCriterionLibrary.cpp @@ -0,0 +1,52 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriterionLibrary.h" + +#define base CElement + +CSelectionCriterionLibrary::CSelectionCriterionLibrary() +{ +} + +string CSelectionCriterionLibrary::getKind() const +{ + return "SelectionCriterionLibrary"; +} + +// Type creation +CSelectionCriterionType* CSelectionCriterionLibrary::createSelectionCriterionType(bool bIsInclusive) +{ + CSelectionCriterionType* pSelectionCriterionType = new CSelectionCriterionType(bIsInclusive); + + addChild(pSelectionCriterionType); + + return pSelectionCriterionType; +} diff --git a/parameter/SelectionCriterionLibrary.h b/parameter/SelectionCriterionLibrary.h new file mode 100644 index 0000000..9d463c8 --- /dev/null +++ b/parameter/SelectionCriterionLibrary.h @@ -0,0 +1,46 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include "SelectionCriterionType.h" + +class CSelectionCriterionLibrary : public CElement +{ +public: + CSelectionCriterionLibrary(); + + // Type creation + CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); + + // CElement + virtual string getKind() const; +}; diff --git a/parameter/SelectionCriterionObserver.h b/parameter/SelectionCriterionObserver.h new file mode 100644 index 0000000..fd0ec7d --- /dev/null +++ b/parameter/SelectionCriterionObserver.h @@ -0,0 +1,39 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +class CSelectionCriterion; + +class ISelectionCriterionObserver +{ +public: + virtual void selectionCriterionChanged(const CSelectionCriterion* pSelectionCriterion) = 0; +}; diff --git a/parameter/SelectionCriterionRule.cpp b/parameter/SelectionCriterionRule.cpp new file mode 100644 index 0000000..4b5956c --- /dev/null +++ b/parameter/SelectionCriterionRule.cpp @@ -0,0 +1,150 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriterionRule.h" +#include "SelectionCriterion.h" +#include "XmlDomainSerializingContext.h" +#include "SelectionCriteriaDefinition.h" +#include <assert.h> + +#define base CRule + +const char* CSelectionCriterionRule::_apcMatchesWhen[CSelectionCriterionRule::ENbMatchesWhen] = { + "Is", + "Contains" +}; + +CSelectionCriterionRule::CSelectionCriterionRule() : _pSelectionCriterion(NULL), _eMatchesWhen(CSelectionCriterionRule::EIs), _iMatchValue(0) +{ +} + +// Class kind +string CSelectionCriterionRule::getKind() const +{ + return "SelectionCriterionRule"; +} + +// Rule check +bool CSelectionCriterionRule::matches() const +{ + assert(_pSelectionCriterion); + + switch(_eMatchesWhen) { + case EIs: + return _pSelectionCriterion->equals(_iMatchValue); + case EContains: + return _pSelectionCriterion->contains(_iMatchValue); + default: + assert(0); + return false; + } +} + +// From IXmlSink +bool CSelectionCriterionRule::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Retrieve actual context + CXmlDomainSerializingContext& xmlDomainSerializingContext = static_cast<CXmlDomainSerializingContext&>(serializingContext); + + // Get selection criterion + string strSelectionCriterion = xmlElement.getAttributeString("SelectionCriterion"); + + _pSelectionCriterion = xmlDomainSerializingContext.getSelectionCriteriaDefinition()->getSelectionCriterion(strSelectionCriterion); + + // Check existence + if (!_pSelectionCriterion) { + + xmlDomainSerializingContext.setError("Couldn't find selection criterion " + strSelectionCriterion + " in " + getKind() + " " + xmlElement.getPath()); + + return false; + } + + // Get MatchesWhen + string strMatchesWhen = xmlElement.getAttributeString("MatchesWhen"); + + if (!setMatchesWhen(strMatchesWhen)) { + + xmlDomainSerializingContext.setError("Wrong MatchesWhen attribute " + strMatchesWhen + " in " + getKind() + " " + xmlElement.getPath()); + + return false; + } + + // Get Value + string strValue = xmlElement.getAttributeString("Value"); + + if (!_pSelectionCriterion->getCriterionType()->getNumericalValue(strValue, _iMatchValue)) { + + xmlDomainSerializingContext.setError("Wrong Value attribute value " + strValue + " in " + getKind() + " " + xmlElement.getPath()); + + return false; + } + + // Done + return true; +} + +// From IXmlSource +void CSelectionCriterionRule::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const +{ + (void)serializingContext; + + assert(_pSelectionCriterion); + + // Set selection criterion + xmlElement.setAttributeString("SelectionCriterion", _pSelectionCriterion->getName()); + + // Set MatchesWhen + xmlElement.setAttributeString("MatchesWhen", _apcMatchesWhen[_eMatchesWhen]); + + // Set Value + string strValue; + + _pSelectionCriterion->getCriterionType()->getLiteralValue(_iMatchValue, strValue); + + xmlElement.setAttributeString("Value", strValue); +} + +// XML MatchesWhen attribute parsing +bool CSelectionCriterionRule::setMatchesWhen(const string& strMatchesWhen) +{ + uint32_t uiMatchesWhen; + + for (uiMatchesWhen = 0; uiMatchesWhen < ENbMatchesWhen; uiMatchesWhen++) { + + if (strMatchesWhen == _apcMatchesWhen[uiMatchesWhen]) { + + // Found it! + _eMatchesWhen = (MatchesWhen)uiMatchesWhen; + + return true; + } + } + return false; +} diff --git a/parameter/SelectionCriterionRule.h b/parameter/SelectionCriterionRule.h new file mode 100644 index 0000000..ebd7611 --- /dev/null +++ b/parameter/SelectionCriterionRule.h @@ -0,0 +1,76 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Rule.h" + +class CSelectionCriterion; + +class CSelectionCriterionRule : public CRule +{ + enum MatchesWhen { + EIs, + EContains, + + ENbMatchesWhen + }; + +public: + CSelectionCriterionRule(); + + // Rule check + virtual bool matches() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // From IXmlSource + virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; + + // Class kind + virtual string getKind() const; +private: + // Selection criterion + const CSelectionCriterion* _pSelectionCriterion; + + // XML MatchesWhen attribute parsing + bool setMatchesWhen(const string& strMatchesWhen); + + // MatchesWhen + MatchesWhen _eMatchesWhen; + + // Value + int32_t _iMatchValue; + + // Used for XML MatchesWhen attribute parsing + static const char* _apcMatchesWhen[ENbMatchesWhen]; +}; + diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp new file mode 100644 index 0000000..2e562da --- /dev/null +++ b/parameter/SelectionCriterionType.cpp @@ -0,0 +1,93 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SelectionCriterionType.h" + +#define base CElement + +CSelectionCriterionType::CSelectionCriterionType(bool bIsInclusive) : _bInclusive(bIsInclusive) +{ +} + +string CSelectionCriterionType::getKind() const +{ + return "SelectionCriterionType"; +} + +// From ISelectionCriterionTypeInterface +std::string CSelectionCriterionType::getCriterionTypeName() +{ + return getName(); +} + +bool CSelectionCriterionType::addValuePair(int iValue, const string& strValue) +{ + if (_numToLitMap.find(strValue) != _numToLitMap.end()) { + + return false; + } + _numToLitMap[strValue] = iValue; + + return true; +} + +bool CSelectionCriterionType::getNumericalValue(const string& strValue, int& iValue) const +{ + NumToLitMapConstIt it = _numToLitMap.find(strValue); + + if (it != _numToLitMap.end()) { + + iValue = it->second; + + return true; + } + return false; +} + +bool CSelectionCriterionType::getLiteralValue(int iValue, string& strValue) const +{ + NumToLitMapConstIt it; + + for (it = _numToLitMap.begin(); it != _numToLitMap.end(); ++it) { + + if (it->second == iValue) { + + strValue = it->first; + + return true; + } + } + return false; +} + +bool CSelectionCriterionType::isTypeInclusive() const +{ + return _bInclusive; +} diff --git a/parameter/SelectionCriterionType.h b/parameter/SelectionCriterionType.h new file mode 100644 index 0000000..ca0571f --- /dev/null +++ b/parameter/SelectionCriterionType.h @@ -0,0 +1,59 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" +#include <map> +#include <string> +#include "SelectionCriterionTypeInterface.h" + +class CSelectionCriterionType : public CElement, public ISelectionCriterionTypeInterface +{ + typedef map<string, int>::const_iterator NumToLitMapConstIt; + +public: + CSelectionCriterionType(bool bIsInclusive); + + // From ISelectionCriterionTypeInterface + virtual std::string getCriterionTypeName(); + virtual bool addValuePair(int iValue, const string& strValue); + virtual bool getNumericalValue(const string& strValue, int& iValue) const; + virtual bool getLiteralValue(int iValue, string& strValue) const; + virtual bool isTypeInclusive() const; + + // From CElement + virtual string getKind() const; +private: + + bool _bInclusive; + map<string, int> _numToLitMap; +}; + diff --git a/parameter/SelectionCriterionTypeInterface.h b/parameter/SelectionCriterionTypeInterface.h new file mode 100644 index 0000000..e089056 --- /dev/null +++ b/parameter/SelectionCriterionTypeInterface.h @@ -0,0 +1,34 @@ +/* SelectionCriterionTypeInterface.h + ** + ** Copyright © 2011 Intel + ** + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** + ** AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + ** CREATED: 2011-06-01 + ** UPDATED: 2011-07-27 + ** + */ +#pragma once + +#include <string> + +class ISelectionCriterionTypeInterface +{ +public: + virtual bool addValuePair(int iValue, const std::string& strValue) = 0; + virtual bool getNumericalValue(const std::string& strValue, int& iValue) const = 0; + virtual bool getLiteralValue(int iValue, std::string& strValue) const = 0; + virtual bool isTypeInclusive() const = 0; +}; + diff --git a/parameter/SimulatedBackSynchronizer.cpp b/parameter/SimulatedBackSynchronizer.cpp new file mode 100644 index 0000000..c808081 --- /dev/null +++ b/parameter/SimulatedBackSynchronizer.cpp @@ -0,0 +1,55 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SimulatedBackSynchronizer.h" +#include "ConfigurableElement.h" + +#define base CBackSynchronizer + +CSimulatedBackSynchronizer::CSimulatedBackSynchronizer(const CConfigurableElement* pConfigurableElement, string& strError, CParameterBlackboard* pParameterBlackboard) + : base(pConfigurableElement), _parameterAccessContext(strError) +{ + _parameterAccessContext.setParameterBlackboard(pParameterBlackboard); +} + +// Back synchronization +bool CSimulatedBackSynchronizer::sync() +{ + // Set default values to simulate back synchronization + list<const CConfigurableElement*>::const_iterator it; + + for (it = _needingBackSyncList.begin(); it != _needingBackSyncList.end(); ++it) { + + const CConfigurableElement* pConfigurableElement = *it; + + pConfigurableElement->setDefaultValues(_parameterAccessContext); + } + return true; +} diff --git a/parameter/SimulatedBackSynchronizer.h b/parameter/SimulatedBackSynchronizer.h new file mode 100644 index 0000000..c6cb5e5 --- /dev/null +++ b/parameter/SimulatedBackSynchronizer.h @@ -0,0 +1,49 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "BackSynchronizer.h" +#include "ParameterAccessContext.h" + +class CParameterBlackboard; + +class CSimulatedBackSynchronizer : public CBackSynchronizer +{ +public: + CSimulatedBackSynchronizer(const CConfigurableElement* pConfigurableElement, string& strError, CParameterBlackboard* pParameterBlackboard); + + // Back synchronization + virtual bool sync(); +private: + // Parameter context + CParameterAccessContext _parameterAccessContext; +}; + diff --git a/parameter/Subsystem.cpp b/parameter/Subsystem.cpp new file mode 100644 index 0000000..a501f91 --- /dev/null +++ b/parameter/Subsystem.cpp @@ -0,0 +1,341 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "Subsystem.h" +#include "ComponentLibrary.h" +#include "InstanceDefinition.h" +#include "XmlParameterSerializingContext.h" +#include "ParameterAccessContext.h" +#include "ConfigurationAccessContext.h" +#include "SubsystemObjectCreator.h" +#include <assert.h> + +#define base CConfigurableElement + +CSubsystem::CSubsystem(const string& strName) : base(strName), _pComponentLibrary(new CComponentLibrary), _pInstanceDefinition(new CInstanceDefinition), _bBigEndian(false) +{ + // Note: A subsystem contains instance components + // InstanceDefintion and ComponentLibrary objects are then not chosen to be children + // They'll be delt with locally +} + +CSubsystem::~CSubsystem() +{ + // Remove subsystem objects + SubsystemObjectListIterator subsystemObjectIt; + + for (subsystemObjectIt = _subsystemObjectList.begin(); subsystemObjectIt != _subsystemObjectList.end(); ++subsystemObjectIt) { + + delete *subsystemObjectIt; + } + + // Remove susbsystem creators + uint32_t uiIndex; + + for (uiIndex = 0; uiIndex < _subsystemObjectCreatorArray.size(); uiIndex++) { + + delete _subsystemObjectCreatorArray[uiIndex]; + } + + // Order matters! + delete _pInstanceDefinition; + delete _pComponentLibrary; +} + +string CSubsystem::getKind() const +{ + return "Subsystem"; +} + +// Susbsystem Endianness +bool CSubsystem::isBigEndian() const +{ + return _bBigEndian; +} + +// From IXmlSink +bool CSubsystem::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Context + CXmlParameterSerializingContext& parameterBuildContext = static_cast<CXmlParameterSerializingContext&>(serializingContext); + + // Install temporary component library for further component creation + parameterBuildContext.setComponentLibrary(_pComponentLibrary); + + CXmlElement childElement; + + // XML populate ComponentLibrary + xmlElement.getChildElement("ComponentLibrary", childElement); + + if (!_pComponentLibrary->fromXml(childElement, serializingContext)) { + + return false; + } + + // XML populate InstanceDefintion + xmlElement.getChildElement("InstanceDefintion", childElement); + if (!_pInstanceDefinition->fromXml(childElement, serializingContext)) { + + return false; + } + + // Create components + _pInstanceDefinition->createInstances(this); + + // Execute mapping to create subsystem mapping entities + string strError; + if (!mapSubsystemElements(strError)) { + + serializingContext.setError(strError); + + return false; + } + + // Endianness + _bBigEndian = xmlElement.getAttributeBoolean("Endianness", "Big"); + + return true; +} + +// XML configuration settings parsing +bool CSubsystem::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const +{ + // Fix Endianness + configurationAccessContext.setBigEndianSubsystem(_bBigEndian); + + return base::serializeXmlSettings(xmlConfigurableElementSettingsElement, configurationAccessContext); +} + + +bool CSubsystem::mapSubsystemElements(string& strError) +{ + // Default mapping context + _contextStack.push(CMappingContext(_contextMappingKeyArray.size())); + + // Map all instantiated subelements in subsystem + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + CInstanceConfigurableElement* pInstanceConfigurableChildElement = static_cast<CInstanceConfigurableElement*>(getChild(uiChild)); + + if (!pInstanceConfigurableChildElement->map(*this, strError)) { + + return false; + } + } + return true; +} + +// Parameter access +bool CSubsystem::setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Deal with Endianness + parameterContext.setBigEndianSubsystem(_bBigEndian); + + return base::setValue(pathNavigator, strValue, errorContext); +} + +bool CSubsystem::getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Deal with Endianness + parameterContext.setBigEndianSubsystem(_bBigEndian); + + return base::getValue(pathNavigator, strValue, errorContext); +} + +void CSubsystem::logValue(string& strValue, CErrorContext& errorContext) const +{ + CParameterAccessContext& parameterContext = static_cast<CParameterAccessContext&>(errorContext); + + // Deal with Endianness + parameterContext.setBigEndianSubsystem(_bBigEndian); + + return base::logValue(strValue, errorContext); +} + +// Used for simulation only +void CSubsystem::setDefaultValues(CParameterAccessContext& parameterAccessContext) const +{ + // Deal with Endianness + parameterAccessContext.setBigEndianSubsystem(_bBigEndian); + + base::setDefaultValues(parameterAccessContext); +} + +// Belonging subsystem +const CSubsystem* CSubsystem::getBelongingSubsystem() const +{ + return this; +} + +// Subsystem context mapping keys publication +void CSubsystem::addContextMappingKey(const string& strMappingKey) +{ + _contextMappingKeyArray.push_back(strMappingKey); +} + +// Subsystem object creator publication (strong reference) +void CSubsystem::addSubsystemObjectCreator(CSubsystemObjectCreator* pSubsystemObjectCreator) +{ + _subsystemObjectCreatorArray.push_back(pSubsystemObjectCreator); +} + +// Mapping generic context handling +bool CSubsystem::handleMappingContext(const CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError) +{ + // Feed context with found mapping data + uint32_t uiItem; + + for (uiItem = 0; uiItem < _contextMappingKeyArray.size(); uiItem++) { + + string strKey = _contextMappingKeyArray[uiItem]; + string strValue; + + if (pInstanceConfigurableElement->getMappingData(strKey, strValue)) { + // Assign item to context + if (!context.setItem(uiItem, strValue)) { + + getMappingError(strError, strKey, "Already set", pInstanceConfigurableElement); + + return false; + } + } + } + return true; +} + +// Creation handling +bool CSubsystem::handleSubsystemObjectCreation(CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError) +{ + uint32_t uiItem; + + for (uiItem = 0; uiItem < _subsystemObjectCreatorArray.size(); uiItem++) { + + const CSubsystemObjectCreator* pSubsystemObjectCreator = _subsystemObjectCreatorArray[uiItem]; + + // Mapping key + string strKey = pSubsystemObjectCreator->getMappingKey(); + // Object id + string strId; + + if (pInstanceConfigurableElement->getMappingData(strKey, strId)) { + + // First check context consisteny + uint32_t uiAncestorKey; + uint32_t uiAncestorMask = pSubsystemObjectCreator->getAncestorMask(); + + for (uiAncestorKey = 0; uiAncestorKey & uiAncestorMask; uiAncestorKey++) { + + string strAncestorKey = _subsystemObjectCreatorArray[uiAncestorKey]->getMappingKey(); + + if (!context.iSet(uiAncestorKey)) { + + getMappingError(strError, strKey, strAncestorKey + " not set", pInstanceConfigurableElement); + + return false; + } + } + + // Do create object + string strCreationError; + + CSubsystemObject* pSubsystemObject = pSubsystemObjectCreator->objectCreate(strId, pInstanceConfigurableElement, context, strCreationError); + + if (!pSubsystemObject) { + + getMappingError(strError, strKey, strCreationError, pInstanceConfigurableElement); + + return false; + } + // Keep track of created object + _subsystemObjectList.push_back(pSubsystemObject); + + // Done + return true; + } + } + getMappingError(strError, "Mapping key", "Not found", pInstanceConfigurableElement); + + return false; +} + +// Generic error handling from derived subsystem classes +void CSubsystem::getMappingError(string& strError, const string& strKey, const string& strMessage, const CInstanceConfigurableElement* pInstanceConfigurableElement) +{ + strError = getName() + " " + getKind() + " mapping:\n" + strKey + " error : \"" + strMessage + "\" for element " + pInstanceConfigurableElement->getPath(); +} + +// From IMapper +bool CSubsystem::mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, string& strError) +{ + // Get current context + CMappingContext context = _contextStack.top(); + + switch(pInstanceConfigurableElement->getType()) { + + case CInstanceConfigurableElement::EComponent: + + if (!handleMappingContext(pInstanceConfigurableElement, context, strError)) { + + return false; + } + break; + case CInstanceConfigurableElement::EParameterBlock: + case CInstanceConfigurableElement::EBitParameterBlock: + case CInstanceConfigurableElement::EParameter: + { + if (!handleSubsystemObjectCreation(pInstanceConfigurableElement, context, strError)) { + + return false; + } + break; + } + default: + assert(0); + return false; + } + + // Push context + _contextStack.push(context); + + return true; +} + +void CSubsystem::mapEnd() +{ + // Unstack context + _contextStack.pop(); +} diff --git a/parameter/Subsystem.h b/parameter/Subsystem.h new file mode 100644 index 0000000..af98608 --- /dev/null +++ b/parameter/Subsystem.h @@ -0,0 +1,113 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ConfigurableElement.h" +#include "Mapper.h" +#include "MappingContext.h" +#include <stack> +#include <vector> + +class CInstanceDefinition; +class CComponentLibrary; +class CSubsystemObject; +class CSubsystemObjectCreator; + +class CSubsystem : public CConfigurableElement, private IMapper +{ + // Subsystem objects iterator + typedef list<CSubsystemObject*>::const_iterator SubsystemObjectListIterator; +public: + CSubsystem(const string& strName); + virtual ~CSubsystem(); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Susbsystem Endianness + bool isBigEndian() const; + + // XML configuration settings parsing + virtual bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; + + // from CElement + virtual string getKind() const; +protected: + // Parameter access + virtual bool setValue(CPathNavigator& pathNavigator, const string& strValue, CErrorContext& errorContext) const; + virtual bool getValue(CPathNavigator& pathNavigator, string& strValue, CErrorContext& errorContext) const; + virtual void logValue(string& strValue, CErrorContext& errorContext) const; + // Used for simulation only + virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; + + /// Functionality intendedn for derived Subsystems + // Subsystem context mapping keys publication + void addContextMappingKey(const string& strMappingKey); + // Subsystem object creator publication (strong reference) + void addSubsystemObjectCreator(CSubsystemObjectCreator* pSubsystemObjectCreator); +private: + // Belonging subsystem + virtual const CSubsystem* getBelongingSubsystem() const; + + // Mapping execution + bool mapSubsystemElements(string& strError); + + // Generic subsystem mapping error handling + void getMappingError(string& strError, const string& strKey, const string& strMessage, const CInstanceConfigurableElement* pInstanceConfigurableElement); + + // From IMapper + virtual bool mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, string& strError); + virtual void mapEnd(); + + // Mapping generic context handling + bool handleMappingContext(const CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError); + // Subsystem object creation handling + bool handleSubsystemObjectCreation(CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError); + + // Subsystem context mapping keys + vector<string> _contextMappingKeyArray; + + // Subsystem object creator map + vector<CSubsystemObjectCreator*> _subsystemObjectCreatorArray; + + // Subsystem sync objects (house keeping) + list<CSubsystemObject*> _subsystemObjectList; + + // Mapping Context stack + stack<CMappingContext> _contextStack; + + // Subelements + CComponentLibrary* _pComponentLibrary; + CInstanceDefinition* _pInstanceDefinition; + + // Endianness + bool _bBigEndian; +}; diff --git a/parameter/SubsystemElementBuilder.cpp b/parameter/SubsystemElementBuilder.cpp new file mode 100644 index 0000000..118ddf1 --- /dev/null +++ b/parameter/SubsystemElementBuilder.cpp @@ -0,0 +1,41 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SubsystemElementBuilder.h" +#include "SubsystemLibrary.h" + +CSubsystemElementBuilder::CSubsystemElementBuilder(const CSubsystemLibrary* pSubsystemLibrary) : CElementBuilder("Subsystem"), _pSubsystemLibrary(pSubsystemLibrary) +{ +} + +CElement* CSubsystemElementBuilder::createElement(const CXmlElement& xmlElement) const +{ + return _pSubsystemLibrary->createElement(xmlElement); +} diff --git a/parameter/SubsystemElementBuilder.h b/parameter/SubsystemElementBuilder.h new file mode 100644 index 0000000..bc3cdfa --- /dev/null +++ b/parameter/SubsystemElementBuilder.h @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ElementBuilder.h" + +class CSubsystemLibrary; + +class CSubsystemElementBuilder : public CElementBuilder +{ +public: + CSubsystemElementBuilder(const CSubsystemLibrary* pSubsystemLibrary); + + virtual CElement* createElement(const CXmlElement& xmlElement) const; + +private: + const CSubsystemLibrary* _pSubsystemLibrary; +}; + diff --git a/parameter/SubsystemLibrary.cpp b/parameter/SubsystemLibrary.cpp new file mode 100644 index 0000000..8dd84e6 --- /dev/null +++ b/parameter/SubsystemLibrary.cpp @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SubsystemLibrary.h" +#include "XmlElement.h" + + +CSubsystemLibrary::CSubsystemLibrary() +{ +} + +CSubsystemLibrary::~CSubsystemLibrary() +{ +} + +string CSubsystemLibrary::getBuilderType(const CXmlElement& xmlElement) const +{ + // Xml element's name attribute + return xmlElement.getAttributeString("Type"); +} diff --git a/parameter/SubsystemLibrary.h b/parameter/SubsystemLibrary.h new file mode 100644 index 0000000..c94b762 --- /dev/null +++ b/parameter/SubsystemLibrary.h @@ -0,0 +1,44 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ElementLibrary.h" + +class CSubsystemLibrary : public CElementLibrary +{ +public: + CSubsystemLibrary(); + virtual ~CSubsystemLibrary(); + +private: + // Builder type (based on element's name attribute) + virtual string getBuilderType(const CXmlElement& xmlElement) const; +}; diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp new file mode 100644 index 0000000..fb53520 --- /dev/null +++ b/parameter/SubsystemObject.cpp @@ -0,0 +1,97 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SubsystemObject.h" +#include "InstanceConfigurableElement.h" +#include "ParameterBlackboard.h" +#include <assert.h> + +CSubsystemObject::CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement) + : _pInstanceConfigurableElement(pInstanceConfigurableElement), _uiDataSize(pInstanceConfigurableElement->getFootPrint()), _pvSynchronizedLocation(NULL) +{ + // Syncer + _pInstanceConfigurableElement->setSyncer(this); +} + +CSubsystemObject::~CSubsystemObject() +{ + _pInstanceConfigurableElement->unsetSyncer(); +} + +// Synchronized location +void CSubsystemObject::setSynchronizedLocation(void* pvSynchronizedLocation) +{ + _pvSynchronizedLocation = pvSynchronizedLocation; +} + +// Size +uint32_t CSubsystemObject::getSize() const +{ + return _uiDataSize; +} + +// Synchronization +bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) +{ + assert(_pvSynchronizedLocation); + +#ifdef SIMULATION + return true; +#endif + + // Synchronize to/from HW + if (bBack) { + + // Read from HW + if (!receiveFromHW()) { + + strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + + return false; + } + + // Write parameter block data + parameterBlackboard.rawWrite(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); + + } else { + + // Read parameter block data + parameterBlackboard.rawRead(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); + + // Send to HW + if (!sendToHW()) { + + strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + + return false; + } + } + return true; +} diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h new file mode 100644 index 0000000..c4e88fb --- /dev/null +++ b/parameter/SubsystemObject.h @@ -0,0 +1,64 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Syncer.h" +#include <stdint.h> + +class CInstanceConfigurableElement; + +class CSubsystemObject : public ISyncer +{ +public: + CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement); + virtual ~CSubsystemObject(); + + // from ISyncer + virtual bool sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError); + +protected: + // Synchronized location + void setSynchronizedLocation(void* pvSynchronizedLocation); + // Size + uint32_t getSize() const; + + // Sync to/from HW + virtual bool sendToHW() = 0; + virtual bool receiveFromHW() = 0; +private: + // Instance element to sync from/to + CInstanceConfigurableElement* _pInstanceConfigurableElement; + // Data size + uint32_t _uiDataSize; + // Synchronized location + void* _pvSynchronizedLocation; +}; + diff --git a/parameter/SubsystemObjectCreator.cpp b/parameter/SubsystemObjectCreator.cpp new file mode 100644 index 0000000..b0f0dde --- /dev/null +++ b/parameter/SubsystemObjectCreator.cpp @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SubsystemObjectCreator.h" + +CSubsystemObjectCreator::CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask) + : _strMappingKey(strMappingKey), _uiAncestorIdMask(uiAncestorIdMask) +{ +} + +// Accessors +const string& CSubsystemObjectCreator::getMappingKey() const +{ + return _strMappingKey; +} + +uint32_t CSubsystemObjectCreator::getAncestorMask() const +{ + return _uiAncestorIdMask; +} diff --git a/parameter/SubsystemObjectCreator.h b/parameter/SubsystemObjectCreator.h new file mode 100644 index 0000000..91ad5be --- /dev/null +++ b/parameter/SubsystemObjectCreator.h @@ -0,0 +1,57 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "SubsystemObject.h" +#include "MappingContext.h" +#include <string> + +using namespace std; + +class CSubsystemObjectCreator +{ +public: + CSubsystemObjectCreator(const string& strMappingKey, uint32_t uiAncestorIdMask); + + // Accessors + const string& getMappingKey() const; + uint32_t getAncestorMask() const; + + // Object creation + virtual CSubsystemObject* objectCreate(const string& strId, CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError) const = 0; + +private: + // Mapping key + string _strMappingKey; + // Mask of must-be-specified ancestors + uint32_t _uiAncestorIdMask; +}; + diff --git a/parameter/Syncer.h b/parameter/Syncer.h new file mode 100644 index 0000000..052df6b --- /dev/null +++ b/parameter/Syncer.h @@ -0,0 +1,43 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <string> + +using namespace std; + +class CParameterBlackboard; + +class ISyncer +{ +public: + virtual bool sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) = 0; +}; diff --git a/parameter/SyncerSet.cpp b/parameter/SyncerSet.cpp new file mode 100644 index 0000000..0924784 --- /dev/null +++ b/parameter/SyncerSet.cpp @@ -0,0 +1,75 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SyncerSet.h" +#include "Syncer.h" + +CSyncerSet::CSyncerSet() +{ +} + +const CSyncerSet& CSyncerSet::operator+=(ISyncer* pRightSyncer) +{ + _syncerSet.insert(pRightSyncer); + + return *this; +} + +const CSyncerSet& CSyncerSet::operator+=(const CSyncerSet& rightSyncerSet) +{ + if (&rightSyncerSet != this) { + + _syncerSet.insert(rightSyncerSet._syncerSet.begin(), rightSyncerSet._syncerSet.end()); + } + + return *this; +} + +void CSyncerSet::clear() +{ + _syncerSet.clear(); +} + +bool CSyncerSet::sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) const +{ + // Propagate + SyncerSetConstIterator it; + + for (it = _syncerSet.begin(); it != _syncerSet.end(); ++it) { + + ISyncer* pSyncer = *it; + + if (!pSyncer->sync(parameterBlackboard, bBack, strError)) { + + return false; + } + } + return true; +} diff --git a/parameter/SyncerSet.h b/parameter/SyncerSet.h new file mode 100644 index 0000000..1095c9e --- /dev/null +++ b/parameter/SyncerSet.h @@ -0,0 +1,59 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include <set> +#include <string> + +using namespace std; + +class ISyncer; +class CParameterBlackboard; + +class CSyncerSet +{ + typedef set<ISyncer*>::const_iterator SyncerSetConstIterator; +public: + CSyncerSet(); + + // Filling + const CSyncerSet& operator+=(ISyncer* pRightSyncer); + const CSyncerSet& operator+=(const CSyncerSet& rightSyncerSet); + + // Clearing + void clear(); + + // Sync + bool sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) const; + +private: + set<ISyncer*> _syncerSet; +}; diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp new file mode 100644 index 0000000..62b6538 --- /dev/null +++ b/parameter/SystemClass.cpp @@ -0,0 +1,177 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include <dlfcn.h> +#include <dirent.h> +#include "SystemClass.h" +#include "SubsystemLibrary.h" +#include "AutoLog.h" + +#define base CConfigurableElement + +// Used by subsystem plugins +typedef void (*GetSusbystemBuilder)(CSubsystemLibrary*); + +CSystemClass::CSystemClass(const string& strName) : base(strName), _pSubsystemLibrary(new CSubsystemLibrary) +{ +} + +CSystemClass::~CSystemClass() +{ + delete _pSubsystemLibrary; +} + +bool CSystemClass::childrenAreDynamic() const +{ + return true; +} + +string CSystemClass::getKind() const +{ + return "SystemClass"; +} + +bool CSystemClass::loadSubsystems(string& strError, const vector<string>& astrPluginFolderPaths) +{ + CAutoLog autoLlog(this, "Loading subsystem plugins"); + + // Plugin list + vector<string> astrPluginFiles; + + uint32_t uiFolderLocation; + + for (uiFolderLocation = 0; uiFolderLocation < astrPluginFolderPaths.size(); uiFolderLocation++) { + + // Folder for current SystemClass + string strPluginPath = astrPluginFolderPaths[uiFolderLocation] + "/" + getName() + "/"; + + // Get plugin list + getPluginFiles(strPluginPath, astrPluginFiles); + } + // Check at least one subsystem plugin available + if (!astrPluginFiles.size()) { + + // No plugin found? + strError = "No subsystem plugin found"; + } + + // Actually load plugins + uint32_t uiPlugin; + // Start clean + _pSubsystemLibrary->clean(); + + for (uiPlugin = 0; uiPlugin < astrPluginFiles.size(); uiPlugin++) { + + string strPluginFileName = astrPluginFiles[uiPlugin]; + + log("Loading subsystem plugin path \"%s\"", strPluginFileName.c_str()); + + void* lib_handle = dlopen(strPluginFileName.c_str(), RTLD_LAZY); + + if (!lib_handle) { + + // Return error + const char* pcError = dlerror(); + + if (pcError) { + + strError = pcError; + } else { + + strError = "Unable to load subsystem plugin " + strPluginFileName; + } + + _pSubsystemLibrary->clean(); + + return false; + } + + GetSusbystemBuilder pfnGetSusbystemBuilder = (GetSusbystemBuilder)dlsym(lib_handle, "getSusbystemBuilder"); + + if (!pfnGetSusbystemBuilder) { + + strError = "Subsystem plugin " + strPluginFileName + " does not contain getSusbystemBuilder symbol."; + + _pSubsystemLibrary->clean(); + + return false; + } + + // Fill library + pfnGetSusbystemBuilder(_pSubsystemLibrary); + } + + return true; +} + +bool CSystemClass::getPluginFiles(const string& strPluginPath, vector<string>& astrPluginFiles) const +{ + log("Seeking subsystem plugins from folder \"%s\"", strPluginPath.c_str()); + + DIR *dirp; + struct dirent *dp; + + if ((dirp = opendir(strPluginPath.c_str())) == NULL) { + + return false; + } + + const string strPluginPattern("-subsystem.so"); + + // Parse it and load plugins + while ((dp = readdir(dirp)) != NULL) { + + string strFileName(dp->d_name); + + // Check file name ends with "-susbsystem.so" + size_t uiPatternPos = strFileName.rfind(strPluginPattern, -1); + + if (uiPatternPos != (size_t)-1 && uiPatternPos == strFileName.size() - strPluginPattern.size()) { + // Found plugin + astrPluginFiles.push_back(strPluginPath + strFileName); + } + } + + // Close plugin folder + closedir(dirp); + + return true; +} + +const CSubsystemLibrary* CSystemClass::getSubsystemLibrary() const +{ + return _pSubsystemLibrary; +} + +bool CSystemClass::init(string& strError) +{ + return base::init(strError); +} + diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h new file mode 100644 index 0000000..a739f1a --- /dev/null +++ b/parameter/SystemClass.h @@ -0,0 +1,62 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "ConfigurableElement.h" +#include <vector> + +class CSubsystemLibrary; + +class CSystemClass : public CConfigurableElement +{ +public: + CSystemClass(const string& strName); + virtual ~CSystemClass(); + + // Called from parent before actual init + bool loadSubsystems(string& strError, const vector<string>& astrPluginFolderPaths); + const CSubsystemLibrary* getSubsystemLibrary() const; + + // base + virtual bool init(string& strError); + virtual string getKind() const; + +private: + // base + virtual bool childrenAreDynamic() const; + + // Subsystem plugins + bool getPluginFiles(const string& strPluginPath, vector<string>& astrPluginFiles) const; + + // ref only + CSubsystemLibrary* _pSubsystemLibrary; +}; + diff --git a/parameter/SystemClassConfiguration.cpp b/parameter/SystemClassConfiguration.cpp new file mode 100644 index 0000000..0ebb2b1 --- /dev/null +++ b/parameter/SystemClassConfiguration.cpp @@ -0,0 +1,63 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "SystemClassConfiguration.h" + +#define base CFrameworkConfigurationGroup + +CSystemClassConfiguration::CSystemClassConfiguration(const string& strName, const string& strKind) + : base(strName, strKind), _bTuningAllowed(false), _uiServerPort(0) +{ +} + +// Tuning allowed +bool CSystemClassConfiguration::isTuningAllowed() const +{ + return _bTuningAllowed; +} + +// Server port +uint16_t CSystemClassConfiguration::getServerPort() const +{ + return _uiServerPort; +} + +// From IXmlSink +bool CSystemClassConfiguration::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Tuning allowed + _bTuningAllowed = xmlElement.getAttributeBoolean("TuningAllowed"); + + // Server port + _uiServerPort = (uint16_t)xmlElement.getAttributeInteger("ServerPort"); + + // Base + return base::fromXml(xmlElement, serializingContext); +} diff --git a/parameter/SystemClassConfiguration.h b/parameter/SystemClassConfiguration.h new file mode 100644 index 0000000..0a24a8a --- /dev/null +++ b/parameter/SystemClassConfiguration.h @@ -0,0 +1,54 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "FrameworkConfigurationGroup.h" + +class CSystemClassConfiguration : public CFrameworkConfigurationGroup +{ +public: + CSystemClassConfiguration(const string& strName, const string& strKind); + + // Tuning allowed + bool isTuningAllowed() const; + + // Server port + uint16_t getServerPort() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); +private: + // Tuning allowed + bool _bTuningAllowed; + // Server port + uint16_t _uiServerPort; +}; + diff --git a/parameter/TypeElement.cpp b/parameter/TypeElement.cpp new file mode 100644 index 0000000..2b9c663 --- /dev/null +++ b/parameter/TypeElement.cpp @@ -0,0 +1,126 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "TypeElement.h" +#include "MappingData.h" +#include "Tokenizer.h" +#include "InstanceConfigurableElement.h" +#include <assert.h> + +#define base CElement + +CTypeElement::CTypeElement(const string& strName) : base(strName), _uiArrayLength(0), _pMappingData(NULL) +{ +} + +CTypeElement::~CTypeElement() +{ + delete _pMappingData; +} + +bool CTypeElement::isScalar() const +{ + return !_uiArrayLength; +} + +uint32_t CTypeElement::getArrayLength() const +{ + return _uiArrayLength; +} + +bool CTypeElement::getMappingData(const string& strKey, string& strValue) const +{ + if (_pMappingData) { + + return _pMappingData->getValue(strKey, strValue); + } + return false; +} + +bool CTypeElement::hasMappingData() const +{ + return !!_pMappingData; +} + +void CTypeElement::populate(CElement* pElement) const +{ + // Populate children + uint32_t uiChild; + uint32_t uiNbChildren = getNbChildren(); + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + const CTypeElement* pChildTypeElement = static_cast<const CTypeElement*>(getChild(uiChild)); + + CInstanceConfigurableElement* pInstanceConfigurableChildElement = pChildTypeElement->instantiate(); + + // Affiliate + pElement->addChild(pInstanceConfigurableChildElement); + } +} + +bool CTypeElement::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Array Length attribute + if (xmlElement.hasAttribute("ArrayLength")) { + + _uiArrayLength = xmlElement.getAttributeInteger("ArrayLength"); + } else { + _uiArrayLength = 0; // Scalar + } + // Manage mapping attribute + if (xmlElement.hasAttribute("Mapping")) { + + if (!getMappingData()->fromXml(xmlElement, serializingContext)) { + + return false; + } + } + return base::fromXml(xmlElement, serializingContext); +} + +CInstanceConfigurableElement* CTypeElement::instantiate() const +{ + CInstanceConfigurableElement* pInstanceConfigurableElement = doInstantiate(); + + // Populate + populate(pInstanceConfigurableElement); + + return pInstanceConfigurableElement; +} + +CMappingData* CTypeElement::getMappingData() +{ + if (!_pMappingData) { + + _pMappingData = new CMappingData; + } + return _pMappingData; +} diff --git a/parameter/TypeElement.h b/parameter/TypeElement.h new file mode 100644 index 0000000..9391729 --- /dev/null +++ b/parameter/TypeElement.h @@ -0,0 +1,75 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "Element.h" + +class CMappingData; +class CInstanceConfigurableElement; + +class CTypeElement : public CElement +{ +public: + CTypeElement(const string& strName = ""); + virtual ~CTypeElement(); + + // Instantiation + CInstanceConfigurableElement* instantiate() const; + + // Mapping info + virtual bool getMappingData(const string& strKey, string& strValue) const; + virtual bool hasMappingData() const; + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); + + // Scalar or Array? + bool isScalar() const; + +protected: + // Array Length + uint32_t getArrayLength() const; + + // Object creation + virtual void populate(CElement* pElement) const; +private: + // Actual instance creation + virtual CInstanceConfigurableElement* doInstantiate() const = 0; + + // Mapping data creation and access + CMappingData* getMappingData(); + + // For Arrays. 0 means scalar + uint32_t _uiArrayLength; + + // Mapping info + CMappingData* _pMappingData; +}; diff --git a/parameter/XmlDomainSerializingContext.cpp b/parameter/XmlDomainSerializingContext.cpp new file mode 100644 index 0000000..34a465c --- /dev/null +++ b/parameter/XmlDomainSerializingContext.cpp @@ -0,0 +1,66 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "XmlDomainSerializingContext.h" + +#define base CXmlElementSerializingContext + +CXmlDomainSerializingContext::CXmlDomainSerializingContext(string& strError, bool bWithSettings) + : base(strError), _bWithSettings(bWithSettings), _bValueSpaceIsRaw(false), _pSelectionCriteriaDefinition(NULL) +{ +} + +// Settings to be loaded or not +bool CXmlDomainSerializingContext::withSettings() const +{ + return _bWithSettings; +} + +// Value Space +void CXmlDomainSerializingContext::setValueSpaceRaw(bool bIsRaw) +{ + _bValueSpaceIsRaw = bIsRaw; +} + +bool CXmlDomainSerializingContext::valueSpaceIsRaw() const +{ + return _bValueSpaceIsRaw; +} + +// Criteria defintion +void CXmlDomainSerializingContext::setSelectionCriteriaDefinition(const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition) +{ + _pSelectionCriteriaDefinition = pSelectionCriteriaDefinition; +} + +const CSelectionCriteriaDefinition* CXmlDomainSerializingContext::getSelectionCriteriaDefinition() const +{ + return _pSelectionCriteriaDefinition; +} diff --git a/parameter/XmlDomainSerializingContext.h b/parameter/XmlDomainSerializingContext.h new file mode 100644 index 0000000..770f14b --- /dev/null +++ b/parameter/XmlDomainSerializingContext.h @@ -0,0 +1,64 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "XmlElementSerializingContext.h" + +class CParameterBlackboard; +class CSelectionCriteriaDefinition; + +class CXmlDomainSerializingContext : public CXmlElementSerializingContext +{ +public: + CXmlDomainSerializingContext(string& strError, bool bWithSettings); + + // Settings to be serialized or not + bool withSettings() const; + + // Value interpretation as Real or Raw (usefull for Fixed point parameters) + void setValueSpaceRaw(bool bIsRaw); + bool valueSpaceIsRaw() const; + + // ParameterBlackboard + const CParameterBlackboard* getParameterBlackboard() const; + + // Criteria defintion + void setSelectionCriteriaDefinition(const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition); + const CSelectionCriteriaDefinition* getSelectionCriteriaDefinition() const; + +private: + // Indicate wheter or not to import settings + bool _bWithSettings; + // Value Space + bool _bValueSpaceIsRaw; + // Criteria defintion + const CSelectionCriteriaDefinition* _pSelectionCriteriaDefinition; +}; diff --git a/parameter/XmlElementSerializingContext.cpp b/parameter/XmlElementSerializingContext.cpp new file mode 100644 index 0000000..a5d0f8e --- /dev/null +++ b/parameter/XmlElementSerializingContext.cpp @@ -0,0 +1,65 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "XmlElementSerializingContext.h" +#include <stdlib.h> + +#define base CXmlSerializingContext + +CXmlElementSerializingContext::CXmlElementSerializingContext(string& strError) : base(strError), _pElementLibrary(NULL) +{ +} + +// Init +void CXmlElementSerializingContext::set(const CElementLibrary* pElementLibrary, const string& strXmlFolder, const string& strXmlSchemaFolder) +{ + _pElementLibrary = pElementLibrary; + _strXmlFolder = strXmlFolder; + _strXmlSchemaFolder = strXmlSchemaFolder; +} + +// ElementLibrary +const CElementLibrary* CXmlElementSerializingContext::getElementLibrary() const +{ + return _pElementLibrary; +} + +// XML Folder Path +const string& CXmlElementSerializingContext::getXmlFolder() const +{ + return _strXmlFolder; +} + +// XML Schema Path +const string& CXmlElementSerializingContext::getXmlSchemaPathFolder() const +{ + return _strXmlSchemaFolder; +} + diff --git a/parameter/XmlElementSerializingContext.h b/parameter/XmlElementSerializingContext.h new file mode 100644 index 0000000..16ff5d2 --- /dev/null +++ b/parameter/XmlElementSerializingContext.h @@ -0,0 +1,57 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "XmlSerializingContext.h" + +class CElementLibrary; + +class CXmlElementSerializingContext : public CXmlSerializingContext +{ +public: + CXmlElementSerializingContext(string& strError); + + // Init + void set(const CElementLibrary* pElementLibrary, const string& strXmlFolder, const string& strXmlSchemaFolder); + + // ElementLibrary + const CElementLibrary* getElementLibrary() const; + + // XML File Path + const string& getXmlFolder() const; + + // Schema Path + const string& getXmlSchemaPathFolder() const; +private: + const CElementLibrary* _pElementLibrary; + string _strXmlFolder; + string _strXmlSchemaFolder; +}; diff --git a/parameter/XmlFileIncluderElement.cpp b/parameter/XmlFileIncluderElement.cpp new file mode 100644 index 0000000..4000758 --- /dev/null +++ b/parameter/XmlFileIncluderElement.cpp @@ -0,0 +1,111 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "XmlFileIncluderElement.h" +#include "XmlParser.h" +#include "XmlElementSerializingContext.h" +#include "ElementLibrary.h" +#include <assert.h> + +#define base CKindElement + +CXmlFileIncluderElement::CXmlFileIncluderElement(const string& strName, const string& strKind) : base(strName, strKind) +{ +} + +// From IXmlSink +bool CXmlFileIncluderElement::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) +{ + // Context + CXmlElementSerializingContext& elementSerializingContext = static_cast<CXmlElementSerializingContext&>(serializingContext); + + // Parse included document + string strPath = xmlElement.getAttributeString("Path"); + + // Relative path? + if (strPath[0] != '/') { + + strPath = elementSerializingContext.getXmlFolder() + "/" + strPath; + } + + // Instantiate parser + string strIncludedElementType = getIncludedElementType(); + + CXmlParser parser(strPath, elementSerializingContext.getXmlSchemaPathFolder() + "/" + strIncludedElementType + ".xsd", strIncludedElementType, elementSerializingContext); + + if (!parser.open()) { + + return false; + } + + // Get top level element + CXmlElement childElement; + + parser.getRootElement(childElement); + + // Create child element + CElement* pChild = elementSerializingContext.getElementLibrary()->createElement(childElement); + + if (pChild) { + + // Store created child! + getParent()->addChild(pChild); + } else { + + elementSerializingContext.setError("Unable to create XML element " + childElement.getPath()); + + return false; + } + + if (!parser.parse(pChild)) { + + return false; + } + + // Detach from parent + getParent()->removeChild(this); + + // Self destroy + delete this; + + return true; +} + +// Element type +string CXmlFileIncluderElement::getIncludedElementType() const +{ + string strKind = getKind(); + + int iPosToRemoveFrom = strKind.rfind("Include", -1); + + assert(iPosToRemoveFrom != -1); + + return strKind.substr(0, iPosToRemoveFrom); +} diff --git a/parameter/XmlFileIncluderElement.h b/parameter/XmlFileIncluderElement.h new file mode 100644 index 0000000..5b37a44 --- /dev/null +++ b/parameter/XmlFileIncluderElement.h @@ -0,0 +1,46 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "KindElement.h" + +// Class used to parse <ElementType>Include elements +class CXmlFileIncluderElement : public CKindElement +{ +public: + CXmlFileIncluderElement(const string& strName, const string& strKind); + + // From IXmlSink + virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); +private: + // Element type + string getIncludedElementType() const; +}; diff --git a/parameter/XmlParameterSerializingContext.cpp b/parameter/XmlParameterSerializingContext.cpp new file mode 100644 index 0000000..2139660 --- /dev/null +++ b/parameter/XmlParameterSerializingContext.cpp @@ -0,0 +1,50 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#include "XmlParameterSerializingContext.h" + +#define base CXmlElementSerializingContext + +CXmlParameterSerializingContext::CXmlParameterSerializingContext(string& strError) : base(strError) +{ +} + +// ComponentLibrary +void CXmlParameterSerializingContext::setComponentLibrary(const CComponentLibrary* pComponentLibrary) +{ + _pComponentLibrary = pComponentLibrary; +} + +const CComponentLibrary* CXmlParameterSerializingContext::getComponentLibrary() const +{ + return _pComponentLibrary; +} + + diff --git a/parameter/XmlParameterSerializingContext.h b/parameter/XmlParameterSerializingContext.h new file mode 100644 index 0000000..2e92c0a --- /dev/null +++ b/parameter/XmlParameterSerializingContext.h @@ -0,0 +1,47 @@ +/* <auto_header> + * <FILENAME> + * + * INTEL CONFIDENTIAL + * Copyright © 2011 Intel + * Corporation All Rights Reserved. + * + * The source code contained or described herein and all documents related to + * the source code ("Material") are owned by Intel Corporation or its suppliers + * or licensors. Title to the Material remains with Intel Corporation or its + * suppliers and licensors. The Material contains trade secrets and proprietary + * and confidential information of Intel or its suppliers and licensors. The + * Material is protected by worldwide copyright and trade secret laws and + * treaty provisions. No part of the Material may be used, copied, reproduced, + * modified, published, uploaded, posted, transmitted, distributed, or + * disclosed in any way without Intel’s prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by Intel in writing. + * + * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + * CREATED: 2011-06-01 + * UPDATED: 2011-07-27 + * + * + * </auto_header> + */ +#pragma once + +#include "XmlElementSerializingContext.h" + +class CComponentLibrary; + +class CXmlParameterSerializingContext : public CXmlElementSerializingContext +{ +public: + CXmlParameterSerializingContext(string& strError); + + // ComponentLibrary + void setComponentLibrary(const CComponentLibrary* pComponentLibrary); + const CComponentLibrary* getComponentLibrary() const; +private: + const CComponentLibrary* _pComponentLibrary; +}; diff --git a/parameter/parameter b/parameter/parameter new file mode 100755 index 0000000..837edd0 --- /dev/null +++ b/parameter/parameter @@ -0,0 +1,2 @@ +#! /bin/sh +./remote-process localhost 5000 $* |