From bd6045a8a79a7923a85e8dcd9782e42ccd115102 Mon Sep 17 00:00:00 2001 From: isamu-takagi <43976882+isamu-takagi@users.noreply.github.com> Date: Mon, 15 Feb 2021 11:03:32 +0900 Subject: [PATCH] Ros2 v0.8 scenario_conditions (#66) --- .../scenario_conditions/condition_base.hpp | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/condition/scenario_conditions/include/scenario_conditions/condition_base.hpp b/condition/scenario_conditions/include/scenario_conditions/condition_base.hpp index 6c7d8131..8e404551 100644 --- a/condition/scenario_conditions/include/scenario_conditions/condition_base.hpp +++ b/condition/scenario_conditions/include/scenario_conditions/condition_base.hpp @@ -15,12 +15,14 @@ #ifndef SCENARIO_CONDITIONS_CONDITION_BASE_H_INCLUDED #define SCENARIO_CONDITIONS_CONDITION_BASE_H_INCLUDED +#include +#include #include #include "scenario_api/scenario_api_core.hpp" #include "scenario_intersection/intersection_manager.hpp" - -#include +#include "scenario_utility/indentation.hpp" +#include namespace scenario_conditions { @@ -30,12 +32,9 @@ class ConditionBase ConditionBase() = default; ConditionBase(const std::string & type) - : type_{type} - { - std::stringstream ss; - ss << type << "Condition<" << static_cast(this) << ">"; - name_ = ss.str(); - } + : type_ { type } + , name_ {} + {} virtual ~ConditionBase() = default; @@ -47,10 +46,28 @@ class ConditionBase const std::string & getName() const noexcept {return name_;} - bool getResult() const noexcept {return result_;} + const std::string& description() const noexcept { return description_; } + + const auto& rename(const std::string& new_name) + { + return name_ = new_name; + } + + bool getResult() const noexcept { return result_; } const std::string & getType() const noexcept {return type_;} + auto property() const + { + boost::property_tree::ptree result {}; + + result.put("Name", getName()); + result.put("Value", description()); + result.put("Result", getResult()); + + return result; + } + protected: std::shared_ptr api_ptr_; YAML::Node node_; @@ -59,6 +76,8 @@ class ConditionBase bool keep_ = false; bool result_ = false; + std::string description_; + std::string type_; std::string name_; };