In der Zeit vom 27.05.19 16 Uhr bis zum 28.05.19 10 Uhr steht die GitLab Instanz der RWTH Aachen nicht zur Verfügung. Es findet ein Umzug des angeschlossenen Storage Systems statt, so dass in der genannten Zeit keine Repositories angelegt, gelöscht oder verändert werden können. Wir bitten um Ihr Verständnis. // In the time from 27.05.19 16 o'clock to 28.05.19 10 o'clock the GitLab instance of the RWTH Aachen is not available. The connected storage system will be moved so that no repositories can be created, deleted or changed during this time. We ask for your understanding.

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 {
public:
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);
private:
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(windowTitle.data())) {}
MapWindowWrapper::~MapWindowWrapper() {
mapWindowDestroy(mapWindow);
mapWindow = nullptr;
}
: mapWindow(mapWindowCreate(windowTitle.data()),
[](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, laneThereName.data(), laneBackName.data(),
mapWindowAddRoad(mapWindow.get(), laneThereName.data(), laneBackName.data(),
coordinates.data(), coordinates.size());
}
......@@ -26,8 +23,8 @@ void MapWindowWrapper::addOrReplaceBicycle(std::string_view vehicleName,
std::string_view laneName,
const double positionOnLane,
const double speed) {
mapWindowAddOrReplaceBicycle(mapWindow, vehicleName.data(), laneName.data(),
positionOnLane, speed);
mapWindowAddOrReplaceBicycle(mapWindow.get(), vehicleName.data(),
laneName.data(), 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) {
mapWindowAddOrReplaceCar(mapWindow, vehicleName.data(), laneName.data(),
mapWindowAddOrReplaceCar(mapWindow.get(), vehicleName.data(), laneName.data(),
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