From 620e27fd41f150e1a5d2dfa5195ff68c8caee13e Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Wed, 11 Mar 2015 14:11:21 +0100 Subject: [PATCH 1/4] Remove init function member from Element init function is defined in Element god class but is used only for plugins initialization after structure and settings loading. This patch delegate Subsystem initialization to SystemClass which is the direct parent. Signed-off-by: Jules Clero --- parameter/Element.cpp | 17 ----------------- parameter/Element.h | 2 -- parameter/ParameterMgr.cpp | 9 +-------- parameter/ParameterMgr.h | 3 --- parameter/Subsystem.cpp | 6 ++++++ parameter/Subsystem.h | 8 ++++++++ parameter/SystemClass.cpp | 17 +++++++++++++++++ parameter/SystemClass.h | 7 +++++++ 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/parameter/Element.cpp b/parameter/Element.cpp index eb8e6d519..e446fbeba 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -64,23 +64,6 @@ bool CElement::childrenAreDynamic() const 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; diff --git a/parameter/Element.h b/parameter/Element.h index b3fe4bed4..dd57584c8 100644 --- a/parameter/Element.h +++ b/parameter/Element.h @@ -57,8 +57,6 @@ class CElement : public IXmlSink, public IXmlSource std::string getPath() const; std::string getQualifiedPath() const; - // Creation / build - virtual bool init(std::string& strError); virtual void clean(); // Children management diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index cf440780c..f8b9f8463 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -440,8 +440,7 @@ bool CParameterMgr::load(string& strError) return false; } - // Init flow of element tree - if (!init(strError)) { + if (!getSystemClass()->initSubsystems(strError)) { return false; } @@ -746,12 +745,6 @@ bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingCo return true; } -// Init -bool CParameterMgr::init(string& strError) -{ - return base::init(strError); -} - // Selection criteria interface CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) { diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 1e0f895fc..c4e196121 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -358,9 +358,6 @@ class CParameterMgr : private CElement CParameterMgr(const CParameterMgr&); CParameterMgr& operator=(const CParameterMgr&); - // Init - virtual bool init(std::string& strError); - // Version std::string getVersion() const; diff --git a/parameter/Subsystem.cpp b/parameter/Subsystem.cpp index fc9f39fef..4b085e0a5 100644 --- a/parameter/Subsystem.cpp +++ b/parameter/Subsystem.cpp @@ -532,3 +532,9 @@ void CSubsystem::mapEnd() // Unstack context _contextStack.pop(); } + +bool CSubsystem::init(string&) +{ + // Default implementation + return true; +} diff --git a/parameter/Subsystem.h b/parameter/Subsystem.h index 2943ff816..55d06e9a4 100644 --- a/parameter/Subsystem.h +++ b/parameter/Subsystem.h @@ -98,6 +98,14 @@ class CSubsystem : public CConfigurableElementWithMapping, private IMapper */ virtual std::string getMapping(std::list& configurableElementPath) const; + /** Subsystem init function. + * This function will be launched after structure loading. + * + * @param[out] error, error encountered during initialization + * @return true if succeed, false otherwise + */ + virtual bool init(std::string& error); + protected: // Parameter access virtual bool accessValue(CPathNavigator& pathNavigator, std::string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index e98fd5045..51709b7f4 100644 --- a/parameter/SystemClass.cpp +++ b/parameter/SystemClass.cpp @@ -301,3 +301,20 @@ void CSystemClass::cleanSubsystemsNeedToResync() pSubsystem->needResync(true); } } + +bool CSystemClass::initSubsystems(std::string& error) +{ + uint32_t uiNbChildren = getNbChildren(); + uint32_t uiChild; + + for (uiChild = 0; uiChild < uiNbChildren; uiChild++) { + + CSubsystem* pSubsystem = static_cast(getChild(uiChild)); + + if (!pSubsystem->init(error)) + { + return false; + } + } + return true; +} diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h index a6531b0df..dccb509a7 100644 --- a/parameter/SystemClass.h +++ b/parameter/SystemClass.h @@ -79,6 +79,13 @@ class CSystemClass : public CConfigurableElement */ void cleanSubsystemsNeedToResync(); + /** Launch init functions of all plugin subsystems + * + * @param[out] error, error encountered during initialization + * @return true if succeed, false otherwise + */ + bool initSubsystems(std::string& error); + // base virtual std::string getKind() const; From 21ceba801c9bf9e0b1076db4042f6369e982a918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gonzalve?= Date: Sat, 28 Feb 2015 21:39:08 +0100 Subject: [PATCH 2/4] Move toString and appendtitle out of element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The element class really looks like a god class with stuff that has really nothing to do with its role. toString and appendTitle are good example of stuff that should be move away from it. This patch move those two functions into utility where they seems to belong. Signed-off-by: Sébastien Gonzalve Signed-off-by: Jules Clero --- parameter/ArrayParameter.cpp | 8 +-- parameter/BitParameterBlockType.cpp | 5 +- parameter/BitParameterType.cpp | 15 +++--- parameter/ConfigurableElement.cpp | 5 +- parameter/Element.cpp | 52 -------------------- parameter/Element.h | 8 --- parameter/EnumParameterType.cpp | 5 +- parameter/EnumValuePair.cpp | 5 +- parameter/FixedPointParameterType.cpp | 13 ++--- parameter/IntegerParameterType.cpp | 17 ++++--- parameter/LinearParameterAdaptation.cpp | 5 +- parameter/LogarithmicParameterAdaptation.cpp | 5 +- parameter/ParameterAdaptation.cpp | 3 +- parameter/ParameterBlockType.cpp | 4 +- parameter/ParameterMgr.cpp | 14 +++--- parameter/ParameterType.cpp | 3 +- parameter/SelectionCriterion.cpp | 3 +- parameter/StringParameterType.cpp | 3 +- parameter/Subsystem.cpp | 4 +- utility/Utility.cpp | 13 +++++ utility/Utility.h | 19 ++++++- 21 files changed, 99 insertions(+), 110 deletions(-) diff --git a/parameter/ArrayParameter.cpp b/parameter/ArrayParameter.cpp index 8561410c3..291b6a13a 100644 --- a/parameter/ArrayParameter.cpp +++ b/parameter/ArrayParameter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -34,6 +34,7 @@ #include "ParameterAccessContext.h" #include "ConfigurationAccessContext.h" #include "ParameterBlackboard.h" +#include "Utility.h" #include #define base CParameter @@ -62,7 +63,7 @@ void CArrayParameter::showProperties(string& strResult) const // Array length strResult += "Array length: "; - strResult += toString(getArrayLength()); + strResult += CUtility::toString(getArrayLength()); strResult += "\n"; } @@ -281,7 +282,8 @@ bool CArrayParameter::setValues(uint32_t uiStartIndex, uint32_t uiBaseOffset, co if (!doSetValue(astrValues[uiValueIndex], uiOffset, parameterAccessContext)) { // Append parameter path to error - parameterAccessContext.appendToError(" " + getPath() + "/" + toString(uiValueIndex + uiStartIndex)); + parameterAccessContext.appendToError(" " + getPath() + "/" + + CUtility::toString(uiValueIndex + uiStartIndex)); return false; } diff --git a/parameter/BitParameterBlockType.cpp b/parameter/BitParameterBlockType.cpp index 2016b3b70..0d344f23b 100644 --- a/parameter/BitParameterBlockType.cpp +++ b/parameter/BitParameterBlockType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -29,6 +29,7 @@ */ #include "BitParameterBlockType.h" #include "BitParameterBlock.h" +#include "Utility.h" #define base CTypeElement @@ -74,7 +75,7 @@ CInstanceConfigurableElement* CBitParameterBlockType::doInstantiate() const void CBitParameterBlockType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { // Size - xmlElement.setAttributeString("Size", toString(_uiSize * 8)); + xmlElement.setAttributeString("Size", CUtility::toString(_uiSize * 8)); base::toXml(xmlElement, serializingContext); } diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp index 2a400d40f..855ff099c 100644 --- a/parameter/BitParameterType.cpp +++ b/parameter/BitParameterType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -33,6 +33,7 @@ #include #include "ParameterAccessContext.h" #include "BitParameterBlockType.h" +#include "Utility.h" #define base CTypeElement @@ -55,17 +56,17 @@ void CBitParameterType::showProperties(string& strResult) const // Bit Pos strResult += "Bit pos: "; - strResult += toString(_uiBitPos); + strResult += CUtility::toString(_uiBitPos); strResult += "\n"; // Bit size strResult += "Bit size: "; - strResult += toString(_uiBitSize); + strResult += CUtility::toString(_uiBitSize); strResult += "\n"; // Max strResult += "Max: "; - strResult += toString(_uiMax); + strResult += CUtility::toString(_uiMax); strResult += "\n"; } @@ -245,13 +246,13 @@ bool CBitParameterType::isEncodable(uint64_t uiData) const void CBitParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { // Position - xmlElement.setAttributeString("Pos", toString(_uiBitPos)); + xmlElement.setAttributeString("Pos", CUtility::toString(_uiBitPos)); // Size - xmlElement.setAttributeString("Size", toString(_uiBitSize)); + xmlElement.setAttributeString("Size", CUtility::toString(_uiBitSize)); // Maximum - xmlElement.setAttributeString("Max", toString(_uiMax)); + xmlElement.setAttributeString("Max", CUtility::toString(_uiMax)); base::toXml(xmlElement, serializingContext); diff --git a/parameter/ConfigurableElement.cpp b/parameter/ConfigurableElement.cpp index 754f2077e..08a01223a 100644 --- a/parameter/ConfigurableElement.cpp +++ b/parameter/ConfigurableElement.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -34,6 +34,7 @@ #include "ConfigurationAccessContext.h" #include "ConfigurableElementAggregator.h" #include "AreaConfiguration.h" +#include "Utility.h" #include #define base CElement @@ -360,7 +361,7 @@ bool CConfigurableElement::isRogue() const std::string CConfigurableElement::getFootprintAsString() const { // Get size as string - return toString(getFootPrint()) + " byte(s)"; + return CUtility::toString(getFootPrint()) + " byte(s)"; } // Matching check for no domain association diff --git a/parameter/Element.cpp b/parameter/Element.cpp index e446fbeba..98b33c1fb 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -35,7 +35,6 @@ #include #include #include -#include using std::string; @@ -110,43 +109,6 @@ void CElement::showProperties(string& strResult) const strResult += "Kind: " + getKind() + "\n"; } -// Conversion utilities -string CElement::toString(uint32_t uiValue) -{ - std::ostringstream ostr; - - ostr << uiValue; - - return ostr.str(); -} - -string CElement::toString(uint64_t uiValue) -{ - std::ostringstream ostr; - - ostr << uiValue; - - return ostr.str(); -} - -string CElement::toString(int32_t iValue) -{ - std::ostringstream ostr; - - ostr << iValue; - - return ostr.str(); -} - -string CElement::toString(double dValue) -{ - std::ostringstream ostr; - - ostr << dValue; - - return ostr.str(); -} - // Content dumping void CElement::logValue(string& strValue, CErrorContext& errorContext) const { @@ -610,17 +572,3 @@ uint8_t CElement::computeStructureChecksum() const return uiChecksum; } - -// Utility to underline -void CElement::appendTitle(string& strTo, const string& strTitle) -{ - strTo += "\n" + strTitle + "\n"; - - string::size_type uiLength = strTitle.size(); - - while (uiLength--) { - - strTo += "="; - } - strTo += "\n"; -} diff --git a/parameter/Element.h b/parameter/Element.h index dd57584c8..2033c0943 100644 --- a/parameter/Element.h +++ b/parameter/Element.h @@ -124,12 +124,6 @@ class CElement : public IXmlSink, public IXmlSource // Element properties virtual void showProperties(std::string& strResult) const; - // Conversion utilities - static std::string toString(uint32_t uiValue); - static std::string toString(uint64_t uiValue); - static std::string toString(int32_t iValue); - static std::string toString(double dValue); - // Checksum for integrity checks uint8_t computeStructureChecksum() const; @@ -138,8 +132,6 @@ class CElement : public IXmlSink, public IXmlSource protected: // Content dumping virtual void logValue(std::string& strValue, CErrorContext& errorContext) const; - // Utility to underline - static void appendTitle(std::string& strTo, const std::string& strTitle); // Hierarchy CElement* getParent(); diff --git a/parameter/EnumParameterType.cpp b/parameter/EnumParameterType.cpp index 8cca7d746..147ee95bf 100644 --- a/parameter/EnumParameterType.cpp +++ b/parameter/EnumParameterType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -35,6 +35,7 @@ #include #include "ParameterAccessContext.h" #include "EnumValuePair.h" +#include "Utility.h" #include #define base CParameterType @@ -344,7 +345,7 @@ bool CEnumParameterType::isValid(int iNumerical, CParameterAccessContext& parame void CEnumParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { // Size - xmlElement.setAttributeString("Size", toString(getSize() * 8)); + xmlElement.setAttributeString("Size", CUtility::toString(getSize() * 8)); base::toXml(xmlElement, serializingContext); } diff --git a/parameter/EnumValuePair.cpp b/parameter/EnumValuePair.cpp index 81febdd5c..35f4cd236 100644 --- a/parameter/EnumValuePair.cpp +++ b/parameter/EnumValuePair.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "EnumValuePair.h" +#include "Utility.h" #define base CElement @@ -51,7 +52,7 @@ int32_t CEnumValuePair::getNumerical() const string CEnumValuePair::getNumericalAsString() const { - return toString(_iNumerical); + return CUtility::toString(_iNumerical); } // From IXmlSink diff --git a/parameter/FixedPointParameterType.cpp b/parameter/FixedPointParameterType.cpp index e7779a9cb..5189a0719 100644 --- a/parameter/FixedPointParameterType.cpp +++ b/parameter/FixedPointParameterType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -36,6 +36,7 @@ #include "Parameter.h" #include "ParameterAccessContext.h" #include "ConfigurationAccessContext.h" +#include "Utility.h" #include #include @@ -59,9 +60,9 @@ void CFixedPointParameterType::showProperties(string& strResult) const // Notation strResult += "Notation: Q"; - strResult += toString(_uiIntegral); + strResult += CUtility::toString(_uiIntegral); strResult += "."; - strResult += toString(_uiFractional); + strResult += CUtility::toString(_uiFractional); strResult += "\n"; } @@ -363,13 +364,13 @@ double CFixedPointParameterType::binaryQnmToDouble(int32_t iValue) const void CFixedPointParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { // Size - xmlElement.setAttributeString("Size", toString(getSize() * 8)); + xmlElement.setAttributeString("Size", CUtility::toString(getSize() * 8)); // Integral - xmlElement.setAttributeString("Integral", toString(_uiIntegral)); + xmlElement.setAttributeString("Integral", CUtility::toString(_uiIntegral)); // Fractional - xmlElement.setAttributeString("Fractional", toString(_uiFractional)); + xmlElement.setAttributeString("Fractional", CUtility::toString(_uiFractional)); base::toXml(xmlElement, serializingContext); } diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp index edc3d46ac..2d48d53c2 100644 --- a/parameter/IntegerParameterType.cpp +++ b/parameter/IntegerParameterType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2015, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -34,6 +34,7 @@ #include "ParameterAccessContext.h" #include #include "ParameterAdaptation.h" +#include "Utility.h" #include #define base CParameterType @@ -69,12 +70,12 @@ void CIntegerParameterType::showProperties(string& strResult) const // Min strResult += "Min: "; - strResult += _bSigned ? toString((int32_t)_uiMin) : toString(_uiMin); + strResult += _bSigned ? CUtility::toString((int32_t)_uiMin) : CUtility::toString(_uiMin); strResult += "\n"; // Max strResult += "Max: "; - strResult += _bSigned ? toString((int32_t)_uiMax) : toString(_uiMax); + strResult += _bSigned ? CUtility::toString((int32_t)_uiMax) : CUtility::toString(_uiMax); strResult += "\n"; // Check if there's an adaptation object available @@ -439,22 +440,22 @@ void CIntegerParameterType::toXml(CXmlElement& xmlElement, CXmlSerializingContex if (_bSigned) { // Mininmum - xmlElement.setAttributeString("Min", toString((int32_t)_uiMin)); + xmlElement.setAttributeString("Min", CUtility::toString((int32_t)_uiMin)); // Maximum - xmlElement.setAttributeString("Max", toString((int32_t)_uiMax)); + xmlElement.setAttributeString("Max", CUtility::toString((int32_t)_uiMax)); } else { // Minimum - xmlElement.setAttributeString("Min", toString(_uiMin)); + xmlElement.setAttributeString("Min", CUtility::toString(_uiMin)); // Maximum - xmlElement.setAttributeString("Max", toString(_uiMax)); + xmlElement.setAttributeString("Max", CUtility::toString(_uiMax)); } // Size - xmlElement.setAttributeString("Size", toString(getSize() * 8)); + xmlElement.setAttributeString("Size", CUtility::toString(getSize() * 8)); base::toXml(xmlElement, serializingContext); diff --git a/parameter/LinearParameterAdaptation.cpp b/parameter/LinearParameterAdaptation.cpp index ea833b3b0..ae925a74a 100644 --- a/parameter/LinearParameterAdaptation.cpp +++ b/parameter/LinearParameterAdaptation.cpp @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "LinearParameterAdaptation.h" +#include "Utility.h" #define base CParameterAdaptation @@ -49,12 +50,12 @@ void CLinearParameterAdaptation::showProperties(string& strResult) const // SlopeNumerator strResult += " - SlopeNumerator: "; - strResult += toString(_dSlopeNumerator); + strResult += CUtility::toString(_dSlopeNumerator); strResult += "\n"; // SlopeDenominator strResult += " - SlopeDenominator: "; - strResult += toString(_dSlopeDenominator); + strResult += CUtility::toString(_dSlopeDenominator); strResult += "\n"; } diff --git a/parameter/LogarithmicParameterAdaptation.cpp b/parameter/LogarithmicParameterAdaptation.cpp index 688527daa..bca494834 100644 --- a/parameter/LogarithmicParameterAdaptation.cpp +++ b/parameter/LogarithmicParameterAdaptation.cpp @@ -29,6 +29,7 @@ */ #include "LogarithmicParameterAdaptation.h" +#include "Utility.h" #include #define base CLinearParameterAdaptation @@ -45,10 +46,10 @@ void CLogarithmicParameterAdaptation::showProperties(std::string& strResult) con base::showProperties(strResult); strResult += " - LogarithmBase: "; - strResult += toString(_dLogarithmBase); + strResult += CUtility::toString(_dLogarithmBase); strResult += "\n"; strResult += " - FloorValue: "; - strResult += toString(_dFloorValue); + strResult += CUtility::toString(_dFloorValue); strResult += "\n"; } diff --git a/parameter/ParameterAdaptation.cpp b/parameter/ParameterAdaptation.cpp index f1e73c19f..99955f144 100644 --- a/parameter/ParameterAdaptation.cpp +++ b/parameter/ParameterAdaptation.cpp @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ParameterAdaptation.h" +#include "Utility.h" #define base CElement @@ -58,7 +59,7 @@ void CParameterAdaptation::showProperties(string& strResult) const // Offset strResult += " - Offset: "; - strResult += toString(_iOffset); + strResult += CUtility::toString(_iOffset); strResult += "\n"; } diff --git a/parameter/ParameterBlockType.cpp b/parameter/ParameterBlockType.cpp index aafa7ca85..ad9488827 100644 --- a/parameter/ParameterBlockType.cpp +++ b/parameter/ParameterBlockType.cpp @@ -29,6 +29,7 @@ */ #include "ParameterBlockType.h" #include "ParameterBlock.h" +#include "Utility.h" #define base CTypeElement @@ -62,7 +63,8 @@ void CParameterBlockType::populate(CElement* pElement) const for (uiChild = 0; uiChild < uiArrayLength; uiChild++) { - CParameterBlock* pChildParameterBlock = new CParameterBlock(toString(uiChild), this); + CParameterBlock* pChildParameterBlock = new CParameterBlock(CUtility::toString(uiChild), + this); pElement->addChild(pChildParameterBlock); diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index f8b9f8463..0cc3cd08c 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -402,11 +402,11 @@ string CParameterMgr::getVersion() const string strVersion; // Major - strVersion = toString(guiEditionMajor) + "."; + strVersion = CUtility::toString(guiEditionMajor) + "."; // Minor - strVersion += toString(guiEditionMinor) + "."; + strVersion += CUtility::toString(guiEditionMinor) + "."; // Revision - strVersion += toString(guiRevision); + strVersion += CUtility::toString(guiRevision); return strVersion; } @@ -898,7 +898,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProces // Show status /// General section - appendTitle(strResult, "General:"); + CUtility::appendTitle(strResult, "General:"); // System class strResult += "System Class: "; strResult += pSystemClass->getName(); @@ -925,19 +925,19 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProces strResult += "\n"; /// Subsystem list - appendTitle(strResult, "Subsystems:"); + CUtility::appendTitle(strResult, "Subsystems:"); string strSubsystemList; pSystemClass->listChildrenPaths(strSubsystemList); strResult += strSubsystemList; /// Last applied configurations - appendTitle(strResult, "Last Applied [Pending] Configurations:"); + CUtility::appendTitle(strResult, "Last Applied [Pending] Configurations:"); string strLastAppliedConfigurations; getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); strResult += strLastAppliedConfigurations; /// Criteria states - appendTitle(strResult, "Selection Criteria:"); + CUtility::appendTitle(strResult, "Selection Criteria:"); list lstrSelectionCriteria; getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true); // Concatenate the criterion list as the command result diff --git a/parameter/ParameterType.cpp b/parameter/ParameterType.cpp index 01d94aa6e..3c963d330 100644 --- a/parameter/ParameterType.cpp +++ b/parameter/ParameterType.cpp @@ -31,6 +31,7 @@ #include "Parameter.h" #include "ArrayParameter.h" #include "ParameterAccessContext.h" +#include "Utility.h" #define base CTypeElement @@ -98,7 +99,7 @@ void CParameterType::showProperties(string& strResult) const } // Scalar size - strResult += "Scalar size: " + toString(getSize()) + " byte(s) \n"; + strResult += "Scalar size: " + CUtility::toString(getSize()) + " byte(s) \n"; } // Default value handling (simulation only) diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp index 03a04dc7b..58d9e9178 100644 --- a/parameter/SelectionCriterion.cpp +++ b/parameter/SelectionCriterion.cpp @@ -30,6 +30,7 @@ #include "SelectionCriterion.h" #include +#include "Utility.h" #define base CElement @@ -133,7 +134,7 @@ std::string CSelectionCriterion::getFormattedDescription(bool bWithTypeInfo, boo if (bWithTypeInfo) { // Display type info - appendTitle(strFormattedDescription, getName() + ":"); + CUtility::appendTitle(strFormattedDescription, getName() + ":"); // States strFormattedDescription += "Possible states "; diff --git a/parameter/StringParameterType.cpp b/parameter/StringParameterType.cpp index d47895d0c..321dc9751 100644 --- a/parameter/StringParameterType.cpp +++ b/parameter/StringParameterType.cpp @@ -29,6 +29,7 @@ */ #include "StringParameterType.h" #include "StringParameter.h" +#include "Utility.h" #define base CTypeElement @@ -51,7 +52,7 @@ void CStringParameterType::showProperties(string& strResult) const // Max length strResult += "Max length: "; - strResult += toString(_uiMaxLength); + strResult += CUtility::toString(_uiMaxLength); strResult += "\n"; } diff --git a/parameter/Subsystem.cpp b/parameter/Subsystem.cpp index 4b085e0a5..0f337d714 100644 --- a/parameter/Subsystem.cpp +++ b/parameter/Subsystem.cpp @@ -35,6 +35,7 @@ #include "ConfigurationAccessContext.h" #include "SubsystemObjectCreator.h" #include "MappingData.h" +#include "Utility.h" #include #include @@ -443,7 +444,8 @@ bool CSubsystem::handleSubsystemObjectCreation( pSubsystemObjectCreator->getMaxConfigurableElementSize()) { string strSizeError = "Size should not exceed " + - toString(pSubsystemObjectCreator->getMaxConfigurableElementSize()); + CUtility::toString( + pSubsystemObjectCreator->getMaxConfigurableElementSize()); strError = getMappingError(strKey, strSizeError, pInstanceConfigurableElement); diff --git a/utility/Utility.cpp b/utility/Utility.cpp index dc0bce1f4..e5f689a1b 100644 --- a/utility/Utility.cpp +++ b/utility/Utility.cpp @@ -32,6 +32,7 @@ #include #include +#include using std::string; @@ -72,3 +73,15 @@ void CUtility::asString(const std::map& mapStr, CUtility::asString(listKeysValues, strOutput, strItemSeparator); } +void CUtility::appendTitle(string& strTo, const string& strTitle) +{ + strTo += "\n" + strTitle + "\n"; + + uint32_t uiLength = strTitle.size(); + + while (uiLength--) { + + strTo += "="; + } + strTo += "\n"; +} diff --git a/utility/Utility.h b/utility/Utility.h index 51f796f02..93acd8205 100644 --- a/utility/Utility.h +++ b/utility/Utility.h @@ -33,6 +33,7 @@ #include #include #include +#include class CUtility { @@ -62,5 +63,21 @@ class CUtility std::string& strOutput, const std::string& strItemSeparator = ", ", const std::string& strKeyValueSeparator = ":"); -}; + /** Utility to easily convert a builtin type into string + * + * FIXME: Should be replaced by std::to_string after C++11 introduction + */ + template + static std::string toString(T uiValue) + { + std::ostringstream ostr; + + ostr << uiValue; + + return ostr.str(); + } + + /** Utility to underline */ + static void appendTitle(std::string& strTo, const std::string& strTitle); +}; From 07218ad1a5f031ec80ed38cc52833fb35445cd0d Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Thu, 12 Mar 2015 17:35:12 +0100 Subject: [PATCH 3/4] Remove SelectionCriteria based subtree from structure checksum. SelectionCriteria class is dependant from Element class because of the checksum calculation algorithm which is based on child name. In preparation of a rework, we exclude it from the structure checksum calculation. Moreover the criterion mechanism is not a part of the parameter-framework structure. Thus, this decision is fair. Signed-off-by: Jules Clero --- parameter/ParameterMgr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 0cc3cd08c..195a8c7ca 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -662,7 +662,8 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) } // We have loaded the whole system structure, compute checksum const CSystemClass* pSystemClass = getConstSystemClass(); - _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum(); + _uiStructureChecksum = pSystemClass->computeStructureChecksum() + + getConfigurableDomains()->computeStructureChecksum(); // Load binary settings if any provided if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { From 44713bbacfcf86bd60f5f67ab3e60cb0e866e1c2 Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Wed, 11 Mar 2015 14:15:26 +0100 Subject: [PATCH 4/4] Avoid ParameterManager inheritance to Element god class. ParameterManager does not have to be a part of the Element tree. Indeed, it is not represented in any xml file. This patch avoids this inheritance and removes some "tricks" which was used to forget the ParameterMgr root element. Signed-off-by: Jules Clero --- parameter/ConfigurableElement.cpp | 20 +- parameter/ConfigurableElement.h | 3 - parameter/Element.cpp | 3 +- parameter/ParameterMgr.cpp | 368 ++++++++++++------------------ parameter/ParameterMgr.h | 49 ++-- 5 files changed, 173 insertions(+), 270 deletions(-) diff --git a/parameter/ConfigurableElement.cpp b/parameter/ConfigurableElement.cpp index 08a01223a..66e462e5c 100644 --- a/parameter/ConfigurableElement.cpp +++ b/parameter/ConfigurableElement.cpp @@ -162,7 +162,7 @@ void CConfigurableElement::getListOfElementsWithMapping( { // Check parent const CElement* pParent = getParent(); - if (isOfConfigurableElementType(pParent)) { + if (pParent != NULL) { const CConfigurableElement* pConfigurableElement = static_cast(pParent); @@ -242,7 +242,7 @@ ISyncer* CConfigurableElement::getSyncer() const // Check parent const CElement* pParent = getParent(); - if (isOfConfigurableElementType(pParent)) { + if (pParent != NULL) { return static_cast(pParent)->getSyncer(); } @@ -311,7 +311,7 @@ void CConfigurableElement::getBelongingDomains(std::list(pParent)->getBelongingDomains(configurableDomainList); } @@ -466,7 +466,7 @@ bool CConfigurableElement::belongsToDomainAscending(const CConfigurableDomain* p // Check parent const CElement* pParent = getParent(); - if (isOfConfigurableElementType(pParent)) { + if (pParent != NULL) { return static_cast(pParent)->belongsTo(pConfigurableDomain); } @@ -479,7 +479,7 @@ const CSubsystem* CConfigurableElement::getBelongingSubsystem() const const CElement* pParent = getParent(); // Stop at system class - if (!pParent->getParent()) { + if (pParent == NULL) { return NULL; } @@ -492,13 +492,3 @@ bool CConfigurableElement::isParameter() const { return false; } - - -// 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 index 18256cfa5..991605ae7 100644 --- a/parameter/ConfigurableElement.h +++ b/parameter/ConfigurableElement.h @@ -141,9 +141,6 @@ class CConfigurableElement : public CElement void getBelongingDomains(std::list& configurableDomainList) const; void listDomains(const std::list& configurableDomainList, std::string& strResult, bool bVertical) const; - // Check parent is still of current type (by structure knowledge) - bool isOfConfigurableElementType(const CElement* pParent) const; - // Offset in main blackboard uint32_t _uiOffset; diff --git a/parameter/Element.cpp b/parameter/Element.cpp index 98b33c1fb..edd093994 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -531,8 +531,7 @@ const CElement* CElement::findChildOfKind(const string& strKind) const string CElement::getPath() const { - // Take out root element from the path - if (_pParent && _pParent->_pParent) { + if (_pParent != NULL) { return _pParent->getPath() + "/" + getPathName(); } diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 195a8c7ca..f5e8654af 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -30,7 +30,6 @@ #include "ParameterMgr.h" #include "XmlParameterSerializingContext.h" #include "XmlElementSerializingContext.h" -#include "SystemClass.h" #include "ElementLibrarySet.h" #include "SubsystemLibrary.h" #include "NamedElementBuilderTemplate.h" @@ -39,7 +38,6 @@ #include "SelectionCriterionType.h" #include "SubsystemElementBuilder.h" #include "FileIncluderElementBuilder.h" -#include "SelectionCriteria.h" #include "ComponentType.h" #include "ComponentInstance.h" #include "ParameterBlockType.h" @@ -49,12 +47,10 @@ #include "ParameterBlackboard.h" #include "Parameter.h" #include "ParameterAccessContext.h" -#include "ParameterFrameworkConfiguration.h" #include "FrameworkConfigurationGroup.h" #include "PluginLocation.h" #include "SubsystemPlugins.h" #include "FrameworkConfigurationLocation.h" -#include "ConfigurableDomains.h" #include "ConfigurableDomain.h" #include "DomainConfiguration.h" #include "XmlDomainSerializingContext.h" @@ -91,8 +87,6 @@ #include #include -#define base CElement - /** Private macro helper to declare a new context * * Context declaration always need logger and logging prefix to be @@ -331,19 +325,17 @@ CParameterMgr::CParameterMgr(const string& strConfigurationFilePath, log::ILogge _bForceNoRemoteInterface(false), _bFailOnMissingSubsystem(true), _bFailOnFailedSettingsLoad(true), - _bValidateSchemasOnStart(false) + _bValidateSchemasOnStart(false), + _pfwConfiguration(), + _criteria(), + _systemClass(_logger), + _domains() { // Tuning Mode Mutex bzero(&_blackboardMutex, sizeof(_blackboardMutex)); pthread_mutex_init(&_blackboardMutex, NULL); - // Deal with children - addChild(new CParameterFrameworkConfiguration); - addChild(new CSelectionCriteria); - addChild(new CSystemClass(_logger)); - addChild(new CConfigurableDomains); - _pCommandHandler = new CCommandHandler(this); // Add command parsers @@ -391,11 +383,6 @@ CParameterMgr::~CParameterMgr() pthread_mutex_destroy(&_blackboardMutex); } -string CParameterMgr::getKind() const -{ - return "ParameterMgr"; -} - // Version string CParameterMgr::getVersion() const { @@ -440,7 +427,7 @@ bool CParameterMgr::load(string& strError) return false; } - if (!getSystemClass()->initSubsystems(strError)) { + if (!_systemClass.initSubsystems(strError)) { return false; } @@ -449,30 +436,26 @@ bool CParameterMgr::load(string& strError) { LOG_CONTEXT("Main blackboard back synchronization"); - // Back synchronization for areas in parameter blackboard not covered by any domain - BackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard).sync(); + // Back synchronization for areas in parameter blackboard not covered by any domain + BackSynchronizer(&_systemClass, _pMainParameterBlackboard).sync(); } // We're done loading the settings and back synchronizing - CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); - // We need to ensure all domains are valid - pConfigurableDomains->validate(_pMainParameterBlackboard); + _domains.validate(_pMainParameterBlackboard); // Log selection criterion states { LOG_CONTEXT("Criterion states"); - const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria(); - list criteria; - selectionCriteria->listSelectionCriteria(criteria, true, false); + _criteria.listSelectionCriteria(criteria, true, false); info() << criteria; } // Subsystem can not ask for resync as they have not been synced yet - getSystemClass()->cleanSubsystemsNeedToResync(); + _systemClass.cleanSubsystemsNeedToResync(); // At initialization, check subsystems that need resync doApplyConfigurations(true); @@ -488,16 +471,18 @@ bool CParameterMgr::loadFrameworkConfiguration(string& strError) // Parse Structure XML file CXmlElementSerializingContext elementSerializingContext(strError); - if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) { + if (!xmlParse(elementSerializingContext, &_pfwConfiguration, _strXmlConfigurationFilePath, + _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) { return false; } // Set class name to system class and configurable domains - getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName()); - getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName()); + _systemClass.setName(_pfwConfiguration.getSystemClassName()); + _domains.setName(_pfwConfiguration.getSystemClassName()); // Get subsystem plugins elements - _pSubsystemPlugins = static_cast(getConstFrameworkConfiguration()->findChild("SubsystemPlugins")); + _pSubsystemPlugins = + static_cast(_pfwConfiguration.findChild("SubsystemPlugins")); if (!_pSubsystemPlugins) { @@ -507,8 +492,7 @@ bool CParameterMgr::loadFrameworkConfiguration(string& strError) } // Log tuning availability - info() << "Tuning " - << (getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited"); + info() << "Tuning " << (_pfwConfiguration.isTuningAllowed() ? "allowed" : "prohibited"); return true; } @@ -518,9 +502,9 @@ bool CParameterMgr::loadSubsystems(std::string& error) LOG_CONTEXT("Loading subsystem plugins"); // Load subsystems - bool isSuccess = getSystemClass()->loadSubsystems(error, - _pSubsystemPlugins, - !_bFailOnMissingSubsystem); + bool isSuccess = _systemClass.loadSubsystems(error, + _pSubsystemPlugins, + !_bFailOnMissingSubsystem); if (isSuccess) { info() << "All subsystem plugins successfully loaded"; @@ -537,17 +521,17 @@ bool CParameterMgr::loadSubsystems(std::string& error) bool CParameterMgr::loadStructure(string& strError) { - // Retrieve system to load structure to - CSystemClass* pSystemClass = getSystemClass(); - - LOG_CONTEXT("Loading " + pSystemClass->getName() + " system class structure"); + LOG_CONTEXT("Loading " + _systemClass.getName() + " system class structure"); // Get structure description element - const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation")); + const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = + static_cast( + _pfwConfiguration.findChildOfKind("StructureDescriptionFileLocation")); if (!pStructureDescriptionFileLocation) { - strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName(); + strError = "No StructureDescriptionFileLocation element found for SystemClass " + + _systemClass.getName(); return false; } @@ -564,17 +548,18 @@ bool CParameterMgr::loadStructure(string& strError) { LOG_CONTEXT("Importing system structure from file " + strXmlStructureFilePath); - if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { + if (!xmlParse(parameterBuildContext, &_systemClass, + strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { return false; } } // Initialize offsets - pSystemClass->setOffset(0); + _systemClass.setOffset(0); // Initialize main blackboard's size - _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint()); + _pMainParameterBlackboard->setSize(_systemClass.getFootPrint()); return true; } @@ -605,7 +590,9 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) LOG_CONTEXT("Loading settings"); // Get settings configuration element - const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration")); + const CFrameworkConfigurationGroup* pParameterConfigurationGroup = + static_cast( + _pfwConfiguration.findChildOfKind("SettingsConfiguration")); if (!pParameterConfigurationGroup) { @@ -629,12 +616,11 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) if (!pConfigurableDomainsFileLocation) { - strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); + strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + + _systemClass.getName(); return false; } - // Get destination root element - CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); // Get Xml configuration domains file name string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath); @@ -643,11 +629,14 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath); // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary) - CXmlDomainImportContext xmlDomainImportContext(strError, !pBinarySettingsFileLocation, - *getSystemClass()); + CXmlDomainImportContext xmlDomainImportContext(strError, + !pBinarySettingsFileLocation, + _systemClass); // Selection criteria definition for rule creation - xmlDomainImportContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + // FIXME: Avoid const_cast by refactoring criteria subtree + xmlDomainImportContext.setSelectionCriteriaDefinition( + const_cast(_criteria).getSelectionCriteriaDefinition()); // Auto validation of configurations if no binary settings provided xmlDomainImportContext.setAutoValidationRequired(!pBinarySettingsFileLocation); @@ -656,17 +645,19 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) << " " << ( pBinarySettingsFileLocation ? "without" : "with") << " settings"; // Do parse - if (!xmlParse(xmlDomainImportContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { + if (!xmlParse(xmlDomainImportContext, &_domains, + strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, + EParameterConfigurationLibrary, "SystemClassName")) { return false; } // We have loaded the whole system structure, compute checksum - const CSystemClass* pSystemClass = getConstSystemClass(); - _uiStructureChecksum = pSystemClass->computeStructureChecksum() + - getConfigurableDomains()->computeStructureChecksum(); + _uiStructureChecksum = _systemClass.computeStructureChecksum() + + _domains.computeStructureChecksum(); // Load binary settings if any provided - if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { + if (pBinarySettingsFileLocation && !_domains.serializeSettings( + strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { return false; } @@ -677,11 +668,12 @@ bool CParameterMgr::loadSettingsFromConfigFile(string& strError) bool CParameterMgr::importDomainFromFile(const string& strXmlFilePath, bool bOverwrite, string& strError) { - CXmlDomainImportContext xmlDomainImportContext(strError, true, *getSystemClass()); + CXmlDomainImportContext xmlDomainImportContext(strError, true, _systemClass); // Selection criteria definition for rule creation + // FIXME: Avoid const_cast by refactoring criteria subtree xmlDomainImportContext.setSelectionCriteriaDefinition( - getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + const_cast(_criteria).getSelectionCriteriaDefinition()); // Auto validation of configurations xmlDomainImportContext.setAutoValidationRequired(true); @@ -698,8 +690,7 @@ bool CParameterMgr::importDomainFromFile(const string& strXmlFilePath, bool bOve LOG_CONTEXT("Adding configurable domain '" + standaloneDomain->getName() + "'"); - if (!logResult(getConfigurableDomains()->addDomain( - *standaloneDomain, bOverwrite, strError), strError)) { + if (!logResult(_domains.addDomain(*standaloneDomain, bOverwrite, strError), strError)) { return false; } @@ -750,22 +741,20 @@ bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingCo CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) { // Propagate - return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive); + return _criteria.createSelectionCriterionType(bIsInclusive); } CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) { // Propagate - return getSelectionCriteria()->createSelectionCriterion(strName, - pSelectionCriterionType, - _logger); + return _criteria.createSelectionCriterion(strName, pSelectionCriterionType, _logger); } // Selection criterion retrieval CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName) { // Propagate - return getSelectionCriteria()->getSelectionCriterion(strName); + return _criteria.getSelectionCriterion(strName); } // Configuration application @@ -793,13 +782,13 @@ const CConfigurableElement* CParameterMgr::getConfigurableElement(const string& CPathNavigator pathNavigator(strPath); // Nagivate through system class - if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { + if (!pathNavigator.navigateThrough(_systemClass.getName(), strError)) { return NULL; } // Find element - const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator); + const CElement* pElement = _systemClass.findDescendant(pathNavigator); if (!pElement) { @@ -894,15 +883,13 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProce CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) { (void)remoteCommand; - // System class - const CSystemClass* pSystemClass = getSystemClass(); // Show status /// General section CUtility::appendTitle(strResult, "General:"); // System class strResult += "System Class: "; - strResult += pSystemClass->getName(); + strResult += _systemClass.getName(); strResult += "\n"; // Tuning mode @@ -928,19 +915,19 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProces /// Subsystem list CUtility::appendTitle(strResult, "Subsystems:"); string strSubsystemList; - pSystemClass->listChildrenPaths(strSubsystemList); + _systemClass.listChildrenPaths(strSubsystemList); strResult += strSubsystemList; /// Last applied configurations CUtility::appendTitle(strResult, "Last Applied [Pending] Configurations:"); string strLastAppliedConfigurations; - getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); + _domains.listLastAppliedConfigurations(strLastAppliedConfigurations); strResult += strLastAppliedConfigurations; /// Criteria states CUtility::appendTitle(strResult, "Selection Criteria:"); list lstrSelectionCriteria; - getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true); + _criteria.listSelectionCriteria(lstrSelectionCriteria, false, true); // Concatenate the criterion list as the command result string strCriteriaStates; CUtility::asString(lstrSelectionCriteria, strCriteriaStates); @@ -1111,7 +1098,9 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommman if (strOutputFormat == "XML") { // Get Root element where to export from - const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition = getConstSelectionCriteria()->getSelectionCriteriaDefinition(); + // FIXME: Avoid const_cast by refactoring criteria subtree + const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition = + const_cast(_criteria).getSelectionCriteriaDefinition(); if (!exportElementToXMLString(pSelectionCriteriaDefinition, "SelectionCriteria", strResult)) { @@ -1127,7 +1116,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommman bool bHumanReadable = strOutputFormat.empty(); list lstrResult; - getSelectionCriteria()->listSelectionCriteria(lstrResult, true, bHumanReadable); + _criteria.listSelectionCriteria(lstrResult, true, bHumanReadable); // Concatenate the criterion list as the command result CUtility::asString(lstrResult, strResult); @@ -1141,7 +1130,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmand { (void)remoteCommand; - getConfigurableDomains()->listDomains(strResult); + _domains.listDomains(strResult); return CCommandHandler::ESucceeded; } @@ -1208,7 +1197,8 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenes CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; + return _domains.listDomainElements(remoteCommand.getArgument(0), strResult) ? + CCommandHandler::ESucceeded : CCommandHandler::EFailed; } CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) @@ -1229,7 +1219,8 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmand /// Configurations CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; + return _domains.listConfigurations(remoteCommand.getArgument(0), strResult) ? + CCommandHandler::ESucceeded : CCommandHandler::EFailed; } CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) @@ -1241,7 +1232,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmand CErrorContext errorContext(strError); // Dump - getConstConfigurableDomains()->dumpContent(strResult, errorContext); + _domains.dumpContent(strResult, errorContext); return CCommandHandler::ESucceeded; } @@ -1301,7 +1292,10 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceC CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { // Delegate to configurable domains - return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; + return _domains.getElementSequence(remoteCommand.getArgument(0), + remoteCommand.getArgument(1), + strResult) ? + CCommandHandler::ESucceeded : CCommandHandler::EFailed; } CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) @@ -1331,7 +1325,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProc /// Elements/Parameters CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass(), false); + CElementLocator elementLocator(&_systemClass, false); CElement* pLocatedElement = NULL; @@ -1347,7 +1341,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommman // List from root folder // Return system class qualified name - pLocatedElement = getSystemClass(); + pLocatedElement = &_systemClass; } // Return sub-elements @@ -1359,7 +1353,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommman /// Elements/Parameters CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass(), false); + CElementLocator elementLocator(&_systemClass, false); CElement* pLocatedElement = NULL; @@ -1375,7 +1369,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommm // List from root folder // Return system class qualified name - pLocatedElement = getSystemClass(); + pLocatedElement = &_systemClass; } // Return sub-elements @@ -1386,7 +1380,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommm CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1407,7 +1401,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmand CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1427,7 +1421,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommm CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1469,7 +1463,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommman CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1489,7 +1483,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomain CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) { - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1511,7 +1505,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedEleme { (void)remoteCommand; - getConfigurableDomains()->listAssociatedElements(strResult); + _domains.listAssociatedElements(strResult); return CCommandHandler::ESucceeded; } @@ -1520,7 +1514,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElem { (void)remoteCommand; - getConfigurableDomains()->listConflictingElements(strResult); + _domains.listConflictingElements(strResult); return CCommandHandler::ESucceeded; } @@ -1529,7 +1523,7 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCo { (void)remoteCommand; - getSystemClass()->listRogueElements(strResult); + _systemClass.listRogueElements(strResult); return CCommandHandler::ESucceeded; } @@ -1676,9 +1670,7 @@ CParameterMgr::CCommandHandler::CommandStatus (void)remoteCommand; // Get Root element where to export from - const CSystemClass* pSystemClass = getSystemClass(); - - if (!exportElementToXMLString(pSystemClass, pSystemClass->getKind(), strResult)) { + if (!exportElementToXMLString(&_systemClass, _systemClass.getKind(), strResult)) { return CCommandHandler::EFailed; } @@ -1713,7 +1705,7 @@ bool CParameterMgr::getParameterMapping(const string& strPath, string& strResult CPathNavigator pathNavigator(strPath); // Nagivate through system class - if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strResult)) { + if (!pathNavigator.navigateThrough(_systemClass.getName(), strResult)) { return false; } @@ -1746,7 +1738,7 @@ bool CParameterMgr::getParameterMapping(const string& strPath, string& strResult // 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()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -1769,13 +1761,12 @@ bool CParameterMgr::accessConfigurationValue(const string& strDomain, const stri ", Configuration: " + strConfiguration + ", Element: " + pConfigurableElement->getPath()); - pConfigurationBlackboard = - getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, - strConfiguration, - pConfigurableElement, - uiBaseOffset, - bIsLastApplied, - strError); + pConfigurationBlackboard = _domains.findConfigurationBlackboard(strDomain, + strConfiguration, + pConfigurableElement, + uiBaseOffset, + bIsLastApplied, + strError); if (!pConfigurationBlackboard) { warning() << "Fail: " << strError; @@ -1835,7 +1826,7 @@ bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, CPathNavigator pathNavigator(strPath); // Nagivate through system class - if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { + if (!pathNavigator.navigateThrough(_systemClass.getName(), strError)) { parameterAccessContext.setError(strError); @@ -1843,14 +1834,14 @@ bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, } // Do the get - return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext); + return _systemClass.accessValue(pathNavigator, strValue, bSet, parameterAccessContext); } // Tuning mode bool CParameterMgr::setTuningMode(bool bOn, string& strError) { // Tuning allowed? - if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) { + if (bOn && !_pfwConfiguration.isTuningAllowed()) { strError = "Tuning prohibited"; @@ -1952,7 +1943,7 @@ bool CParameterMgr::sync(string& strError) // Get syncer set CSyncerSet syncerSet; // ... from system class - getConstSystemClass()->fillSyncerSet(syncerSet); + _systemClass.fillSyncerSet(syncerSet); // Sync core::Results error; @@ -1976,7 +1967,7 @@ bool CParameterMgr::createDomain(const string& strName, string& strError) } // Delegate to configurable domains - return logResult(getConfigurableDomains()->createDomain(strName, strError), strError); + return logResult(_domains.createDomain(strName, strError), strError); } bool CParameterMgr::deleteDomain(const string& strName, string& strError) @@ -1991,7 +1982,7 @@ bool CParameterMgr::deleteDomain(const string& strName, string& strError) } // Delegate to configurable domains - return logResult(getConfigurableDomains()->deleteDomain(strName, strError), strError); + return logResult(_domains.deleteDomain(strName, strError), strError); } bool CParameterMgr::renameDomain(const string& strName, const string& strNewName, string& strError) @@ -1999,8 +1990,7 @@ bool CParameterMgr::renameDomain(const string& strName, const string& strNewName LOG_CONTEXT("Renaming configurable domain '" + strName + "' to '" + strNewName + "'"); // Delegate to configurable domains - return logResult(getConfigurableDomains()->renameDomain( - strName, strNewName, strError), strError); + return logResult(_domains.renameDomain(strName, strNewName, strError), strError); } bool CParameterMgr::deleteAllDomains(string& strError) @@ -2015,7 +2005,7 @@ bool CParameterMgr::deleteAllDomains(string& strError) } // Delegate to configurable domains - getConfigurableDomains()->deleteAllDomains(); + _domains.deleteAllDomains(); info() << "Success"; return true; @@ -2032,14 +2022,13 @@ bool CParameterMgr::setSequenceAwareness(const string& strName, bool bSequenceAw return false; } - return logResult(getConfigurableDomains()->setSequenceAwareness( - strName, bSequenceAware, strResult), strResult); + return logResult(_domains.setSequenceAwareness(strName, bSequenceAware, strResult), strResult); } bool CParameterMgr::getSequenceAwareness(const string& strName, bool& bSequenceAware, string& strResult) { - return getConfigurableDomains()->getSequenceAwareness(strName, bSequenceAware, strResult); + return _domains.getSequenceAwareness(strName, bSequenceAware, strResult); } bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError) @@ -2054,7 +2043,7 @@ bool CParameterMgr::createConfiguration(const string& strDomain, const string& s } // Delegate to configurable domains - return logResult(getConfigurableDomains()->createConfiguration( + return logResult(_domains.createConfiguration( strDomain, strConfiguration, _pMainParameterBlackboard, strError), strError); } bool CParameterMgr::renameConfiguration(const string& strDomain, const string& strConfiguration, @@ -2063,7 +2052,7 @@ bool CParameterMgr::renameConfiguration(const string& strDomain, const string& s LOG_CONTEXT("Renaming domain '" + strDomain + "''s configuration '" + strConfiguration + "' to '" + strNewConfiguration + "'"); - return logResult(getConfigurableDomains()->renameConfiguration( + return logResult(_domains.renameConfiguration( strDomain, strConfiguration, strNewConfiguration, strError), strError); } @@ -2080,8 +2069,7 @@ bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& s } // Delegate to configurable domains - return logResult(getConfigurableDomains()->deleteConfiguration( - strDomain, strConfiguration, strError), strError); + return logResult(_domains.deleteConfiguration(strDomain, strConfiguration, strError), strError); } bool CParameterMgr::restoreConfiguration(const string& strDomain, @@ -2100,7 +2088,7 @@ bool CParameterMgr::restoreConfiguration(const string& strDomain, } // Delegate to configurable domains - return logResult(getConstConfigurableDomains()->restoreConfiguration( + return logResult(_domains.restoreConfiguration( strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, errors), strError); } @@ -2117,7 +2105,7 @@ bool CParameterMgr::saveConfiguration(const string& strDomain, const string& str } // Delegate to configurable domains - return logResult(getConfigurableDomains()->saveConfiguration( + return logResult(_domains.saveConfiguration( strDomain, strConfiguration, _pMainParameterBlackboard, strError), strError); } @@ -2133,7 +2121,7 @@ bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, cons return false; } - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -2148,7 +2136,7 @@ bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, cons // Delegate core::Results infos; - bool isSuccess = getConfigurableDomains()->addConfigurableElementToDomain( + bool isSuccess = _domains.addConfigurableElementToDomain( strDomain, pConfigurableElement, _pMainParameterBlackboard, infos); if (isSuccess) { @@ -2173,7 +2161,7 @@ bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, return false; } - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -2187,7 +2175,7 @@ bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement = static_cast(pLocatedElement); // Delegate - return logResult(getConfigurableDomains()->removeConfigurableElementFromDomain( + return logResult(_domains.removeConfigurableElementFromDomain( strDomain, pConfigurableElement, strError), strError); } @@ -2202,7 +2190,7 @@ bool CParameterMgr::split(const string& strDomain, const string& strConfigurable return false; } - CElementLocator elementLocator(getSystemClass()); + CElementLocator elementLocator(&_systemClass); CElement* pLocatedElement = NULL; @@ -2217,7 +2205,7 @@ bool CParameterMgr::split(const string& strDomain, const string& strConfigurable // Delegate core::Results infos; - bool isSuccess = getConfigurableDomains()->split(strDomain, pConfigurableElement, infos); + bool isSuccess = _domains.split(strDomain, pConfigurableElement, infos); if (isSuccess) { info() << infos; @@ -2239,28 +2227,29 @@ bool CParameterMgr::setElementSequence(const string& strDomain, const string& st return false; } - return getConfigurableDomains()->setElementSequence(strDomain, strConfiguration, + return _domains.setElementSequence(strDomain, strConfiguration, astrNewElementSequence, strError); } bool CParameterMgr::getApplicationRule(const string& strDomain, const string& strConfiguration, string& strResult) { - return getConfigurableDomains()->getApplicationRule(strDomain, strConfiguration, strResult); + return _domains.getApplicationRule(strDomain, strConfiguration, strResult); } bool CParameterMgr::setApplicationRule(const string& strDomain, const string& strConfiguration, const string& strApplicationRule, string& strError) { - return getConfigurableDomains()->setApplicationRule(strDomain, strConfiguration, - strApplicationRule, getConstSelectionCriteria()->getSelectionCriteriaDefinition(), + // FIXME: Avoid const_cast by refactoring criteria subtree + return _domains.setApplicationRule(strDomain, strConfiguration, strApplicationRule, + const_cast(_criteria).getSelectionCriteriaDefinition(), strError); } bool CParameterMgr::clearApplicationRule(const string& strDomain, const string& strConfiguration, string& strError) { - return getConfigurableDomains()->clearApplicationRule(strDomain, strConfiguration, strError); + return _domains.clearApplicationRule(strDomain, strConfiguration, strError); } bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSettings, @@ -2279,15 +2268,14 @@ bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSetti return false; } - // Root element - CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); // Context - CXmlDomainImportContext xmlDomainImportContext(strError, bWithSettings, *getSystemClass()); + CXmlDomainImportContext xmlDomainImportContext(strError, bWithSettings, _systemClass); // Selection criteria definition for rule creation + // FIXME: Avoid const_cast by refactoring criteria subtree xmlDomainImportContext.setSelectionCriteriaDefinition( - getConstSelectionCriteria()->getSelectionCriteriaDefinition()); + const_cast(_criteria).getSelectionCriteriaDefinition()); // Init serializing context xmlDomainImportContext.set( @@ -2296,7 +2284,7 @@ bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSetti // Get Schema file associated to root element string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + - pConfigurableDomains->getKind() + ".xsd"; + _domains.getKind() + ".xsd"; // Xml Source CXmlDocSource* pSource; @@ -2305,36 +2293,36 @@ bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSetti // when importing from a file strXmlSource is the file name pSource = new CXmlFileDocSource(strXmlSource, strXmlSchemaFilePath, - pConfigurableDomains->getKind(), - pConfigurableDomains->getName(), "SystemClassName", + _domains.getKind(), + _domains.getName(), "SystemClassName", _bValidateSchemasOnStart); } else { // when importing from an xml string, strXmlSource contains the string pSource = new CXmlStringDocSource(strXmlSource, strXmlSchemaFilePath, - pConfigurableDomains->getKind(), - pConfigurableDomains->getName(), "SystemClassName", + _domains.getKind(), + _domains.getName(), "SystemClassName", _bValidateSchemasOnStart); } // Start clean - pConfigurableDomains->clean(); + _domains.clean(); // Use a doc sink that instantiate Configurable Domains from the given doc source - CXmlMemoryDocSink memorySink(pConfigurableDomains); + CXmlMemoryDocSink memorySink(&_domains); bool bProcessSuccess = memorySink.process(*pSource, xmlDomainImportContext); if (!bProcessSuccess) { //Cleanup - pConfigurableDomains->clean(); + _domains.clean(); } else { // Validate domains after XML import - pConfigurableDomains->validate(_pMainParameterBlackboard); + _domains.validate(_pMainParameterBlackboard); } @@ -2407,8 +2395,6 @@ bool CParameterMgr::serializeElement(string& strXmlDest, bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile, string& strError) const { - const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); - CXmlDomainExportContext xmlDomainExportContext(strError, bWithSettings); xmlDomainExportContext.setValueSpaceRaw(_bValueSpaceIsRaw); @@ -2416,18 +2402,15 @@ bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, boo xmlDomainExportContext.setOutputRawFormat(_bOutputRawFormatIsHex); - return serializeElement(strXmlDest, xmlDomainExportContext, bToFile, - *pConfigurableDomains, strError); + return serializeElement(strXmlDest, xmlDomainExportContext, bToFile, _domains, strError); } bool CParameterMgr::exportSingleDomainXml(string& strXmlDest, const string& strDomainName, bool bWithSettings, bool bToFile, string& strError) const { - const CConfigurableDomains* pAllDomains = getConstConfigurableDomains(); - // Element to be serialized const CConfigurableDomain* pRequestedDomain = - pAllDomains->findConfigurableDomain(strDomainName, strError); + _domains.findConfigurableDomain(strDomainName, strError); if (!pRequestedDomain) { return false; @@ -2458,11 +2441,9 @@ bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strEr return false; } - // Root element - CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); // Serialize in - return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError); + return _domains.serializeSettings(strFileName, false, _uiStructureChecksum, strError); } bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError) @@ -2475,11 +2456,8 @@ bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strEr return false; } - // Root element - CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); - // Serialize out - return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError); + return _domains.serializeSettings(strFileName, true, _uiStructureChecksum, strError); } // For tuning, check we're in tuning mode @@ -2526,7 +2504,8 @@ void CParameterMgr::feedElementLibraries() // Parameter creation CElementLibrary* pParameterCreationLibrary = new CElementLibrary; - pParameterCreationLibrary->addElementBuilder("Subsystem", new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); + pParameterCreationLibrary->addElementBuilder( + "Subsystem", new CSubsystemElementBuilder(_systemClass.getSubsystemLibrary())); pParameterCreationLibrary->addElementBuilder("ComponentType", new TNamedElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("Component", new TNamedElementBuilderTemplate()); pParameterCreationLibrary->addElementBuilder("BitParameter", new TNamedElementBuilderTemplate()); @@ -2576,7 +2555,7 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) } // Start server if tuning allowed - if (getConstFrameworkConfiguration()->isTuningAllowed()) { + if (_pfwConfiguration.isTuningAllowed()) { info() << "Loading remote processor library"; @@ -2609,16 +2588,16 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) } // Create server - _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler); + _pRemoteProcessorServer = + pfnCreateRemoteProcessorServer(_pfwConfiguration.getServerPort(), _pCommandHandler); - info() << "Starting remote processor server on port " - << getConstFrameworkConfiguration()->getServerPort(); + info() << "Starting remote processor server on port " << _pfwConfiguration.getServerPort(); // Start if (!_pRemoteProcessorServer->start()) { ostringstream oss; oss << "ParameterMgr: Unable to start remote processor server on port " - << getConstFrameworkConfiguration()->getServerPort(); + << _pfwConfiguration.getServerPort(); strError = oss.str(); return false; @@ -2628,53 +2607,6 @@ bool CParameterMgr::handleRemoteProcessingInterface(string& strError) return true; } -// Children typwise access -CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration() -{ - return static_cast(getChild(EFrameworkConfiguration)); -} - -const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration() -{ - return getFrameworkConfiguration(); -} - -CSelectionCriteria* CParameterMgr::getSelectionCriteria() -{ - return static_cast(getChild(ESelectionCriteria)); -} - -const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria() -{ - return static_cast(getChild(ESelectionCriteria)); -} - -CSystemClass* CParameterMgr::getSystemClass() -{ - return static_cast(getChild(ESystemClass)); -} - -const CSystemClass* CParameterMgr::getConstSystemClass() const -{ - return static_cast(getChild(ESystemClass)); -} - -// Configurable Domains -CConfigurableDomains* CParameterMgr::getConfigurableDomains() -{ - return static_cast(getChild(EConfigurableDomains)); -} - -const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() -{ - return static_cast(getChild(EConfigurableDomains)); -} - -const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const -{ - return static_cast(getChild(EConfigurableDomains)); -} - // Apply configurations void CParameterMgr::doApplyConfigurations(bool bForce) { @@ -2684,14 +2616,14 @@ void CParameterMgr::doApplyConfigurations(bool bForce) core::Results infos; // Check subsystems that need resync - getSystemClass()->checkForSubsystemsToResync(syncerSet, infos); + _systemClass.checkForSubsystemsToResync(syncerSet, infos); // Ensure application of currently selected configurations - getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce, infos); + _domains.apply(_pMainParameterBlackboard, syncerSet, bForce, infos); info() << infos; // Reset the modified status of the current criteria to indicate that a new configuration has been applied - getSelectionCriteria()->resetModifiedStatus(); + _criteria.resetModifiedStatus(); } // Export to XML string diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index c4e196121..bd7d4850b 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -40,6 +40,10 @@ #include "XmlDocSink.h" #include "XmlDocSource.h" #include "Results.h" +#include "ParameterFrameworkConfiguration.h" +#include "SelectionCriteria.h" +#include "ConfigurableDomains.h" +#include "SystemClass.h" #include #include @@ -48,26 +52,16 @@ class CElementLibrarySet; class CSubsystemLibrary; -class CSystemClass; -class CSelectionCriteria; -class CParameterFrameworkConfiguration; class CSystemClassConfiguration; class CParameterBlackboard; -class CConfigurableDomains; class IRemoteProcessorServerInterface; class CParameterHandle; class CSubsystemPlugins; class CParameterAccessContext; class CConfigurableElement; -class CParameterMgr : private CElement +class CParameterMgr { - enum ChildElement { - EFrameworkConfiguration, - ESelectionCriteria, - ESystemClass, - EConfigurableDomains - }; enum ElementLibrary { EFrameworkConfigurationLibrary, EParameterCreationLibrary, @@ -351,9 +345,6 @@ class CParameterMgr : private CElement const std::string& strRootElementType, std::string& strResult) const; - // CElement - virtual std::string getKind() const; - private: CParameterMgr(const CParameterMgr&); CParameterMgr& operator=(const CParameterMgr&); @@ -545,24 +536,6 @@ class CParameterMgr : private CElement bool importDomainFromFile(const std::string& strXmlFilePath, bool bOverwrite, std::string& strError); - - // 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; - // Apply configurations void doApplyConfigurations(bool bForce); @@ -663,5 +636,17 @@ class CParameterMgr : private CElement * If set to false, no .xml/xsd validation will happen (default behaviour) */ bool _bValidateSchemasOnStart; + + /** Parameter Configuration information */ + CParameterFrameworkConfiguration _pfwConfiguration; + + /** Selection Criteria used in application rules */ + CSelectionCriteria _criteria; + + /** Subsystems handler */ + CSystemClass _systemClass; + + /** Application domains */ + CConfigurableDomains _domains; };