Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Commit 48f8a3b4 authored by Martin Kröning's avatar Martin Kröning

Use std::unique_ptr to delete MapWindow in MapWindowWrapper

This also disallows copying the MapWindowWrapper
parent 0bf630e5
#pragma once
#include <chrono>
#include <functional>
#include <memory>
#include <string_view>
#include <vector>
struct MapWindow;
......@@ -8,7 +10,6 @@ struct MapWindow;
class MapWindowWrapper {
MapWindowWrapper(std::string_view windowTitle);
virtual ~MapWindowWrapper();
void addJunction(double x, double y);
void addRoad(std::string_view laneThereName, std::string_view laneBackName,
const std::vector<double> &coordinates);
......@@ -21,5 +22,5 @@ public:
void setTimeLabel(std::chrono::minutes time);
MapWindow *mapWindow;
std::unique_ptr<MapWindow, std::function<void(MapWindow *)>> mapWindow;
#include "MapWindowWrapper.hpp"
#include <pi2-view.h>
#include <string_view>
#include <type_traits>
#include <vector>
MapWindowWrapper::MapWindowWrapper(std::string_view windowTitle)
: mapWindow(mapWindowCreate( {}
MapWindowWrapper::~MapWindowWrapper() {
mapWindow = nullptr;
: mapWindow(mapWindowCreate(,
[](MapWindow *mapWindow) { mapWindowDestroy(mapWindow); }) {}
void MapWindowWrapper::addJunction(const double x, const double y) {
mapWindowAddJunction(mapWindow, x, y);
mapWindowAddJunction(mapWindow.get(), x, y);
void MapWindowWrapper::addRoad(std::string_view laneThereName,
std::string_view laneBackName,
const std::vector<double> &coordinates) {
mapWindowAddRoad(mapWindow.get(),,,, coordinates.size());
......@@ -26,8 +23,8 @@ void MapWindowWrapper::addOrReplaceBicycle(std::string_view vehicleName,
std::string_view laneName,
const double positionOnLane,
const double speed) {
positionOnLane, speed);
mapWindowAddOrReplaceBicycle(mapWindow.get(),,, positionOnLane, speed);
void MapWindowWrapper::addOrReplaceCar(std::string_view vehicleName,
......@@ -35,10 +32,10 @@ void MapWindowWrapper::addOrReplaceCar(std::string_view vehicleName,
const double positionOnLane,
const double speed,
const double remainingFuel) {
positionOnLane, speed, remainingFuel);
void MapWindowWrapper::setTimeLabel(const std::chrono::minutes time) {
mapWindowSetTimeLabel(mapWindow, time.count());
mapWindowSetTimeLabel(mapWindow.get(), time.count());
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