summaryrefslogtreecommitdiffstats
path: root/upstream/bindings
diff options
context:
space:
mode:
authorSebastien Guiriec <sebastien.guiriec@renault.com>2016-04-26 07:26:09 +0200
committerEric Laurent <elaurent@google.com>2019-03-12 17:48:47 -0700
commit67f663e08dfcebdfaea69df36ebae6167595a549 (patch)
tree66e6f26a6a09209dafcfb350ce0531e0fca154be /upstream/bindings
parent9a458296b14bbbf4d3d4760b809c8613d46fdafb (diff)
downloadplatform_external_parameter-framework-67f663e08dfcebdfaea69df36ebae6167595a549.tar.gz
platform_external_parameter-framework-67f663e08dfcebdfaea69df36ebae6167595a549.tar.bz2
platform_external_parameter-framework-67f663e08dfcebdfaea69df36ebae6167595a549.zip
[PFW] Integrate PFW core version 3.2.5 release
PFW 3.2.5 release notes: https://github.com/intel/parameter-framework/releases/tag/v3.2.5 This release contains the following changes: - CMake Package configuration file generation - Preliminary and unofficial OSX support in Travis-CI - Use clang-tidy for automatic code cleanup - Some more cleanup and fixes - Speed Travis-CI up by using CCache Bug: 124767636 Test: build Change-Id: Ib7ce6824430f3907c0508194e91f71a934bdcda8 Signed-off-by: Sebastien Guiriec <sebastien.guiriec@renault.com>
Diffstat (limited to 'upstream/bindings')
-rw-r--r--upstream/bindings/c/CMakeLists.txt6
-rw-r--r--upstream/bindings/c/ParameterFramework.cpp44
-rw-r--r--upstream/bindings/c/Test.cpp26
3 files changed, 35 insertions, 41 deletions
diff --git a/upstream/bindings/c/CMakeLists.txt b/upstream/bindings/c/CMakeLists.txt
index 0c88412..c04ac3c 100644
--- a/upstream/bindings/c/CMakeLists.txt
+++ b/upstream/bindings/c/CMakeLists.txt
@@ -37,12 +37,6 @@ install(FILES ParameterFramework.h
target_link_libraries(cparameter PRIVATE parameter pfw_utility)
-target_include_directories(cparameter
- # Fixme use an include folder
- PUBLIC .
- # Export symbol macro header
- PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
-
install(TARGETS cparameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
if(BUILD_TESTING)
diff --git a/upstream/bindings/c/ParameterFramework.cpp b/upstream/bindings/c/ParameterFramework.cpp
index 53f7a66..858994b 100644
--- a/upstream/bindings/c/ParameterFramework.cpp
+++ b/upstream/bindings/c/ParameterFramework.cpp
@@ -50,7 +50,7 @@ namespace pfw
typedef ISelectionCriterionInterface Criterion;
typedef std::map<string, Criterion *> Criteria;
typedef CParameterMgrPlatformConnector Pfw;
-}
+} // namespace pfw
/** Class to abstract the boolean+string status api. */
class Status
@@ -110,7 +110,7 @@ static void defaultLogCb(void *, PfwLogLevel level, const char *logLine)
};
}
-static PfwLogger defaultLogger = {NULL, &defaultLogCb};
+static PfwLogger defaultLogger = {nullptr, &defaultLogCb};
class LogWrapper : public CParameterMgrPlatformConnector::ILogger
{
@@ -127,7 +127,7 @@ private:
{
// A LogWrapper should NOT be register to the pfw (thus log called)
// if logCb is NULL.
- assert(mLogger.logCb != NULL);
+ assert(mLogger.logCb != nullptr);
mLogger.logCb(mLogger.userCtx, level, strLog.c_str());
}
@@ -167,10 +167,10 @@ void pfwDestroy(PfwHandler *handle)
void PfwHandler::setLogger(const PfwLogger *logger)
{
- if (logger != NULL and logger->logCb == NULL) {
+ if (logger != nullptr and logger->logCb == nullptr) {
return; // There is no callback, do not log => do not add a logger
}
- mLogger = logger != NULL ? *logger : defaultLogger;
+ mLogger = logger != nullptr ? *logger : defaultLogger;
pfw->setLogger(&mLogger);
}
@@ -180,10 +180,10 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
// Add criteria
for (size_t criterionIndex = 0; criterionIndex < criterionNb; ++criterionIndex) {
const PfwCriterion &criterion = criteriaArray[criterionIndex];
- if (criterion.name == NULL) {
+ if (criterion.name == nullptr) {
return status.failure("Criterion name is NULL");
}
- if (criterion.values == NULL) {
+ if (criterion.values == nullptr) {
return status.failure("Criterion values is NULL");
}
// Check that the criterion does not exist
@@ -194,9 +194,9 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
// Create criterion type
ISelectionCriterionTypeInterface *type =
pfw->createSelectionCriterionType(criterion.inclusive);
- assert(type != NULL);
+ assert(type != nullptr);
// Add criterion values
- for (size_t valueIndex = 0; criterion.values[valueIndex] != NULL; ++valueIndex) {
+ for (size_t valueIndex = 0; criterion.values[valueIndex] != nullptr; ++valueIndex) {
int value;
if (criterion.inclusive) {
// Check that (int)1 << valueIndex would not overflow (UB)
@@ -227,7 +227,7 @@ bool pfwStart(PfwHandler *handle, const char *configPath, const PfwCriterion cri
// Check that the api is correctly used
Status &status = handle->lastStatus;
- if (handle->pfw != NULL) {
+ if (handle->pfw != nullptr) {
return status.failure("Can not start an already started parameter framework");
}
// Create a pfw
@@ -249,19 +249,19 @@ const char *pfwGetLastError(const PfwHandler *handle)
static pfw::Criterion *getCriterion(const pfw::Criteria &criteria, const string &name)
{
- pfw::Criteria::const_iterator it = criteria.find(name);
- return it == criteria.end() ? NULL : it->second;
+ auto it = criteria.find(name);
+ return it == criteria.end() ? nullptr : it->second;
}
bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
{
Status &status = handle->lastStatus;
- if (handle->pfw == NULL) {
+ if (handle->pfw == nullptr) {
return status.failure("Can not set criterion \"" + string(name) +
"\" as the parameter framework is not started.");
}
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
- if (criterion == NULL) {
+ if (criterion == nullptr) {
return status.failure("Can not set criterion " + string(name) + " as does not exist");
}
criterion->setCriterionState(value);
@@ -270,12 +270,12 @@ bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
{
Status &status = handle->lastStatus;
- if (handle->pfw == NULL) {
+ if (handle->pfw == nullptr) {
return status.failure("Can not get criterion \"" + string(name) +
"\" as the parameter framework is not started.");
}
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
- if (criterion == NULL) {
+ if (criterion == nullptr) {
return status.failure("Can not get criterion " + string(name) + " as it does not exist");
}
*value = criterion->getCriterionState();
@@ -285,7 +285,7 @@ bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
bool pfwApplyConfigurations(const PfwHandler *handle)
{
Status &status = handle->lastStatus;
- if (handle->pfw == NULL) {
+ if (handle->pfw == nullptr) {
return status.failure("Can not commit criteria "
"as the parameter framework is not started.");
}
@@ -306,17 +306,17 @@ struct PfwParameterHandler_
PfwParameterHandler *pfwBindParameter(PfwHandler *handle, const char path[])
{
Status &status = handle->lastStatus;
- if (handle->pfw == NULL) {
+ if (handle->pfw == nullptr) {
status.failure("The parameter framework is not started, "
"while trying to bind parameter \"" +
string(path) + "\")");
- return NULL;
+ return nullptr;
}
CParameterHandle *paramHandle;
paramHandle = handle->pfw->createParameterHandle(path, status.msg());
- if (paramHandle == NULL) {
- return NULL;
+ if (paramHandle == nullptr) {
+ return nullptr;
}
status.success();
@@ -344,7 +344,7 @@ bool pfwSetIntParameter(PfwParameterHandler *handle, int32_t value)
bool pfwGetStringParameter(const PfwParameterHandler *handle, char *value[])
{
Status &status = handle->pfw.lastStatus;
- *value = NULL;
+ *value = nullptr;
string retValue;
bool success = handle->parameter.getAsString(retValue, status.msg());
if (not success) {
diff --git a/upstream/bindings/c/Test.cpp b/upstream/bindings/c/Test.cpp
index 39f5df6..9d3b038 100644
--- a/upstream/bindings/c/Test.cpp
+++ b/upstream/bindings/c/Test.cpp
@@ -114,8 +114,8 @@ struct Test
TEST_CASE_METHOD(Test, "Parameter-framework c api use")
{
// Create criteria
- const char *letterList[] = {"a", "b", "c", NULL};
- const char *numberList[] = {"1", "2", "3", NULL};
+ const char *letterList[] = {"a", "b", "c", nullptr};
+ const char *numberList[] = {"1", "2", "3", nullptr};
const PfwCriterion criteria[] = {
{"inclusiveCrit", true, letterList}, {"exclusiveCrit", false, numberList},
};
@@ -165,7 +165,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 2, &logger));
}
WHEN ("The pfw is started with duplicated criterion value state") {
- const char *values[] = {"a", "a", NULL};
+ const char *values[] = {"a", "a", nullptr};
const PfwCriterion duplicatedCriteria[] = {{"name", true, values}};
WHEN ("Using test logger") {
@@ -173,15 +173,15 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
}
WHEN ("Using default logger") {
// Test coverage of default logger warning
- REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, NULL));
+ REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, nullptr));
}
}
WHEN ("The pfw is started with NULL name criterion") {
- const PfwCriterion duplicatedCriteria[] = {{NULL, true, letterList}};
+ const PfwCriterion duplicatedCriteria[] = {{nullptr, true, letterList}};
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
WHEN ("The pfw is started with NULL criterion state list") {
- const PfwCriterion duplicatedCriteria[] = {{"name", true, NULL}};
+ const PfwCriterion duplicatedCriteria[] = {{"name", true, nullptr}};
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
GIVEN ("A criteria with lots of values") {
@@ -192,7 +192,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
for (size_t i = 0; i < values.size(); ++i) {
values[i] = &names[i];
}
- values.back() = NULL;
+ values.back() = nullptr;
/* The pfw c api requires criterion values to be a NULL terminated
* array of string. Each string is a pointer to a NULL terminated
* array of char. The pfw requires each string to be different
@@ -225,7 +225,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
WHEN ("The pfw is started with max length criterion state list") {
- values[values.size() - 2] = NULL; // Hide last value
+ values[values.size() - 2] = nullptr; // Hide last value
REQUIRE_SUCCESS(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
}
@@ -240,11 +240,11 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
}
WHEN ("The pfw is started without a logger callback") {
- PfwLogger noLog = {NULL, NULL};
+ PfwLogger noLog = {nullptr, nullptr};
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, &noLog));
}
WHEN ("The pfw is started with default logger") {
- REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, NULL));
+ REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, nullptr));
}
WHEN ("Get criterion of a stopped pfw") {
@@ -311,12 +311,12 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_SUCCESS(pfwApplyConfigurations(pfw));
}
WHEN ("Bind a non existing parameter") {
- REQUIRE_FAILURE(pfwBindParameter(pfw, "do/not/exist") != NULL);
+ REQUIRE_FAILURE(pfwBindParameter(pfw, "do/not/exist") != nullptr);
}
GIVEN ("An integer parameter handle") {
PfwParameterHandler *param = pfwBindParameter(pfw, intParameterPath);
- REQUIRE_SUCCESS(param != NULL);
+ REQUIRE_SUCCESS(param != nullptr);
WHEN ("Set parameter out of range") {
REQUIRE_FAILURE(pfwSetIntParameter(param, 101));
@@ -335,7 +335,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
GIVEN ("An string parameter handle") {
PfwParameterHandler *param = pfwBindParameter(pfw, stringParameterPath);
- REQUIRE_SUCCESS(param != NULL);
+ REQUIRE_SUCCESS(param != nullptr);
WHEN ("Set parameter out of range") {
REQUIRE_FAILURE(pfwSetStringParameter(param, "ko_1234567"));