Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 36 additions & 38 deletions parameter/SelectionCriterionType.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -110,6 +110,39 @@ bool CSelectionCriterionType::getAtomicNumericalValue(const std::string& strValu
}

bool CSelectionCriterionType::getLiteralValue(int iValue, std::string& strValue) const
{
if (_bInclusive) {

// Need to go through all bit fields
uint32_t uiBit;
bool bFirst = true;

for (uiBit = 0; uiBit < sizeof(iValue) * 8; uiBit++) {

int iSingleBitValue = iValue & (1 << uiBit);
// Check if current bit is set
if (!iSingleBitValue) {
continue;
}
// Simple translation
std::string strSingleValue;
if (!getAtomicLiteralValue(iSingleBitValue, strSingleValue)) {
return false;
}

if (bFirst) {
bFirst = false;
} else {
strValue += "|";
}
strValue += strSingleValue;
}
return true;
}
return getAtomicLiteralValue(iValue, strValue);
}

bool CSelectionCriterionType::getAtomicLiteralValue(int iValue, std::string& strValue) const
{
NumToLitMapConstIt it;

Expand Down Expand Up @@ -160,43 +193,8 @@ std::string CSelectionCriterionType::getFormattedState(int iValue) const
{
std::string strFormattedState;

if (_bInclusive) {

// Need to go through all set bit
uint32_t uiBit;
bool bFirst = true;

for (uiBit = 0; uiBit < sizeof(iValue) * 8; uiBit++) {

int iSingleBitValue = iValue & (1 << uiBit);

// Check if current bit is set
if (!iSingleBitValue) {

continue;
}

// Simple translation
std::string strSingleValue;

if (!getLiteralValue(iSingleBitValue, strSingleValue)) {
// Numeric value not part supported values for this criterion type.
continue;
}

if (bFirst) {

bFirst = false;
} else {
strFormattedState += "|";
}

strFormattedState += strSingleValue;
}

} else {
// Simple translation
getLiteralValue(iValue, strFormattedState);
if (!getLiteralValue(iValue, strFormattedState)) {
strFormattedState = "<none>";
}

// Sometimes nothing is set
Expand Down
3 changes: 2 additions & 1 deletion parameter/SelectionCriterionType.h
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -85,6 +85,7 @@ class CSelectionCriterionType : public CElement, public ISelectionCriterionTypeI
* @return true if integer value retrieved from the std::string one, false otherwise.
*/
bool getAtomicNumericalValue(const std::string& strValue, int& iValue) const;
bool getAtomicLiteralValue(int iValue, std::string& strValue) const;
bool _bInclusive;
std::map<std::string, int> _numToLitMap;

Expand Down