From b8bd211d8ec9c9b2d8418e1476e5701f96cc1079 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 1 Mar 2022 17:52:39 +0100 Subject: [PATCH 1/2] updated API to take reference instead of pointer --- mission/memory/NVMParameterBase.cpp | 2 +- mission/memory/NVMParameterBase.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index 0802a392..c7ac7560 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -19,7 +19,7 @@ ReturnValue_t NVMParameterBase::readJsonFile() { ReturnValue_t NVMParameterBase::writeJsonFile() { std::ofstream o(fullName); - o << std::setw(4) << json; + o << std::setw(4) << json << std::endl; return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index aafbf8cc..eb839905 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -34,7 +34,7 @@ class NVMParameterBase : public HasReturnvaluesIF { ReturnValue_t setValue(std::string key, T value); template - ReturnValue_t getValue(std::string key, T* value) const; + ReturnValue_t getValue(std::string key, T& value) const; void printKeys() const; void print() const; @@ -67,11 +67,11 @@ inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { } template -inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { +inline ReturnValue_t NVMParameterBase::getValue(std::string key, T& value) const { if (!json.contains(key)) { return KEY_NOT_EXISTS; } - *value = json[key]; + value = json[key]; return RETURN_OK; } From e0e0554feabd1b80ee986ea4160fc89379bdfa1b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 1 Mar 2022 17:54:43 +0100 Subject: [PATCH 2/2] update Q7S test task for API change --- bsp_q7s/boardtest/Q7STestTask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index bd9890a7..1f14d0e1 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -142,13 +142,13 @@ void Q7STestTask::testDummyParams() { param.print(); int test = 0; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, test); if (result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 << " does not exist" << std::endl; } std::string test2; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, test2); if (result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 << " does not exist" << std::endl;