summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Gaffie <francois.gaffie@renault.com>2021-10-22 17:22:59 +0200
committerEric Laurent <elaurent@google.com>2021-12-17 14:08:14 +0100
commitff18ccf5dbbc8482ef76e6af3da616e1c094dc47 (patch)
tree6eeb4c3875d42157c896d0bd89b87c290ea1dc37
parent5944d00c031ffb81dbbf8c8e570ac10e7ffc938a (diff)
downloadparameter-framework-ff18ccf5dbbc8482ef76e6af3da616e1c094dc47.tar.gz
Migrate bitfield criterion type to 64bits
This CL moves inclusive criterion type to 64bits in order to fix (temporarily?) the Audio Output Devices type representation that exceed 32 devices currently. Test: make Signed-off-by: Francois Gaffie <francois.gaffie@renault.com> Change-Id: I6fb8148af89b5070c624f02d9d0bb139e566079a
-rw-r--r--upstream/bindings/c/ParameterFramework.cpp8
-rw-r--r--upstream/bindings/c/ParameterFramework.h5
-rw-r--r--upstream/bindings/python/pfw.i13
-rw-r--r--upstream/parameter/SelectionCriterion.cpp12
-rw-r--r--upstream/parameter/SelectionCriterion.h14
-rw-r--r--upstream/parameter/SelectionCriterionRule.h2
-rw-r--r--upstream/parameter/SelectionCriterionType.cpp17
-rw-r--r--upstream/parameter/SelectionCriterionType.h14
-rw-r--r--upstream/parameter/include/SelectionCriterionInterface.h5
-rw-r--r--upstream/parameter/include/SelectionCriterionTypeInterface.h10
-rw-r--r--upstream/test/test-platform/TestPlatform.cpp16
-rw-r--r--upstream/test/test-platform/TestPlatform.h2
-rw-r--r--upstream/tools/xmlGenerator/domainGeneratorConnector.cpp2
13 files changed, 63 insertions, 57 deletions
diff --git a/upstream/bindings/c/ParameterFramework.cpp b/upstream/bindings/c/ParameterFramework.cpp
index 858994b..1e09eea 100644
--- a/upstream/bindings/c/ParameterFramework.cpp
+++ b/upstream/bindings/c/ParameterFramework.cpp
@@ -197,10 +197,10 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
assert(type != nullptr);
// Add criterion values
for (size_t valueIndex = 0; criterion.values[valueIndex] != nullptr; ++valueIndex) {
- int value;
+ uint64_t value;
if (criterion.inclusive) {
// Check that (int)1 << valueIndex would not overflow (UB)
- if (std::numeric_limits<int>::max() >> valueIndex == 0) {
+ if (std::numeric_limits<uint64_t>::max() >> valueIndex == 0) {
return status.failure("Too many values for criterion " +
string(criterion.name));
}
@@ -253,7 +253,7 @@ static pfw::Criterion *getCriterion(const pfw::Criteria &criteria, const string
return it == criteria.end() ? nullptr : it->second;
}
-bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
+bool pfwSetCriterion(PfwHandler *handle, const char name[], uint64_t value)
{
Status &status = handle->lastStatus;
if (handle->pfw == nullptr) {
@@ -267,7 +267,7 @@ bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
criterion->setCriterionState(value);
return status.success();
}
-bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
+bool pfwGetCriterion(const PfwHandler *handle, const char name[], uint64_t *value)
{
Status &status = handle->lastStatus;
if (handle->pfw == nullptr) {
diff --git a/upstream/bindings/c/ParameterFramework.h b/upstream/bindings/c/ParameterFramework.h
index c136845..d763f21 100644
--- a/upstream/bindings/c/ParameterFramework.h
+++ b/upstream/bindings/c/ParameterFramework.h
@@ -192,14 +192,15 @@ const char *pfwGetLastError(const PfwHandler *handle) NONNULL;
* @return true on success and false on failure.
*/
CPARAMETER_EXPORT
-bool pfwSetCriterion(PfwHandler *handle, const char name[], int value) NONNULL USERESULT;
+bool pfwSetCriterion(PfwHandler *handle, const char name[], uint64_t value) NONNULL USERESULT;
/** Get a criterion value given its name.
* Same usage as pfwSetCriterion except that value is an out param.
* Get criterion will return the last value setted with pfwSetCriterion independantly of
* pfwCommitCritenio.
*/
CPARAMETER_EXPORT
-bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value) NONNULL USERESULT;
+bool pfwGetCriterion(const PfwHandler *handle, const char name[],
+ uint64_t *value) NONNULL USERESULT;
/** Commit criteria change and change parameters according to the configurations.
* Criterion do not have impact on the parameters value when changed,
diff --git a/upstream/bindings/python/pfw.i b/upstream/bindings/python/pfw.i
index a1bfe62..7a4b151 100644
--- a/upstream/bindings/python/pfw.i
+++ b/upstream/bindings/python/pfw.i
@@ -206,11 +206,12 @@ class ISelectionCriterionTypeInterface
%}
public:
- virtual bool addValuePair(int iValue, const std::string& strValue, std::string& strError) = 0;
- virtual bool getNumericalValue(const std::string& strValue, int& iValue) const = 0;
- virtual bool getLiteralValue(int iValue, std::string& strValue) const = 0;
+ virtual bool addValuePair(uint64_t iValue, const std::string& strValue,
+ std::string& strError) = 0;
+ virtual bool getNumericalValue(const std::string& strValue, uint64_t& iValue) const = 0;
+ virtual bool getLiteralValue(uint64_t iValue, std::string& strValue) const = 0;
virtual bool isTypeInclusive() const = 0;
- virtual std::string getFormattedState(int iValue) const = 0;
+ virtual std::string getFormattedState(uint64_t iValue) const = 0;
protected:
virtual ~ISelectionCriterionTypeInterface() {}
@@ -223,8 +224,8 @@ class ISelectionCriterionInterface
%}
public:
- virtual void setCriterionState(int iState) = 0;
- virtual int getCriterionState() const = 0;
+ virtual void setCriterionState(uint64_t iState) = 0;
+ virtual uint64_t getCriterionState() const = 0;
virtual std::string getCriterionName() const = 0;
virtual const ISelectionCriterionTypeInterface* getCriterionType() const = 0;
diff --git a/upstream/parameter/SelectionCriterion.cpp b/upstream/parameter/SelectionCriterion.cpp
index f99abec..97203d6 100644
--- a/upstream/parameter/SelectionCriterion.cpp
+++ b/upstream/parameter/SelectionCriterion.cpp
@@ -60,7 +60,7 @@ void CSelectionCriterion::resetModifiedStatus()
/// From ISelectionCriterionInterface
// State
-void CSelectionCriterion::setCriterionState(int iState)
+void CSelectionCriterion::setCriterionState(uint64_t iState)
{
// Check for a change
if (_iState != iState) {
@@ -85,7 +85,7 @@ void CSelectionCriterion::setCriterionState(int iState)
}
}
-int CSelectionCriterion::getCriterionState() const
+uint64_t CSelectionCriterion::getCriterionState() const
{
return _iState;
}
@@ -103,24 +103,24 @@ const ISelectionCriterionTypeInterface *CSelectionCriterion::getCriterionType()
}
/// Match methods
-bool CSelectionCriterion::is(int iState) const
+bool CSelectionCriterion::is(uint64_t iState) const
{
return _iState == iState;
}
-bool CSelectionCriterion::isNot(int iState) const
+bool CSelectionCriterion::isNot(uint64_t iState) const
{
return _iState != iState;
}
-bool CSelectionCriterion::includes(int iState) const
+bool CSelectionCriterion::includes(uint64_t iState) const
{
// For inclusive criterion, Includes checks if ALL the bit sets in iState are set in the
// current _iState.
return (_iState & iState) == iState;
}
-bool CSelectionCriterion::excludes(int iState) const
+bool CSelectionCriterion::excludes(uint64_t iState) const
{
return (_iState & iState) == 0;
}
diff --git a/upstream/parameter/SelectionCriterion.h b/upstream/parameter/SelectionCriterion.h
index 9c2dfe2..079ea43 100644
--- a/upstream/parameter/SelectionCriterion.h
+++ b/upstream/parameter/SelectionCriterion.h
@@ -47,8 +47,8 @@ public:
/// From ISelectionCriterionInterface
// State
- void setCriterionState(int iState) override;
- int getCriterionState() const override;
+ void setCriterionState(uint64_t iState) override;
+ uint64_t getCriterionState() const override;
// Name
std::string getCriterionName() const override;
// Type
@@ -58,10 +58,10 @@ public:
void resetModifiedStatus();
/// Match methods
- bool is(int iState) const;
- bool isNot(int iState) const;
- bool includes(int iState) const;
- bool excludes(int iState) const;
+ bool is(uint64_t iState) const;
+ bool isNot(uint64_t iState) const;
+ bool includes(uint64_t iState) const;
+ bool excludes(uint64_t iState) const;
/// User request
std::string getFormattedDescription(bool bWithTypeInfo, bool bHumanReadable) const;
@@ -80,7 +80,7 @@ public:
private:
// Current state
- int _iState{0};
+ uint64_t _iState{0};
// Type
const CSelectionCriterionType *_pType;
diff --git a/upstream/parameter/SelectionCriterionRule.h b/upstream/parameter/SelectionCriterionRule.h
index 7dac343..cbdc5ca 100644
--- a/upstream/parameter/SelectionCriterionRule.h
+++ b/upstream/parameter/SelectionCriterionRule.h
@@ -89,7 +89,7 @@ private:
MatchesWhen _eMatchesWhen{EIs};
// Value
- int32_t _iMatchValue{0};
+ uint64_t _iMatchValue{0};
// Used for XML MatchesWhen attribute parsing
static const SMatchingRuleDescription _astMatchesWhen[ENbMatchesWhen];
diff --git a/upstream/parameter/SelectionCriterionType.cpp b/upstream/parameter/SelectionCriterionType.cpp
index d97d18b..fe8246f 100644
--- a/upstream/parameter/SelectionCriterionType.cpp
+++ b/upstream/parameter/SelectionCriterionType.cpp
@@ -51,14 +51,15 @@ std::string CSelectionCriterionType::getKind() const
}
// From ISelectionCriterionTypeInterface
-bool CSelectionCriterionType::addValuePair(int iValue, const std::string &strValue,
+bool CSelectionCriterionType::addValuePair(uint64_t iValue, const std::string &strValue,
std::string &strError)
{
// Check 1 bit set only for inclusive types
if (_bInclusive && (!iValue || (iValue & (iValue - 1)))) {
std::ostringstream error;
- error << "Rejecting value pair association: 0x" << std::hex << iValue << " - " << strValue
+ error << "CSelectionCriterionType Rejecting value pair association: 0x" << std::hex
+ << iValue << " - " << strValue
<< " for Selection Criterion Type " << getName();
strError = error.str();
@@ -90,14 +91,14 @@ bool CSelectionCriterionType::addValuePair(int iValue, const std::string &strVal
return true;
}
-bool CSelectionCriterionType::getNumericalValue(const std::string &strValue, int &iValue) const
+bool CSelectionCriterionType::getNumericalValue(const std::string &strValue, uint64_t &iValue) const
{
if (_bInclusive) {
Tokenizer tok(strValue, _strDelimiter);
std::vector<std::string> astrValues = tok.split();
size_t uiNbValues = astrValues.size();
- int iResult = 0;
+ uint64_t iResult = 0;
size_t uiValueIndex;
iValue = 0;
@@ -116,7 +117,7 @@ bool CSelectionCriterionType::getNumericalValue(const std::string &strValue, int
}
bool CSelectionCriterionType::getAtomicNumericalValue(const std::string &strValue,
- int &iValue) const
+ uint64_t &iValue) const
{
auto it = _numToLitMap.find(strValue);
@@ -129,7 +130,7 @@ bool CSelectionCriterionType::getAtomicNumericalValue(const std::string &strValu
return false;
}
-bool CSelectionCriterionType::getLiteralValue(int iValue, std::string &strValue) const
+bool CSelectionCriterionType::getLiteralValue(uint64_t iValue, std::string &strValue) const
{
NumToLitMapConstIt it;
@@ -176,7 +177,7 @@ std::string CSelectionCriterionType::listPossibleValues() const
}
// Formatted state
-std::string CSelectionCriterionType::getFormattedState(int iValue) const
+std::string CSelectionCriterionType::getFormattedState(uint64_t iValue) const
{
std::string strFormattedState;
@@ -187,7 +188,7 @@ std::string CSelectionCriterionType::getFormattedState(int iValue) const
for (size_t bit = 0; bit < sizeof(iValue) * CHAR_BIT; bit++) {
- int iSingleBitValue = iValue & (1 << bit);
+ uint64_t iSingleBitValue = iValue & (0x1ull << bit);
// Check if current bit is set
if (!iSingleBitValue) {
diff --git a/upstream/parameter/SelectionCriterionType.h b/upstream/parameter/SelectionCriterionType.h
index 4b2f767..10ed919 100644
--- a/upstream/parameter/SelectionCriterionType.h
+++ b/upstream/parameter/SelectionCriterionType.h
@@ -36,13 +36,13 @@
class CSelectionCriterionType : public CElement, public ISelectionCriterionTypeInterface
{
- typedef std::map<std::string, int>::const_iterator NumToLitMapConstIt;
+ typedef std::map<std::string, uint64_t>::const_iterator NumToLitMapConstIt;
public:
CSelectionCriterionType(bool bIsInclusive);
// From ISelectionCriterionTypeInterface
- bool addValuePair(int iValue, const std::string &strValue, std::string &strError) override;
+ bool addValuePair(uint64_t iValue, const std::string &strValue, std::string &strError) override;
/**
* Retrieve the numerical value from the std::string representation of the criterion type.
*
@@ -53,15 +53,15 @@ public:
*
* @return true if integer value retrieved from the std::string one, false otherwise.
*/
- bool getNumericalValue(const std::string &strValue, int &iValue) const override;
- bool getLiteralValue(int iValue, std::string &strValue) const override;
+ bool getNumericalValue(const std::string &strValue, uint64_t &iValue) const override;
+ bool getLiteralValue(uint64_t iValue, std::string &strValue) const override;
bool isTypeInclusive() const override;
// Value list
std::string listPossibleValues() const;
// Formatted state
- std::string getFormattedState(int iValue) const override;
+ std::string getFormattedState(uint64_t iValue) const override;
/**
* Export to XML
@@ -85,9 +85,9 @@ private:
*
* @return true if integer value retrieved from the std::string one, false otherwise.
*/
- bool getAtomicNumericalValue(const std::string &strValue, int &iValue) const;
+ bool getAtomicNumericalValue(const std::string &strValue, uint64_t &iValue) const;
bool _bInclusive;
- std::map<std::string, int> _numToLitMap;
+ std::map<std::string, uint64_t> _numToLitMap;
static const std::string _strDelimiter; /**< Inclusive criterion type delimiter. */
};
diff --git a/upstream/parameter/include/SelectionCriterionInterface.h b/upstream/parameter/include/SelectionCriterionInterface.h
index 6eb2d8a..2080ff9 100644
--- a/upstream/parameter/include/SelectionCriterionInterface.h
+++ b/upstream/parameter/include/SelectionCriterionInterface.h
@@ -30,14 +30,15 @@
#pragma once
#include <string>
+#include <stdint.h>
#include "SelectionCriterionTypeInterface.h"
class ISelectionCriterionInterface
{
public:
- virtual void setCriterionState(int iState) = 0;
- virtual int getCriterionState() const = 0;
+ virtual void setCriterionState(uint64_t iState) = 0;
+ virtual uint64_t getCriterionState() const = 0;
virtual std::string getCriterionName() const = 0;
virtual const ISelectionCriterionTypeInterface *getCriterionType() const = 0;
diff --git a/upstream/parameter/include/SelectionCriterionTypeInterface.h b/upstream/parameter/include/SelectionCriterionTypeInterface.h
index bebcfc7..10f4c88 100644
--- a/upstream/parameter/include/SelectionCriterionTypeInterface.h
+++ b/upstream/parameter/include/SelectionCriterionTypeInterface.h
@@ -30,6 +30,7 @@
#pragma once
#include <string>
+#include <stdint.h>
class ISelectionCriterionTypeInterface
{
@@ -42,11 +43,12 @@ public:
* @param[out] strError string containing error information we can provide to client
* @return true if succeed false otherwise
*/
- virtual bool addValuePair(int iValue, const std::string &strValue, std::string &strError) = 0;
- virtual bool getNumericalValue(const std::string &strValue, int &iValue) const = 0;
- virtual bool getLiteralValue(int iValue, std::string &strValue) const = 0;
+ virtual bool addValuePair(uint64_t iValue, const std::string &strValue,
+ std::string &strError) = 0;
+ virtual bool getNumericalValue(const std::string &strValue, uint64_t &iValue) const = 0;
+ virtual bool getLiteralValue(uint64_t iValue, std::string &strValue) const = 0;
virtual bool isTypeInclusive() const = 0;
- virtual std::string getFormattedState(int iValue) const = 0;
+ virtual std::string getFormattedState(uint64_t iValue) const = 0;
protected:
virtual ~ISelectionCriterionTypeInterface() {}
diff --git a/upstream/test/test-platform/TestPlatform.cpp b/upstream/test/test-platform/TestPlatform.cpp
index d090939..6e57f52 100644
--- a/upstream/test/test-platform/TestPlatform.cpp
+++ b/upstream/test/test-platform/TestPlatform.cpp
@@ -227,7 +227,7 @@ CTestPlatform::CommandReturn CTestPlatform::setCriterionState(const IRemoteComma
bool bSuccess;
- uint32_t state;
+ uint64_t state;
if (convertTo(remoteCommand.getArgument(1), state)) {
// Sucessfull conversion, set criterion state by numerical state
@@ -267,7 +267,7 @@ bool CTestPlatform::createExclusiveSelectionCriterionFromStateList(
const std::string &strValue = remoteCommand.getArgument(state + 1);
// FIXME state type vs addValuePair params
- if (!pCriterionType->addValuePair(int(state), strValue, strResult)) {
+ if (!pCriterionType->addValuePair(uint64_t(state), strValue, strResult)) {
strResult = "Unable to add value: " + strValue + ": " + strResult;
@@ -294,7 +294,7 @@ bool CTestPlatform::createInclusiveSelectionCriterionFromStateList(
const std::string &strValue = remoteCommand.getArgument(state + 1);
- if (!pCriterionType->addValuePair(0x1 << state, strValue, strResult)) {
+ if (!pCriterionType->addValuePair(0x1ull << state, strValue, strResult)) {
strResult = "Unable to add value: " + strValue + ": " + strResult;
@@ -321,7 +321,7 @@ bool CTestPlatform::createExclusiveSelectionCriterion(const string &strName, siz
ostrValue << state;
// FIXME state type vs addValuePair params
- if (!pCriterionType->addValuePair(int(state), ostrValue.str(), strResult)) {
+ if (!pCriterionType->addValuePair(uint64_t(state), ostrValue.str(), strResult)) {
strResult = "Unable to add value: " + ostrValue.str() + ": " + strResult;
@@ -345,9 +345,9 @@ bool CTestPlatform::createInclusiveSelectionCriterion(const string &strName, siz
std::ostringstream ostrValue;
ostrValue << "State_0x";
- ostrValue << (0x1 << state);
+ ostrValue << (0x1ull << state);
- if (!pCriterionType->addValuePair(0x1 << state, ostrValue.str(), strResult)) {
+ if (!pCriterionType->addValuePair(0x1ull << state, ostrValue.str(), strResult)) {
strResult = "Unable to add value: " + ostrValue.str() + ": " + strResult;
@@ -360,7 +360,7 @@ bool CTestPlatform::createInclusiveSelectionCriterion(const string &strName, siz
return true;
}
-bool CTestPlatform::setCriterionState(const string &strName, uint32_t uiState, string &strResult)
+bool CTestPlatform::setCriterionState(const string &strName, uint64_t uiState, string &strResult)
{
ISelectionCriterionInterface *pCriterion =
mParameterMgrPlatformConnector.getSelectionCriterion(strName);
@@ -409,7 +409,7 @@ bool CTestPlatform::setCriterionStateByLexicalSpace(const IRemoteCommand &remote
}
/// Translate lexical state to numerical state
- int iNumericalState = 0;
+ uint64_t iNumericalState = 0;
size_t lexicalSubStateIndex;
// Parse lexical substates
diff --git a/upstream/test/test-platform/TestPlatform.h b/upstream/test/test-platform/TestPlatform.h
index 8917dbb..6e843b0 100644
--- a/upstream/test/test-platform/TestPlatform.h
+++ b/upstream/test/test-platform/TestPlatform.h
@@ -144,7 +144,7 @@ private:
std::string &strResult);
bool createInclusiveSelectionCriterion(const std::string &strName, size_t nbValues,
std::string &strResult);
- bool setCriterionState(const std::string &strName, uint32_t uiState, std::string &strResult);
+ bool setCriterionState(const std::string &strName, uint64_t uiState, std::string &strResult);
bool setCriterionStateByLexicalSpace(const IRemoteCommand &remoteCommand,
std::string &strResult);
diff --git a/upstream/tools/xmlGenerator/domainGeneratorConnector.cpp b/upstream/tools/xmlGenerator/domainGeneratorConnector.cpp
index a83822f..9f40a31 100644
--- a/upstream/tools/xmlGenerator/domainGeneratorConnector.cpp
+++ b/upstream/tools/xmlGenerator/domainGeneratorConnector.cpp
@@ -136,7 +136,7 @@ void XmlGenerator::addCriteria(std::vector<string> &tokens)
int index = 0;
for (const auto &literalValue : tokens) {
// inclusive criteria are bitfields
- int numericalValue = inclusiveness ? 1 << index : index;
+ uint64_t numericalValue = inclusiveness ? 0x1ull << index : index;
string error;
bool success = criterionType->addValuePair(numericalValue, literalValue, error);