Skip to content
Snippets Groups Projects
Commit 0e42a1c8 authored by Martin Stump's avatar Martin Stump Committed by Andreas Rauschert
Browse files

feat: Add support for named variables in IEnvironment

parent 55ef2198
No related branches found
No related tags found
1 merge request!147feat: Add support for named variables in IEnvironment
/*******************************************************************************
* Copyright (c) 2021-2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2024, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
......@@ -28,11 +29,17 @@
#include <MantleAPI/Traffic/i_entity_repository.h>
#include <MantleAPI/Traffic/i_traffic_swarm_service.h>
#include <cstdint>
#include <optional>
#include <string>
#include <variant>
namespace mantle_api
{
/// @brief Allowed data types for parameters defined in a parameter declaration.
using ParameterType = std::variant<bool, mantle_api::Time, double, std::string, std::uint32_t, std::uint16_t, std::int32_t>;
/// Base interface for the environment conditions (e.g. time of day, weather, road condition) of a scenario
class IEnvironment
{
......@@ -50,7 +57,7 @@ public:
///
/// @param entity The entity to be manipulated by the specified controller.
/// @param controller_id Identifies the controller to manipulate the entity.
virtual void AddEntityToController(IEntity& entity, UniqueId controller_id) = 0; // NOLINT (google-runtime-references)
virtual void AddEntityToController(IEntity& entity, UniqueId controller_id) = 0; // NOLINT (google-runtime-references)
/// Removes an entity from the specified controller.
///
......@@ -157,6 +164,18 @@ public:
/// @return The user defined value. No value if it doesn't exist.
virtual std::optional<std::string> GetUserDefinedValue(const std::string& name) = 0;
/// @brief Sets a named variable
///
/// @param name The name of the variable
/// @param value The value
virtual void SetVariable(const std::string& name, const ParameterType& value) = 0;
/// @brief Gets a named variable if it exists
///
/// @param name The name of the variable
/// @return The variable. No value if it doesn't exist.
[[nodiscard]] virtual std::optional<ParameterType> GetVariable(const std::string& name) const = 0;
/// @brief Specifies how to behave if no route is available
/// or if an entity has reached the end of a route
///
......
/*******************************************************************************
* Copyright (c) 2021-2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2022 Ansys, Inc.
* Copyright (c) 2024, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
......@@ -573,7 +574,17 @@ public:
(mantle_api::Time date_time),
(override));
mantle_api::Time GetDateTime() override { return mantle_api::Time(); }
MOCK_METHOD(void,
SetVariable,
(const std::string& name, const ParameterType& value),
(override));
MOCK_METHOD(std::optional<ParameterType>,
GetVariable,
(const std::string& name),
(const, override));
mantle_api::Time GetDateTime() override { return {}; }
MOCK_METHOD(mantle_api::Time, GetSimulationTime, (), (override));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment