diff options
author | Patrick Benavoli <patrickx.benavoli@intel.com> | 2011-09-13 14:15:52 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-10 17:14:55 +0100 |
commit | b71ccf75a1b2c718543783b277bb9c104c97e490 (patch) | |
tree | acf3c45915424b371bd7ed692c896b695005e45c | |
parent | a364ba000fb5eafe901b0b5e11c2b0f39d60f1bd (diff) | |
download | external_parameter-framework-b71ccf75a1b2c718543783b277bb9c104c97e490.zip external_parameter-framework-b71ccf75a1b2c718543783b277bb9c104c97e490.tar.gz external_parameter-framework-b71ccf75a1b2c718543783b277bb9c104c97e490.tar.bz2 |
parameter-framework: Changed criterion interface
BZ: 9561
- separated selection criterion change event indication form configuration application requests in different APIs
- added a way to retrieve selection criterion from its name
- updated version number 0.2.1
Change-Id: Icf4560fe67001655a171401f106296b9aa09afb3
Orig-Change-Id: I8dfb05ba1e704888c5c1ff9268a2a2e9a46af9bb
Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com>
Reviewed-on: http://android.intel.com:8080/20208
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-connector-test/ExamplePlatform.cpp | 21 | ||||
-rw-r--r-- | parameter-connector-test/ExamplePlatform.h | 2 | ||||
-rw-r--r-- | parameter/ParameterMgr.cpp | 20 | ||||
-rw-r--r-- | parameter/ParameterMgr.h | 13 | ||||
-rw-r--r-- | parameter/ParameterMgrPlatformConnector.cpp | 23 | ||||
-rw-r--r-- | parameter/ParameterMgrPlatformConnector.h | 5 | ||||
-rw-r--r-- | parameter/SelectionCriteria.cpp | 7 | ||||
-rw-r--r-- | parameter/SelectionCriteria.h | 5 | ||||
-rw-r--r-- | parameter/SelectionCriteriaDefinition.cpp | 14 | ||||
-rw-r--r-- | parameter/SelectionCriteriaDefinition.h | 4 | ||||
-rw-r--r-- | parameter/SelectionCriterion.cpp | 19 | ||||
-rw-r--r-- | parameter/SelectionCriterion.h | 8 | ||||
-rw-r--r-- | parameter/SelectionCriterionInterface.h | 2 | ||||
-rw-r--r-- | parameter/SelectionCriterionObserver.h | 39 |
14 files changed, 73 insertions, 109 deletions
diff --git a/parameter-connector-test/ExamplePlatform.cpp b/parameter-connector-test/ExamplePlatform.cpp index 0e51cfb..5d60880 100644 --- a/parameter-connector-test/ExamplePlatform.cpp +++ b/parameter-connector-test/ExamplePlatform.cpp @@ -80,9 +80,6 @@ CExamplePlatform::CExamplePlatform(const string& strClass) : _pParameterMgrPlatf _pMode = _pParameterMgrPlatformConnector->createSelectionCriterion("Mode", _pModeType); _pSelectedInputDevice = _pParameterMgrPlatformConnector->createSelectionCriterion("SelectedInputDevice", _pInputDeviceType); _pSelectedOutputDevice = _pParameterMgrPlatformConnector->createSelectionCriterion("SelectedOutputDevice", _pOutputDeviceType); - - // Init state - setState(EInitState); } CExamplePlatform::~CExamplePlatform() @@ -94,21 +91,26 @@ CExamplePlatform::~CExamplePlatform() // Start bool CExamplePlatform::start(string& strError) { - return _pParameterMgrPlatformConnector->start(strError); + if (!_pParameterMgrPlatformConnector->start(strError)) { + + return false; + } + // Init state + return setState(EInitState, strError); } // State -void CExamplePlatform::setState(CExamplePlatform::State eState) +bool CExamplePlatform::setState(CExamplePlatform::State eState, string& strError) { switch(eState) { case EInitState: - _pMode->setCriterionState(0, false); - _pSelectedInputDevice->setCriterionState(0, false); + _pMode->setCriterionState(0); + _pSelectedInputDevice->setCriterionState(0); _pSelectedOutputDevice->setCriterionState(0x4); break; case EState1: - _pMode->setCriterionState(0, false); - _pSelectedInputDevice->setCriterionState(0, false); + _pMode->setCriterionState(0); + _pSelectedInputDevice->setCriterionState(0); // Select Headset _pSelectedOutputDevice->setCriterionState(0x1); break; @@ -119,5 +121,6 @@ void CExamplePlatform::setState(CExamplePlatform::State eState) default: break; } + return _pParameterMgrPlatformConnector->applyConfigurations(strError); } diff --git a/parameter-connector-test/ExamplePlatform.h b/parameter-connector-test/ExamplePlatform.h index bf821e8..1249c7f 100644 --- a/parameter-connector-test/ExamplePlatform.h +++ b/parameter-connector-test/ExamplePlatform.h @@ -58,7 +58,7 @@ public: bool start(string& strError); // State - void setState(State eState); + bool setState(State eState, string& strError); private: // The connector diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index a8335c8..329ab37 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -305,9 +305,6 @@ bool CParameterMgr::load(string& strError) return false; } - // All is loaded, we're ready to observe selection criteria change events - getSelectionCriteria()->setObserver(this); - // Start remote processor server if appropriate return handleRemoteProcessingInterface(strError); } @@ -554,10 +551,17 @@ CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strNa return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType); } +// Selection criterion retrieval +CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName) +{ + // Propagate + return getSelectionCriteria()->getSelectionCriterion(strName); +} + // Selection criteria changed event -void CParameterMgr::selectionCriterionChanged(const CSelectionCriterion* pSelectionCriterion) +bool CParameterMgr::applyConfigurations(string& strError) { - CAutoLog autoLog(this, "Selection criterion changed event: " + pSelectionCriterion->getFormattedDescription(false)); + CAutoLog autoLog(this, "Configuration application request"); // Lock state CAutoLock autoLock(&_tuningModeMutex); @@ -565,13 +569,15 @@ void CParameterMgr::selectionCriterionChanged(const CSelectionCriterion* pSelect if (!_bTuningModeIsOn) { // Apply configuration(s) - string strError; - if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) { log("Failed to apply configurations!"); + + return false; } } + + return true; } // Command processing diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 74440f8..4596843 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -36,7 +36,6 @@ #include "SelectionCriterionType.h" #include "SelectionCriterion.h" #include "Element.h" -#include "SelectionCriterionObserver.h" #include <map> #include <vector> @@ -52,7 +51,7 @@ class CConfigurableDomains; class IRemoteProcessorServerInterface; class CBackSynchronizer; -class CParameterMgr : private CElement, private IRemoteCommandHandler, private ISelectionCriterionObserver +class CParameterMgr : private CElement, private IRemoteCommandHandler { enum ChildElement { EFrameworkConfiguration, @@ -94,7 +93,7 @@ class CParameterMgr : private CElement, private IRemoteCommandHandler, private I // Version static const uint32_t guiEditionMajor = 0x0; - static const uint32_t guiEditionMinor = 0x1; + static const uint32_t guiEditionMinor = 0x2; static const uint32_t guiRevision = 0x1; public: // Logger interface @@ -118,6 +117,11 @@ public: // Selection Criteria CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); + // Selection criterion retrieval + CSelectionCriterion* getSelectionCriterion(const string& strName); + + // Configuration application + bool applyConfigurations(string& strError); //////////// Tuning ///////////// // Tuning mode @@ -176,9 +180,6 @@ private: 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); diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index 9da41dd..7f570c5 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -54,6 +54,7 @@ CParameterMgrPlatformConnector::~CParameterMgrPlatformConnector() delete _pParameterMgrLogger; } +// Selection Criteria interface. Beware returned objects are lent, clients shall not delete them! ISelectionCriterionTypeInterface* CParameterMgrPlatformConnector::createSelectionCriterionType(bool bIsInclusive) { assert(!_bStarted); @@ -61,13 +62,27 @@ ISelectionCriterionTypeInterface* CParameterMgrPlatformConnector::createSelectio return _pParameterMgr->createSelectionCriterionType(bIsInclusive); } -ISelectionCriterionInterface* CParameterMgrPlatformConnector::createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType) +ISelectionCriterionInterface* CParameterMgrPlatformConnector::createSelectionCriterion(const string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType) { assert(!_bStarted); return _pParameterMgr->createSelectionCriterion(strName, static_cast<const CSelectionCriterionType*>(pSelectionCriterionType)); } +// Selection criterion retrieval +ISelectionCriterionInterface* CParameterMgrPlatformConnector::getSelectionCriterion(const string& strName) +{ + return _pParameterMgr->getSelectionCriterion(strName); +} + +// Configuration application +bool CParameterMgrPlatformConnector::applyConfigurations(string& strError) +{ + assert(_bStarted); + + return _pParameterMgr->applyConfigurations(strError); +} + // Logging void CParameterMgrPlatformConnector::setLogger(CParameterMgrPlatformConnector::ILogger* pLogger) { @@ -75,7 +90,7 @@ void CParameterMgrPlatformConnector::setLogger(CParameterMgrPlatformConnector::I } // Start -bool CParameterMgrPlatformConnector::start(std::string& strError) +bool CParameterMgrPlatformConnector::start(string& strError) { // Create data structure if (!_pParameterMgr->load(strError)) { @@ -88,11 +103,13 @@ bool CParameterMgrPlatformConnector::start(std::string& strError) return false; } + _bStarted = true; + return true; } // Private logging -void CParameterMgrPlatformConnector::doLog(const std::string& strLog) +void CParameterMgrPlatformConnector::doLog(const string& strLog) { if (_pLogger) { diff --git a/parameter/ParameterMgrPlatformConnector.h b/parameter/ParameterMgrPlatformConnector.h index 91679b7..91fa1b2 100644 --- a/parameter/ParameterMgrPlatformConnector.h +++ b/parameter/ParameterMgrPlatformConnector.h @@ -46,6 +46,11 @@ public: // Should be called before start ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive = false); ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType); + // Selection criterion retrieval + ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName); + + // Configuration application + bool applyConfigurations(std::string& strError); // Logging // Should be called before start diff --git a/parameter/SelectionCriteria.cpp b/parameter/SelectionCriteria.cpp index 9377e31..d0b5766 100644 --- a/parameter/SelectionCriteria.cpp +++ b/parameter/SelectionCriteria.cpp @@ -56,11 +56,10 @@ CSelectionCriterion* CSelectionCriteria::createSelectionCriterion(const string& return getSelectionCriteriaDefinition()->createSelectionCriterion(strName, pSelectionCriterionType); } -// Subscription -void CSelectionCriteria::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) +// Selection criterion retrieval +CSelectionCriterion* CSelectionCriteria::getSelectionCriterion(const string& strName) { - // Delegate - getSelectionCriteriaDefinition()->setObserver(pSelectionCriterionObserver); + return getSelectionCriteriaDefinition()->getSelectionCriterion(strName); } // List available criteria diff --git a/parameter/SelectionCriteria.h b/parameter/SelectionCriteria.h index 4751d59..37e4d65 100644 --- a/parameter/SelectionCriteria.h +++ b/parameter/SelectionCriteria.h @@ -50,13 +50,12 @@ public: // Selection Criteria/Type creation CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); + // Selection criterion retrieval + CSelectionCriterion* getSelectionCriterion(const string& strName); // Selection Criterion definition const CSelectionCriteriaDefinition* getSelectionCriteriaDefinition() const; - // Subscription - void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); - // List available criteria void listSelectionCriteria(string& strResult, bool bWithTypeInfo) const; diff --git a/parameter/SelectionCriteriaDefinition.cpp b/parameter/SelectionCriteriaDefinition.cpp index e23f326..5a9855a 100644 --- a/parameter/SelectionCriteriaDefinition.cpp +++ b/parameter/SelectionCriteriaDefinition.cpp @@ -56,19 +56,9 @@ const CSelectionCriterion* CSelectionCriteriaDefinition::getSelectionCriterion(c return static_cast<const CSelectionCriterion*>(findChild(strName)); } -// Subscription -void CSelectionCriteriaDefinition::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) +CSelectionCriterion* CSelectionCriteriaDefinition::getSelectionCriterion(const string& strName) { - // Propagate - uint32_t uiNbChildren = getNbChildren(); - uint32_t uiChild; - - for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { - - CSelectionCriterion* pSelectionCriterion = static_cast<CSelectionCriterion*>(getChild(uiChild)); - - pSelectionCriterion->setObserver(pSelectionCriterionObserver); - } + return static_cast<CSelectionCriterion*>(findChild(strName)); } // List available criteria diff --git a/parameter/SelectionCriteriaDefinition.h b/parameter/SelectionCriteriaDefinition.h index e8487b5..a496e9b 100644 --- a/parameter/SelectionCriteriaDefinition.h +++ b/parameter/SelectionCriteriaDefinition.h @@ -45,9 +45,7 @@ public: // Selection Criterion access const CSelectionCriterion* getSelectionCriterion(const string& strName) const; - - // Subscription - void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); + CSelectionCriterion* getSelectionCriterion(const string& strName); // List available criteria void listSelectionCriteria(string& strResult, bool bWithTypeInfo) const; diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp index 9640b3b..d3e561b 100644 --- a/parameter/SelectionCriterion.cpp +++ b/parameter/SelectionCriterion.cpp @@ -29,10 +29,11 @@ * </auto_header> */ #include "SelectionCriterion.h" +#include "AutoLog.h" #define base CElement -CSelectionCriterion::CSelectionCriterion(const string& strName, const CSelectionCriterionType* pType) : base(strName), _iState(0), _pType(pType), _pObserver(NULL) +CSelectionCriterion::CSelectionCriterion(const string& strName, const CSelectionCriterionType* pType) : base(strName), _iState(0), _pType(pType) { } @@ -43,18 +44,14 @@ string CSelectionCriterion::getKind() const /// From ISelectionCriterionInterface // State -void CSelectionCriterion::setCriterionState(int iState, bool bUpdate) +void CSelectionCriterion::setCriterionState(int iState) { // Check for a change if (_iState != iState) { - _iState = iState; - - // Update if required - if (bUpdate && _pObserver) { + CAutoLog autoLog(this, "Selection criterion changed event: " + getFormattedDescription(false)); - _pObserver->selectionCriterionChanged(this); - } + _iState = iState; } } @@ -75,12 +72,6 @@ const ISelectionCriterionTypeInterface* CSelectionCriterion::getCriterionType() return _pType; } -/// Observer -void CSelectionCriterion::setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver) -{ - _pObserver = pSelectionCriterionObserver; -} - /// Match methods bool CSelectionCriterion::is(int iState) const { diff --git a/parameter/SelectionCriterion.h b/parameter/SelectionCriterion.h index e7b44fe..53e2b17 100644 --- a/parameter/SelectionCriterion.h +++ b/parameter/SelectionCriterion.h @@ -32,7 +32,6 @@ #include "Element.h" #include "SelectionCriterionType.h" -#include "SelectionCriterionObserver.h" #include "SelectionCriterionInterface.h" #include <list> @@ -46,16 +45,13 @@ public: /// From ISelectionCriterionInterface // State - virtual void setCriterionState(int iState, bool bUpdate); + virtual void setCriterionState(int iState); virtual int getCriterionState() const; // Name virtual string getCriterionName() const; // Type virtual const ISelectionCriterionTypeInterface* getCriterionType() const; - /// Subscription - void setObserver(ISelectionCriterionObserver* pSelectionCriterionObserver); - /// Match methods bool is(int iState) const; bool isNot(int iState) const; @@ -72,7 +68,5 @@ private: int _iState; // Type const CSelectionCriterionType* _pType; - // Observer - ISelectionCriterionObserver* _pObserver; }; diff --git a/parameter/SelectionCriterionInterface.h b/parameter/SelectionCriterionInterface.h index 134de01..9162486 100644 --- a/parameter/SelectionCriterionInterface.h +++ b/parameter/SelectionCriterionInterface.h @@ -28,7 +28,7 @@ class ISelectionCriterionInterface { public: - virtual void setCriterionState(int iState, bool bUpdate = true) = 0; + virtual void setCriterionState(int iState) = 0; virtual int getCriterionState() const = 0; virtual std::string getCriterionName() const = 0; virtual const ISelectionCriterionTypeInterface* getCriterionType() const = 0; diff --git a/parameter/SelectionCriterionObserver.h b/parameter/SelectionCriterionObserver.h deleted file mode 100644 index fd0ec7d..0000000 --- a/parameter/SelectionCriterionObserver.h +++ /dev/null @@ -1,39 +0,0 @@ -/* <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; -}; |