Commit 45d09110 authored by Christoph Kochendoerfer's avatar Christoph Kochendoerfer
Browse files

Added controller repository

parent 840c01ab
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <MantleAPI/Map/i_lane_location_query_service.h> #include <MantleAPI/Map/i_lane_location_query_service.h>
#include <MantleAPI/Map/map_details.h> #include <MantleAPI/Map/map_details.h>
#include <MantleAPI/Traffic/i_entity_repository.h> #include <MantleAPI/Traffic/i_entity_repository.h>
#include <MantleAPI/Traffic/i_controller_repository.h>
#include <string> #include <string>
...@@ -38,12 +39,6 @@ public: ...@@ -38,12 +39,6 @@ public:
/// environment must do so. /// environment must do so.
virtual void CreateMap(const std::string& map_file_path, const mantle_api::MapDetails& map_details) = 0; virtual void CreateMap(const std::string& map_file_path, const mantle_api::MapDetails& map_details) = 0;
/// Creates a controller from the given config. A created controller can be assigned to multiple entities
///
/// @param config Specifies what kind of controller shall be created. The config needs to contain a controller ID
/// in order to be able to assign this controller to an entity.
virtual void CreateController(std::unique_ptr<IControllerConfig> config) = 0;
/// Assigns an entity to a copy of the specified controller. This controller needs to be created beforehand. Only /// Assigns an entity to a copy of the specified controller. This controller needs to be created beforehand. Only
/// one controller can be added to an entity /// one controller can be added to an entity
/// ///
...@@ -72,6 +67,9 @@ public: ...@@ -72,6 +67,9 @@ public:
virtual IEntityRepository& GetEntityRepository() = 0; virtual IEntityRepository& GetEntityRepository() = 0;
virtual const IEntityRepository& GetEntityRepository() const = 0; virtual const IEntityRepository& GetEntityRepository() const = 0;
virtual IControllerRepository& GetControllerRepository() = 0;
virtual const IControllerRepository& GetControllerRepository() const = 0;
/// @brief DateTime in UTC (converted from RFC 3339 standard) /// @brief DateTime in UTC (converted from RFC 3339 standard)
virtual void SetDateTime(mantle_api::Time time) = 0; virtual void SetDateTime(mantle_api::Time time) = 0;
virtual mantle_api::Time GetDateTime() = 0; virtual mantle_api::Time GetDateTime() = 0;
......
/********************************************************************************
* Copyright (c) 2021 in-tech GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
//-----------------------------------------------------------------------------
/** @file i_controller.h */
//-----------------------------------------------------------------------------
#include "MantleAPI/Common/i_identifiable.h"
#pragma once
namespace mantle_api
{
/// Base interface for all controllers.
class IController : public IIdentifiable
{
};
} // namespace mantle_api
\ No newline at end of file
...@@ -31,7 +31,7 @@ struct IControllerConfig ...@@ -31,7 +31,7 @@ struct IControllerConfig
{ {
IControllerConfig() {} IControllerConfig() {}
IControllerConfig(const IControllerConfig& controller_config) IControllerConfig(const IControllerConfig& controller_config)
: map_query_service(controller_config.map_query_service), id(controller_config.id) : map_query_service(controller_config.map_query_service)
{ {
std::transform(controller_config.control_strategies.begin(), std::transform(controller_config.control_strategies.begin(),
controller_config.control_strategies.end(), controller_config.control_strategies.end(),
...@@ -44,7 +44,6 @@ struct IControllerConfig ...@@ -44,7 +44,6 @@ struct IControllerConfig
// TODO: Check why map_query_service is part of the interface because it is not set from engine side but only in the // TODO: Check why map_query_service is part of the interface because it is not set from engine side but only in the
// environment on calling AddController() // environment on calling AddController()
ILaneLocationQueryService* map_query_service{nullptr}; ILaneLocationQueryService* map_query_service{nullptr};
std::uint64_t id{0};
std::vector<std::unique_ptr<mantle_api::ControlStrategy>> control_strategies; std::vector<std::unique_ptr<mantle_api::ControlStrategy>> control_strategies;
}; };
...@@ -66,7 +65,7 @@ inline bool operator==(const IControllerConfig& lhs, const IControllerConfig& rh ...@@ -66,7 +65,7 @@ inline bool operator==(const IControllerConfig& lhs, const IControllerConfig& rh
} }
} }
} }
return lhs.id == rhs.id && control_strategies_equal; return control_strategies_equal;
} }
struct NoOpControllerConfig : public IControllerConfig struct NoOpControllerConfig : public IControllerConfig
......
/********************************************************************************
* Copyright (c) 2021 in-tech GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
//-----------------------------------------------------------------------------
/** @file i_controller_repository.h */
//-----------------------------------------------------------------------------
#pragma once
#include "MantleAPI/Traffic/i_controller_config.h"
#include "MantleAPI/Traffic/i_controller.h"
namespace mantle_api
{
/// This interface provides CRUD functionality for controllers.
class IControllerRepository
{
public:
virtual IController& Create(const IControllerConfig& config) = 0;
[[deprecated]] virtual IController& Create(UniqueId id, const IControllerConfig& config) = 0; // deprecated
virtual std::optional<std::reference_wrapper<IController>> Get(UniqueId id) = 0;
virtual bool Contains(UniqueId id) const = 0;
virtual void Delete(UniqueId id) = 0;
};
} // namespace mantle_api
\ No newline at end of file
...@@ -30,11 +30,11 @@ class IEntityRepository ...@@ -30,11 +30,11 @@ class IEntityRepository
{ {
public: public:
virtual IVehicle& Create(const std::string& name, const VehicleProperties& properties) = 0; virtual IVehicle& Create(const std::string& name, const VehicleProperties& properties) = 0;
virtual IVehicle& Create(UniqueId id, const std::string& name, const VehicleProperties& properties) = 0; [[deprecated]] virtual IVehicle& Create(UniqueId id, const std::string& name, const VehicleProperties& properties) = 0;
virtual IPedestrian& Create(const std::string& name, const PedestrianProperties& properties) = 0; virtual IPedestrian& Create(const std::string& name, const PedestrianProperties& properties) = 0;
virtual IPedestrian& Create(UniqueId id, const std::string& name, const PedestrianProperties& properties) = 0; [[deprecated]] virtual IPedestrian& Create(UniqueId id, const std::string& name, const PedestrianProperties& properties) = 0;
virtual IStaticObject& Create(const std::string& name, const mantle_api::StaticObjectProperties& properties) = 0; virtual IStaticObject& Create(const std::string& name, const mantle_api::StaticObjectProperties& properties) = 0;
virtual IStaticObject& Create(UniqueId id, const std::string& name, const StaticObjectProperties& properties) = 0; [[deprecated]] virtual IStaticObject& Create(UniqueId id, const std::string& name, const StaticObjectProperties& properties) = 0;
virtual IVehicle& GetHost() = 0; virtual IVehicle& GetHost() = 0;
virtual std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) = 0; virtual std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment