summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2012-02-02 17:12:41 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:15:02 +0100
commit68808c650fc95660c9eb0d8f0bf97701b8076eb8 (patch)
tree57fa617254a8895609a9c17608141b83f263bc2d
parent0bd50546a8d06a6865d32c695adf8893fa71250a (diff)
downloadexternal_parameter-framework-68808c650fc95660c9eb0d8f0bf97701b8076eb8.zip
external_parameter-framework-68808c650fc95660c9eb0d8f0bf97701b8076eb8.tar.gz
external_parameter-framework-68808c650fc95660c9eb0d8f0bf97701b8076eb8.tar.bz2
PFW: Enum parameter mapping
BZ: 22125 Enum parameter types are now fully parsed as any other types, which allow Mapping attributes to be correctly interpreted. Now inner structure of enum parameter types is based on automatically created objects: ValuePair Slight adaptation of to ICS environment in Android.mk files and XmlComposer (time.h). More explicit error statement issued in case of plugin load failure in SystemClass.cpp. Added a log for Alsa mixer elements accesses. Change-Id: Ia71fd854e639a288c5dae79260b1e2a0eb1a7ac2 Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com> Reviewed-on: http://android.intel.com:8080/33756 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--Schemas/Parameter.xsd2
-rw-r--r--parameter/Android.mk3
-rw-r--r--parameter/EnumParameterType.cpp82
-rw-r--r--parameter/EnumParameterType.h14
-rw-r--r--parameter/EnumValuePair.cpp75
-rw-r--r--parameter/EnumValuePair.h56
-rw-r--r--parameter/ParameterMgr.cpp8
-rw-r--r--parameter/SystemClass.cpp2
-rw-r--r--xmlserializer/XmlComposer.cpp2
9 files changed, 190 insertions, 54 deletions
diff --git a/Schemas/Parameter.xsd b/Schemas/Parameter.xsd
index 098ee26..81f87c8 100644
--- a/Schemas/Parameter.xsd
+++ b/Schemas/Parameter.xsd
@@ -63,7 +63,7 @@
<xs:sequence>
<xs:element name="ValuePair" maxOccurs="unbounded">
<xs:complexType>
- <xs:attribute name="Literal" type="xs:NMTOKEN" use="required"/>
+ <xs:attribute name="Literal" type="xs:string" use="required"/>
<xs:attribute name="Numerical" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
diff --git a/parameter/Android.mk b/parameter/Android.mk
index eab9430..90e9ada 100644
--- a/parameter/Android.mk
+++ b/parameter/Android.mk
@@ -92,7 +92,8 @@ LOCAL_SRC_FILES:= \
ParameterHandle.cpp \
ParameterAdaptation.cpp \
LinearParameterAdaptation.cpp \
- RuleParser.cpp
+ RuleParser.cpp \
+ EnumValuePair.cpp
LOCAL_MODULE:= libparameter
diff --git a/parameter/EnumParameterType.cpp b/parameter/EnumParameterType.cpp
index 87cefcd..60c937c 100644
--- a/parameter/EnumParameterType.cpp
+++ b/parameter/EnumParameterType.cpp
@@ -35,6 +35,7 @@
#include <ctype.h>
#include <assert.h>
#include "ParameterAccessContext.h"
+#include "EnumValuePair.h"
#define base CParameterType
@@ -47,6 +48,11 @@ string CEnumParameterType::getKind() const
return "EnumParameter";
}
+bool CEnumParameterType::childrenAreDynamic() const
+{
+ return true;
+}
+
// Element properties
void CEnumParameterType::showProperties(string& strResult) const
{
@@ -55,14 +61,17 @@ void CEnumParameterType::showProperties(string& strResult) const
strResult += "Value Pairs:\n";
// Show all value pairs
- ValuePairListIterator it;
+ uint32_t uiChild;
+ uint32_t uiNbChildren = getNbChildren();
+
+ for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
- for (it = _valuePairList.begin(); it != _valuePairList.end(); ++it) {
+ const CEnumValuePair* pValuePair = static_cast<const CEnumValuePair*>(getChild(uiChild));
strResult += "\tLiteral: \"";
- strResult += it->_strLiteral;
+ strResult += pValuePair->getName();
strResult += "\", Numerical: ";
- strResult += toString(it->_iNumerical);
+ strResult += pValuePair->getNumericalAsString();
strResult += "\n";
}
}
@@ -75,26 +84,8 @@ bool CEnumParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingC
// Size
setSize(uiSizeInBits / 8);
- // Get value pairs
- CXmlElement::CChildIterator it(xmlElement);
-
- CXmlElement xmlValuePairElement;
-
- while (it.next(xmlValuePairElement)) {
-
- _valuePairList.push_back(SValuePair(xmlValuePairElement.getAttributeString("Literal"), xmlValuePairElement.getAttributeSignedInteger("Numerical")));
- }
-
- // Check value pair list
- if (_valuePairList.empty()) {
-
- serializingContext.setError("No Value pairs provided for element " + xmlElement.getPath());
-
- return false;
- }
-
- // Don't dig
- return true;
+ // Base
+ return base::fromXml(xmlElement, serializingContext);
}
// Conversion (tuning)
@@ -214,10 +205,13 @@ bool CEnumParameterType::fromBlackboard(int32_t& iUserValue, uint32_t uiValue, C
// Default value handling (simulation only)
uint32_t CEnumParameterType::getDefaultValue() const
{
- assert(!_valuePairList.empty());
+ if (!getNbChildren()) {
+
+ return 0;
+ }
- // Return first item
- return _valuePairList.front()._iNumerical;
+ // Return first available numerical
+ return static_cast<const CEnumValuePair*>(getChild(0))->getNumerical();
}
// Check string is a number
@@ -231,47 +225,59 @@ bool CEnumParameterType::isNumber(const string& strValue)
// Literal - numerical conversions
bool CEnumParameterType::getLiteral(int32_t iNumerical, string& strLiteral) const
{
- ValuePairListIterator it;
+ uint32_t uiChild;
+ uint32_t uiNbChildren = getNbChildren();
- for (it = _valuePairList.begin(); it != _valuePairList.end(); ++it) {
+ for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
- if (it->_iNumerical == iNumerical) {
+ const CEnumValuePair* pValuePair = static_cast<const CEnumValuePair*>(getChild(uiChild));
- strLiteral = it->_strLiteral;
+ if (pValuePair->getNumerical() == iNumerical) {
+
+ strLiteral = pValuePair->getName();
return true;
}
}
+
return false;
}
bool CEnumParameterType::getNumerical(const string& strLiteral, int32_t& iNumerical) const
{
- ValuePairListIterator it;
+ uint32_t uiChild;
+ uint32_t uiNbChildren = getNbChildren();
+
+ for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
- for (it = _valuePairList.begin(); it != _valuePairList.end(); ++it) {
+ const CEnumValuePair* pValuePair = static_cast<const CEnumValuePair*>(getChild(uiChild));
- if (it->_strLiteral == strLiteral) {
+ if (pValuePair->getName() == strLiteral) {
- iNumerical = it->_iNumerical;
+ iNumerical = pValuePair->getNumerical();
return true;
}
}
+
return false;
}
// Numerical validity
bool CEnumParameterType::isValid(int32_t iNumerical) const
{
- ValuePairListIterator it;
+ uint32_t uiChild;
+ uint32_t uiNbChildren = getNbChildren();
+
+ for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
- for (it = _valuePairList.begin(); it != _valuePairList.end(); ++it) {
+ const CEnumValuePair* pValuePair = static_cast<const CEnumValuePair*>(getChild(uiChild));
- if (it->_iNumerical == iNumerical) {
+ if (pValuePair->getNumerical() == iNumerical) {
return true;
}
}
+
return false;
}
diff --git a/parameter/EnumParameterType.h b/parameter/EnumParameterType.h
index 9ef6343..a195fea 100644
--- a/parameter/EnumParameterType.h
+++ b/parameter/EnumParameterType.h
@@ -36,15 +36,6 @@
class CEnumParameterType : public CParameterType
{
- // Value pairs
- struct SValuePair
- {
- SValuePair(const string& strLiteral, int32_t iNumerical) : _strLiteral(strLiteral), _iNumerical(iNumerical) {}
-
- string _strLiteral;
- int32_t _iNumerical;
- };
- typedef list<SValuePair>::const_iterator ValuePairListIterator;
public:
CEnumParameterType(const string& strName);
@@ -68,6 +59,8 @@ public:
// CElement
virtual string getKind() const;
private:
+ // Returns true if children dynamic creation is to be dealt with
+ virtual bool childrenAreDynamic() const;
// Check string is a number
static bool isNumber(const string& strValue);
@@ -77,7 +70,4 @@ private:
// Numerical validity
bool isValid(int32_t iNumerical) const;
-
- // Value pairs
- list<SValuePair> _valuePairList;
};
diff --git a/parameter/EnumValuePair.cpp b/parameter/EnumValuePair.cpp
new file mode 100644
index 0000000..789d8f9
--- /dev/null
+++ b/parameter/EnumValuePair.cpp
@@ -0,0 +1,75 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "EnumValuePair.h"
+
+#define base CElement
+
+CEnumValuePair::CEnumValuePair() : _iNumerical(0)
+{
+}
+
+// CElement
+string CEnumValuePair::getKind() const
+{
+ return "ValuePair";
+}
+
+// Numerical
+int32_t CEnumValuePair::getNumerical() const
+{
+ return _iNumerical;
+}
+
+string CEnumValuePair::getNumericalAsString() const
+{
+ return toString(_iNumerical);
+}
+
+// From IXmlSink
+bool CEnumValuePair::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
+{
+ // Literal
+ setName(xmlElement.getAttributeString("Literal"));
+
+ // Numerical
+ _iNumerical = xmlElement.getAttributeSignedInteger("Numerical");
+
+ // Base
+ return base::fromXml(xmlElement, serializingContext);
+}
+
+// Content dumping
+void CEnumValuePair::logValue(string& strValue, CErrorContext& errorContext) const
+{
+ (void)errorContext;
+ // Convert value
+ strValue = getNumericalAsString();
+}
diff --git a/parameter/EnumValuePair.h b/parameter/EnumValuePair.h
new file mode 100644
index 0000000..717fc72
--- /dev/null
+++ b/parameter/EnumValuePair.h
@@ -0,0 +1,56 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "Element.h"
+
+class CEnumValuePair : public CElement
+{
+public:
+ CEnumValuePair();
+
+ // Numerical
+ int32_t getNumerical() const;
+ string getNumericalAsString() const;
+
+ // From IXmlSink
+ virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
+
+ // CElement
+ virtual string getKind() const;
+protected:
+ // Content dumping
+ virtual void logValue(string& strValue, CErrorContext& errorContext) const;
+private:
+ // Numerical
+ int32_t _iNumerical;
+};
+
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 9a180fa..6ef37bb 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -77,6 +77,7 @@
#include <assert.h>
#include "ParameterHandle.h"
#include "LinearParameterAdaptation.h"
+#include "EnumValuePair.h"
#define base CElement
@@ -1302,6 +1303,12 @@ bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bS
// Define context
CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
+ // Auto Sync
+ if (bSet) {
+
+ parameterAccessContext.setAutoSync(_bAutoSyncOn);
+ }
+
// Do the get
return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
}
@@ -1752,6 +1759,7 @@ void CParameterMgr::feedElementLibraries()
pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
+ pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp
index 532473a..6409c9b 100644
--- a/parameter/SystemClass.cpp
+++ b/parameter/SystemClass.cpp
@@ -208,7 +208,7 @@ bool CSystemClass::loadPlugins(list<string>& lstrPluginFiles, string& strError)
if (!lib_handle) {
// Failed
- log("Plugin load failed, proceeding on with remaining ones");
+ log("Plugin load failed: %s, proceeding on with remaining ones", dlerror());
// Next plugin
++it;
diff --git a/xmlserializer/XmlComposer.cpp b/xmlserializer/XmlComposer.cpp
index ff607dd..ebbcf1b 100644
--- a/xmlserializer/XmlComposer.cpp
+++ b/xmlserializer/XmlComposer.cpp
@@ -31,7 +31,7 @@
#include "XmlComposer.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include <time.h>
+#include <sys/time.h>
#define base CXmlSerializer