Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Ros2 v0.8 scenario_conditions (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu-takagi authored Feb 15, 2021
1 parent daf87a7 commit bd6045a
Showing 1 changed file with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
#ifndef SCENARIO_CONDITIONS_CONDITION_BASE_H_INCLUDED
#define SCENARIO_CONDITIONS_CONDITION_BASE_H_INCLUDED

#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
#include <yaml-cpp/yaml.h>

#include "scenario_api/scenario_api_core.hpp"
#include "scenario_intersection/intersection_manager.hpp"

#include <sstream>
#include "scenario_utility/indentation.hpp"
#include <limits>

namespace scenario_conditions
{
Expand All @@ -30,12 +32,9 @@ class ConditionBase
ConditionBase() = default;

ConditionBase(const std::string & type)
: type_{type}
{
std::stringstream ss;
ss << type << "Condition<" << static_cast<const void *>(this) << ">";
name_ = ss.str();
}
: type_ { type }
, name_ {}
{}

virtual ~ConditionBase() = default;

Expand All @@ -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<ScenarioAPI> api_ptr_;
YAML::Node node_;
Expand All @@ -59,6 +76,8 @@ class ConditionBase
bool keep_ = false;
bool result_ = false;

std::string description_;

std::string type_;
std::string name_;
};
Expand Down

0 comments on commit bd6045a

Please sign in to comment.