summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2011-11-07 20:01:02 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:14:59 +0100
commit99041c5b5ed90dd66c65fa1903a74f5f3f9a8fdc (patch)
tree0cfd397ffc37b512c0dc155083e25202382b3420
parent082dd4728914bae6d6cb70e74c8cffa5155082a3 (diff)
downloadexternal_parameter-framework-99041c5b5ed90dd66c65fa1903a74f5f3f9a8fdc.zip
external_parameter-framework-99041c5b5ed90dd66c65fa1903a74f5f3f9a8fdc.tar.gz
external_parameter-framework-99041c5b5ed90dd66c65fa1903a74f5f3f9a8fdc.tar.bz2
PFW: parameter access code reuse
BZ: 13283 Path navigator embeds a navigate and validate functionality that spares parameter manager from replicating code between get and set parameter contexts. Change-Id: Ic7c950660cd8c22b233ce02238fa1a66649a501b Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com> Reviewed-on: http://android.intel.com:8080/25403 Reviewed-by: Barthes, FabienX <fabienx.barthes@intel.com> Tested-by: Barthes, FabienX <fabienx.barthes@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
-rw-r--r--parameter/ParameterAccessContext.h2
-rw-r--r--parameter/ParameterMgr.cpp44
-rw-r--r--parameter/PathNavigator.cpp29
-rw-r--r--parameter/PathNavigator.h6
4 files changed, 41 insertions, 40 deletions
diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h
index af6f1b7..11c0fdc 100644
--- a/parameter/ParameterAccessContext.h
+++ b/parameter/ParameterAccessContext.h
@@ -37,7 +37,7 @@ class CParameterBlackboard;
class CParameterAccessContext : public CErrorContext
{
public:
- CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex);
+ CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex = false);
CParameterAccessContext(string& strError);
// ParameterBlackboard
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 83867d5..61e204a 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -1652,31 +1652,14 @@ bool CParameterMgr::doSetValue(const string& strPath, const string& strValue, bo
{
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";
+ // Nagivate through system class
+ if (!pathNavigator.navigateThrough(getSystemClass()->getName(), strError)) {
return false;
}
// Define context
- CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, false);
+ CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace);
// Set auto sync
parameterAccessContext.setAutoSync(_bAutoSyncOn);
@@ -1692,25 +1675,8 @@ bool CParameterMgr::doGetValue(const string& strPath, string& strValue, bool bRa
{
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";
+ // Nagivate through system class
+ if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
return false;
}
diff --git a/parameter/PathNavigator.cpp b/parameter/PathNavigator.cpp
index 1911002..cb6bec3 100644
--- a/parameter/PathNavigator.cpp
+++ b/parameter/PathNavigator.cpp
@@ -50,6 +50,35 @@ bool CPathNavigator::isPathValid() const
return _bValid;
}
+// Navigate through
+bool CPathNavigator::navigateThrough(const string& strItemName, string& strError)
+{
+ if (!_bValid) {
+
+ strError = "Path not well formed";
+
+ return false;
+ }
+
+ string* pStrChildName = next();
+
+ if (!pStrChildName) {
+
+ strError = "Path not complete";
+
+ return false;
+ }
+
+ if (*pStrChildName != strItemName) {
+
+ strError = "Path not found";
+
+ return false;
+ }
+
+ return true;
+}
+
string* CPathNavigator::next()
{
if (_uiCurrentIndex < _astrItems.size()) {
diff --git a/parameter/PathNavigator.h b/parameter/PathNavigator.h
index ae3a901..c7f637a 100644
--- a/parameter/PathNavigator.h
+++ b/parameter/PathNavigator.h
@@ -41,10 +41,16 @@ class CPathNavigator
public:
CPathNavigator(const string& strPath);
+ // Path validity
bool isPathValid() const;
+ // Navigate through
+ bool navigateThrough(const string& strItemName, string& strError);
+
+ // Nagivate
string* next();
+ // Current path
string getCurrentPath() const;
private: