summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Boisnard <fredericx.boisnard@intel.com>2013-02-25 15:56:56 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:03:48 +0100
commite42dacdeaf82d63000be61c6f1583a2ab08e0a98 (patch)
treeffbdab1836280ba3e9a979802949edb046f21c04
parent6bc17c03f4b006a411b768fca33269843144542d (diff)
downloadexternal_parameter-framework-e42dacdeaf82d63000be61c6f1583a2ab08e0a98.zip
external_parameter-framework-e42dacdeaf82d63000be61c6f1583a2ab08e0a98.tar.gz
external_parameter-framework-e42dacdeaf82d63000be61c6f1583a2ab08e0a98.tar.bz2
[PFW] Access Configurations directly
BZ: 88357 This patch aims to enable direct access to Configurations without using the main blackboard. 2 additional commands are available: - getConfigurationParameter <domain> <configuration> <param path>: Get value for parameter at given path from configuration. - setConfigurationParameter <domain> <configuration> <param path> <value> Set value for parameter at given path to configuration. Change-Id: I9357ba5141feee558fa3f7c10f62db14406433b6 Signed-off-by: Frédéric Boisnard <fredericx.boisnard@intel.com> Reviewed-on: http://android.intel.com:8080/92325 Reviewed-by: cactus <cactus@intel.com> Reviewed-by: Gonzalve, Sebastien <sebastien.gonzalve@intel.com> Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
-rw-r--r--parameter/AreaConfiguration.cpp10
-rw-r--r--parameter/AreaConfiguration.h4
-rw-r--r--parameter/ConfigurableDomain.cpp60
-rw-r--r--parameter/ConfigurableDomain.h9
-rw-r--r--parameter/ConfigurableDomains.cpp32
-rw-r--r--parameter/ConfigurableDomains.h8
-rw-r--r--parameter/DomainConfiguration.cpp31
-rw-r--r--parameter/DomainConfiguration.h4
-rw-r--r--parameter/ParameterMgr.cpp103
-rw-r--r--parameter/ParameterMgr.h7
10 files changed, 257 insertions, 11 deletions
diff --git a/parameter/AreaConfiguration.cpp b/parameter/AreaConfiguration.cpp
index a9519a6..6d6c50d 100644
--- a/parameter/AreaConfiguration.cpp
+++ b/parameter/AreaConfiguration.cpp
@@ -160,6 +160,16 @@ uint32_t CAreaConfiguration::getSize() const
return _blackboard.getSize();
}
+CParameterBlackboard& CAreaConfiguration::getBlackboard()
+{
+ return _blackboard;
+}
+
+const CParameterBlackboard& CAreaConfiguration::getBlackboard() const
+{
+ return _blackboard;
+}
+
// Store validity
void CAreaConfiguration::setValid(bool bValid)
{
diff --git a/parameter/AreaConfiguration.h b/parameter/AreaConfiguration.h
index 46d9e3d..bcf2229 100644
--- a/parameter/AreaConfiguration.h
+++ b/parameter/AreaConfiguration.h
@@ -72,6 +72,10 @@ public:
// Data size
uint32_t getSize() const;
+ // Fetch the Configuration Blackboard
+ CParameterBlackboard& getBlackboard();
+ const CParameterBlackboard& getBlackboard() const;
+
protected:
CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet, uint32_t uiSize);
diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp
index 6d1c19c..8a497fd 100644
--- a/parameter/ConfigurableDomain.cpp
+++ b/parameter/ConfigurableDomain.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* INTEL CONFIDENTIAL
* Copyright © 2011 Intel
* Corporation All Rights Reserved.
@@ -372,6 +372,64 @@ bool CConfigurableDomain::removeConfigurableElement(CConfigurableElement* pConfi
return true;
}
+/**
+* Blackboard Configuration and Base Offset retrieval.
+*
+* This method fetches the Blackboard associated to the ConfigurableElement
+* given in parameter, for a specific Configuration. The ConfigurableElement
+* must belong to the Domain. If a Blackboard is found, the base offset of
+* the ConfigurableElement is returned as well. This base offset corresponds to
+* the offset of the ancestor of the ConfigurableElement associated to the Configuration.
+*
+* @param[in] strConfiguration Name of the Configuration.
+* @param[in] pCandidateDescendantConfigurableElement Pointer to a CConfigurableElement that
+* belongs to the Domain.
+* @param[out] uiBaseOffset The base offset of the CConfigurableElement.
+* @param[out] bIsLastApplied Boolean indicating that the Configuration is
+* the last one applied of the Domain.
+* @param[out] strError Error message
+*
+* return Pointer to the Blackboard of the Configuration.
+*/
+CParameterBlackboard* CConfigurableDomain::findConfigurationBlackboard(const string& strConfiguration,
+ const CConfigurableElement* pCandidateDescendantConfigurableElement,
+ uint32_t& uiBaseOffset,
+ bool& bIsLastApplied,
+ string& strError) const
+{
+ // Find Configuration
+ const CDomainConfiguration* pDomainConfiguration = static_cast<const CDomainConfiguration*>(findChild(strConfiguration));
+
+ if (!pDomainConfiguration) {
+
+ strError = "Domain configuration " + strConfiguration + " not found";
+
+ return NULL;
+ }
+
+ // Parse all configurable elements
+ ConfigurableElementListIterator it;
+
+ for (it = _configurableElementList.begin(); it != _configurableElementList.end(); ++it) {
+
+ const CConfigurableElement* pAssociatedConfigurableElement = *it;
+
+ // Check if the the associated element is the configurable element or one of its ancestors
+ if ((pCandidateDescendantConfigurableElement == pAssociatedConfigurableElement) ||
+ (pCandidateDescendantConfigurableElement->isDescendantOf(pAssociatedConfigurableElement))) {
+
+ uiBaseOffset = pAssociatedConfigurableElement->getOffset();
+ bIsLastApplied = (pDomainConfiguration == _pLastAppliedConfiguration);
+
+ return pDomainConfiguration->getBlackboard(pAssociatedConfigurableElement);
+ }
+ }
+
+ strError = "Element not associated to the Domain";
+
+ return NULL;
+}
+
// Domain splitting
bool CConfigurableDomain::split(CConfigurableElement* pConfigurableElement, string& strError)
{
diff --git a/parameter/ConfigurableDomain.h b/parameter/ConfigurableDomain.h
index ad0cc33..ddad2d2 100644
--- a/parameter/ConfigurableDomain.h
+++ b/parameter/ConfigurableDomain.h
@@ -1,4 +1,4 @@
-/*
+/*
* INTEL CONFIDENTIAL
* Copyright © 2011 Intel
* Corporation All Rights Reserved.
@@ -73,6 +73,13 @@ public:
bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError);
+ // Blackboard Configuration and Base Offset retrieval
+ CParameterBlackboard* findConfigurationBlackboard(const string& strConfiguration,
+ const CConfigurableElement* pConfigurableElement,
+ uint32_t& uiBaseOffset,
+ bool& bIsLastApplied,
+ string& strError) const;
+
// Domain splitting
bool split(CConfigurableElement* pConfigurableElement, string& strError);
diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp
index fcfeb4d..bd5c3c5 100644
--- a/parameter/ConfigurableDomains.cpp
+++ b/parameter/ConfigurableDomains.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* INTEL CONFIDENTIAL
* Copyright © 2011 Intel
* Corporation All Rights Reserved.
@@ -503,6 +503,36 @@ bool CConfigurableDomains::removeConfigurableElementFromDomain(const string& str
return pConfigurableDomain->removeConfigurableElement(pConfigurableElement, strError);
}
+CParameterBlackboard* CConfigurableDomains::findConfigurationBlackboard(const string& strDomain,
+ const string& strConfiguration,
+ const CConfigurableElement* pConfigurableElement,
+ uint32_t& uiBaseOffset,
+ bool& bIsLastApplied,
+ string& strError) const
+{
+ log_info("Find configuration blackboard for Domain:%s, Configuration:%s, Element:%s",
+ strDomain.c_str(), strConfiguration.c_str(), pConfigurableElement->getPath().c_str());
+
+ // Find domain
+ const CConfigurableDomain* pConfigurableDomain = findConfigurableDomain(strDomain, strError);
+
+ if (!pConfigurableDomain) {
+
+ return NULL;
+ }
+
+ // Check that element belongs to the domain
+ if (!pConfigurableElement->belongsTo(pConfigurableDomain)) {
+
+ strError = "Element \"" + pConfigurableElement->getPath() + "\" does not belong to domain \"" + strDomain + "\"";
+
+ return NULL;
+ }
+
+ // Find Configuration Blackboard and Base Offset
+ return pConfigurableDomain->findConfigurationBlackboard(strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
+}
+
// Binary settings load/store
bool CConfigurableDomains::serializeSettings(const string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, string& strError)
{
diff --git a/parameter/ConfigurableDomains.h b/parameter/ConfigurableDomains.h
index af98c52..42a2e35 100644
--- a/parameter/ConfigurableDomains.h
+++ b/parameter/ConfigurableDomains.h
@@ -73,6 +73,14 @@ public:
bool addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
bool removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError);
+ // Configuration Blackboard for element
+ CParameterBlackboard* findConfigurationBlackboard(const string& strDomain,
+ const string& strConfiguration,
+ const CConfigurableElement* pConfigurableElement,
+ uint32_t& uiBaseOffset,
+ bool& bIsLastApplied,
+ string& strError) const;
+
// Binary settings load/store
bool serializeSettings(const string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, string& strError);
diff --git a/parameter/DomainConfiguration.cpp b/parameter/DomainConfiguration.cpp
index 1aa3e0d..ec6e186 100644
--- a/parameter/DomainConfiguration.cpp
+++ b/parameter/DomainConfiguration.cpp
@@ -318,6 +318,37 @@ void CDomainConfiguration::getApplicationRule(string& strResult) const
}
}
+/**
+ * Get the Configuration Blackboard.
+ *
+ * Fetch the Configuration Blackboard related to the ConfigurableElement given in parameter. This
+ * Element is used to retrieve the correct AreaConfiguration where the Blackboard is stored.
+ *
+ * @param[in] pConfigurableElement A pointer to a ConfigurableElement that is part of the
+ * Domain. This must have been checked previously, as an
+ * assertion is performed.
+ *
+ * return Pointer to the Blackboard of the Configuration.
+ */
+CParameterBlackboard* CDomainConfiguration::getBlackboard(const CConfigurableElement* pConfigurableElement) const
+{
+ AreaConfigurationListIterator it;
+
+ for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) {
+
+ CAreaConfiguration* pAreaConfiguration = *it;
+
+ // Check if the Element is associated with the Domain
+ if (pAreaConfiguration->getConfigurableElement() == pConfigurableElement) {
+
+ return &pAreaConfiguration->getBlackboard();
+ }
+ }
+
+ assert(0);
+ return NULL;
+}
+
// Save data from current
void CDomainConfiguration::save(const CParameterBlackboard* pMainBlackboard)
{
diff --git a/parameter/DomainConfiguration.h b/parameter/DomainConfiguration.h
index a4e2aad..a87c75c 100644
--- a/parameter/DomainConfiguration.h
+++ b/parameter/DomainConfiguration.h
@@ -58,6 +58,9 @@ public:
void clearApplicationRule();
void getApplicationRule(string& strResult) const;
+ // Get Blackboard for an element of the domain
+ CParameterBlackboard* getBlackboard(const CConfigurableElement* pConfigurableElement) const;
+
// Save data from current
void save(const CParameterBlackboard* pMainBlackboard);
// Apply data to current
@@ -91,6 +94,7 @@ public:
// 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;
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index b5b9683..e8ab863 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -42,7 +42,6 @@
#include "FixedPointParameterType.h"
#include "ParameterBlackboard.h"
#include "Parameter.h"
-#include "ParameterBlackboard.h"
#include "ParameterAccessContext.h"
#include "XmlFileIncluderElement.h"
#include "ParameterFrameworkConfiguration.h"
@@ -160,6 +159,8 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa
{ "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
{ "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
{ "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
+ { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3, "<domain> <configuration> <param path>", "Get value for parameter at given path from configuration" },
+ { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4, "<domain> <configuration> <param path> <value>", "Set value for parameter at given path to configuration" },
/// 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" },
@@ -1150,7 +1151,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommman
{
string strValue;
- if (!accessValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
+ if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
return CCommandHandler::EFailed;
}
@@ -1170,7 +1171,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommman
// Get value to set
string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
- return accessValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
+ return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
}
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
@@ -1240,6 +1241,35 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCo
return CCommandHandler::ESucceeded;
}
+CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
+{
+ string strOutputValue;
+ string strError;
+
+ if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
+
+ strResult = strError;
+ return CCommandHandler::EFailed;
+ }
+ // Succeeded
+ strResult = strOutputValue;
+
+ return CCommandHandler::ESucceeded;
+}
+
+CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
+{
+ // Get value to set
+ string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
+
+ bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
+ remoteCommand.getArgument(1),
+ remoteCommand.getArgument(2),
+ strValue, true, strResult);
+
+ return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
+}
+
/// Settings Import/Export
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
{
@@ -1297,8 +1327,70 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSystemClassXMLCo
return CCommandHandler::ESucceeded;
}
+// User set/get parameters in main BlackBoard
+bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
+{
+ // Define context
+ CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
+
+ return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
+}
+
+// User set/get parameters in specific Configuration BlackBoard
+bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
+{
+ CElementLocator elementLocator(getSystemClass());
+
+ CElement* pLocatedElement = NULL;
+
+ if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
+
+ return false;
+ }
+
+ // Convert element
+ const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
+
+ // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
+ uint32_t uiBaseOffset;
+ bool bIsLastApplied;
+
+ CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
+
+ if (!pConfigurationBlackboard) {
+
+ return false;
+ }
+
+ log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
+
+ /// Update the Configuration Blackboard
+
+ // Define Configuration context using Base Offset
+ CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
+
+ // Access Value in the Configuration Blackboard
+ if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
+
+ return false;
+ }
+
+ /// If the Configuration is the last one applied, update the Main Blackboard as well
+
+ if (bIsLastApplied) {
+
+ // Define Main context
+ parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
+
+ // Access Value in the Main Blackboard
+ return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
+ }
+
+ return true;
+}
+
// User set/get parameters
-bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bSet, string& strError)
+bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
{
// Lock state
CAutoLock autoLock(&_blackboardMutex);
@@ -1311,9 +1403,6 @@ bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bS
return false;
}
- // Define context
- CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
-
// Auto Sync
if (bSet) {
diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h
index 44f3d41..fa12128 100644
--- a/parameter/ParameterMgr.h
+++ b/parameter/ParameterMgr.h
@@ -49,6 +49,7 @@ class IRemoteProcessorServerInterface;
class CBackSynchronizer;
class CParameterHandle;
class CSubsystemPlugins;
+class CParameterAccessContext;
class CParameterMgr : private CElement
{
@@ -135,7 +136,9 @@ public:
bool sync(string& strError);
// User set/get parameters
- bool accessValue(const string& strPath, string& strValue, bool bSet, string& strError);
+ bool accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError);
+ bool accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError);
+ bool accessConfigurationValue(const string &strDomain, const string &stConfiguration, const string& strPath, string& strValue, bool bSet, string& strError);
////////// Configuration/Domains handling //////////////
// Creation/Deletion
@@ -237,6 +240,8 @@ private:
CCommandHandler::CommandStatus showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
CCommandHandler::CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
CCommandHandler::CommandStatus setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
+ CCommandHandler::CommandStatus getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
+ CCommandHandler::CommandStatus setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
CCommandHandler::CommandStatus listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
CCommandHandler::CommandStatus listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
/// Browse