From 342e9d2f46abf6e763aa842a918df634aaf4a21f Mon Sep 17 00:00:00 2001 From: Sebastian Schildt Date: Thu, 18 Nov 2021 14:34:34 +0100 Subject: [PATCH] Accept default only for attributes according to VSS spec Signed-off-by: Sebastian Schildt --- src/VssDatabase.cpp | 7 +++---- test/unit-test/VssDatabaseTests.cpp | 23 ----------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/VssDatabase.cpp b/src/VssDatabase.cpp index 2d6c10208..243aec461 100644 --- a/src/VssDatabase.cpp +++ b/src/VssDatabase.cpp @@ -58,14 +58,13 @@ bool VssDatabase::isAttribute(const json &element) { } -/** Iterates over a given VSS tree and checks for sensors and actuators specifying the "default" - * metadata. If a default is present, it will be used as "value" (and thus returned upon get - * even if there has been no previous set) +/** Iterates over a given VSS tree and checks attributes specifying the "default" + * metadata. If a default is present, it will be used as "value" (and thus returned upon get) */ void VssDatabase::applyDefaultValues(json &tree, VSSPath path) { //logger_->Log(LogLevel::VERBOSE, "Applying default values in "+path.to_string()); - if ( isSensor(tree) || isActor(tree) || isAttribute(tree)) { + if ( isAttribute(tree)) { if (tree.contains("default")) { logger_->Log(LogLevel::INFO, "Setting default for "+path.to_string()+" to "+tree["default"].as()); /** Not using setSignal, as that always operates on the complete tree. However applyDefaultValues shall also diff --git a/test/unit-test/VssDatabaseTests.cpp b/test/unit-test/VssDatabaseTests.cpp index f8f7cb019..60f38eb64 100644 --- a/test/unit-test/VssDatabaseTests.cpp +++ b/test/unit-test/VssDatabaseTests.cpp @@ -451,17 +451,6 @@ BOOST_AUTO_TEST_CASE(applyDefaultValues_Recurse) { ], "type": "attribute", "uuid": "0c4cf2b3979456928967e73b646bda05" - }, - "ChargePortFlap": { - "datatype": "string", - "default": "closed", - "description": "Signal indicating if charge port cover is open or closed, can potentially be controlled manually.", - "enum": [ - "open", - "closed" - ], - "type": "actuator", - "uuid": "528e53ad98c1546b90bb48f24f04815a" } } } @@ -484,18 +473,6 @@ BOOST_AUTO_TEST_CASE(applyDefaultValues_Recurse) { ], "type": "attribute", "uuid": "0c4cf2b3979456928967e73b646bda05" - }, - "ChargePortFlap": { - "datatype": "string", - "default": "closed", - "value": "closed", - "description": "Signal indicating if charge port cover is open or closed, can potentially be controlled manually.", - "enum": [ - "open", - "closed" - ], - "type": "actuator", - "uuid": "528e53ad98c1546b90bb48f24f04815a" } } }