Commit 2222f3b0 authored by Martin Kröning's avatar Martin Kröning

Rename MapAppABIWrapper to MapAppABIWrapper

parent 781bc038
......@@ -2,13 +2,13 @@
#include "Vehicle.hpp"
#include <string>
class MapAppABIWrapper;
class MapAppAPIWrapper;
class Bicycle : public Vehicle {
public:
Bicycle(std::string name, double topSpeed, double timeOfStart, double time);
void draw(MapAppABIWrapper &mapApp, const std::string &laneName,
void draw(MapAppAPIWrapper &mapApp, const std::string &laneName,
double laneLength, double speedLimit) const override;
double getSpeed(double speedLimit) const override;
......
......@@ -2,7 +2,7 @@
#include "Vehicle.hpp"
#include <string>
class MapAppABIWrapper;
class MapAppAPIWrapper;
class Car : public Vehicle {
public:
......@@ -10,7 +10,7 @@ public:
Car(std::string name, double topSpeed, double timeOfStart, double fuelConsumption,
double fuelCapacity, double time);
void draw(MapAppABIWrapper &mapApp, const std::string &laneName,
void draw(MapAppAPIWrapper &mapApp, const std::string &laneName,
double laneLength, double speedLimit) const override;
double getSpeed(double speedLimit) const override;
......
......@@ -7,7 +7,7 @@
#include <string>
#include <vector>
class Vehicle;
class MapAppABIWrapper;
class MapAppAPIWrapper;
class Junction : public Named {
public:
......@@ -25,7 +25,7 @@ public:
void processVehicles(double time);
void drawVehicles(MapAppABIWrapper &mapApp) const;
void drawVehicles(MapAppAPIWrapper &mapApp) const;
void createCar(std::string name, double topSpeed, double fuelConsumption,
double fuelCapacity, double timeOfStart, double time);
......
......@@ -5,7 +5,7 @@
#include <memory>
#include <string>
#include <vector>
class MapAppABIWrapper;
class MapAppAPIWrapper;
class Junction;
class Lane : public Named {
......@@ -16,7 +16,7 @@ public:
double speedLimit, bool noPassing,
std::weak_ptr<Junction> destinationJunction);
void drawVehicles(MapAppABIWrapper &mapApp) const;
void drawVehicles(MapAppAPIWrapper &mapApp) const;
void processVehicles(double time);
......
#pragma once
#include "MapAppABIWrapper.hpp"
#include "MapAppAPIWrapper.hpp"
#include <chrono>
#include <iosfwd>
#include <memory>
......@@ -18,18 +18,18 @@ public:
private:
double time;
std::vector<std::shared_ptr<Junction>> junctions;
MapAppABIWrapper mapApp;
MapAppAPIWrapper mapApp;
std::weak_ptr<Junction> getJunction(const std::string &name);
/// Required format:
/// `name` `fuelAmount` `x` `y`
void extractJunctionAndDraw(std::istream &is, MapAppABIWrapper &mapApp);
void extractJunctionAndDraw(std::istream &is, MapAppAPIWrapper &mapApp);
/// Required format:
/// `nameJunctionA` `nameJunctionB` `nameLaneAToB` `nameLaneBToA` `length in km`
/// `speedLimit in {1,2,3}` `noPassing` `coordinateCount` `coordinates...`
void extractRoadAndDraw(std::istream &is, MapAppABIWrapper &mapApp);
void extractRoadAndDraw(std::istream &is, MapAppAPIWrapper &mapApp);
/// Required format:
/// `name` `topSpeed` `nameStartJunction` `timeOfStart`
......
......@@ -5,10 +5,10 @@
#include <vector>
struct MapApp;
class MapAppABIWrapper {
class MapAppAPIWrapper {
public:
MapAppABIWrapper(const std::string &windowTitle);
virtual ~MapAppABIWrapper();
MapAppAPIWrapper(const std::string &windowTitle);
virtual ~MapAppAPIWrapper();
void addJunction(double x, double y);
void addRoad(const std::string &laneThereName,
const std::string &laneBackName,
......
......@@ -2,13 +2,13 @@
#include "Named.hpp"
#include <string>
class MapAppABIWrapper;
class MapAppAPIWrapper;
class Vehicle : public Named {
public:
// Draws the vehicle on the provided \p mapApp on the specified \p laneName
// which has a \p laneLength and a \p speedLimit
virtual void draw(MapAppABIWrapper &mapApp, const std::string &laneName,
virtual void draw(MapAppAPIWrapper &mapApp, const std::string &laneName,
double laneLength, double speedLimit) const = 0;
/// \returns The current speed in km/h
......
......@@ -8,7 +8,7 @@ pi2_demo_src = files(
'src/Lane.cpp',
'src/Map.cpp',
'src/main.cpp',
'src/MapAppABIWrapper.cpp'
'src/MapAppAPIWrapper.cpp'
)
boost_po_dep = dependency('boost', modules : ['program_options'])
executable('pi2-demo', pi2_demo_src,
......
#include "Bicycle.hpp"
#include "MapAppABIWrapper.hpp"
#include "MapAppAPIWrapper.hpp"
#include <algorithm>
#include <cmath>
#include <utility>
......@@ -8,7 +8,7 @@ Bicycle::Bicycle(std::string name, const double topSpeed,
const double timeOfStart, const double time)
: Vehicle(std::move(name), topSpeed, timeOfStart, time) {}
void Bicycle::draw(MapAppABIWrapper &mapApp, const std::string &laneName,
void Bicycle::draw(MapAppAPIWrapper &mapApp, const std::string &laneName,
const double laneLength, const double speedLimit) const {
const auto positionOnLane = getDistanceOnLane() / laneLength;
mapApp.addOrReplaceBicycle(getName(), laneName, positionOnLane,
......
#include "Car.hpp"
#include "MapAppABIWrapper.hpp"
#include "MapAppAPIWrapper.hpp"
#include <algorithm>
#include <utility>
......@@ -10,7 +10,7 @@ Car::Car(std::string name, const double topSpeed, const double timeOfStart,
fuelConsumption(fuelConsumption), fuelCapacity(fuelCapacity),
fuel(fuelCapacity / 2) {}
void Car::draw(MapAppABIWrapper &mapApp, const std::string &laneName,
void Car::draw(MapAppAPIWrapper &mapApp, const std::string &laneName,
const double laneLength, const double speedLimit) const {
const auto positionOnLane = getDistanceOnLane() / laneLength;
mapApp.addOrReplaceCar(getName(), laneName, positionOnLane,
......
......@@ -5,7 +5,7 @@
#include <random>
#include <typeinfo>
#include <utility>
class MapAppABIWrapper;
class MapAppAPIWrapper;
void Junction::connect(const std::weak_ptr<Junction> &junctionA,
const std::weak_ptr<Junction> &junctionB,
......@@ -33,7 +33,7 @@ void Junction::processVehicles(const double time) {
}
}
void Junction::drawVehicles(MapAppABIWrapper &mapApp) const {
void Junction::drawVehicles(MapAppAPIWrapper &mapApp) const {
for (auto &&weg : outboundLanes) {
weg.drawVehicles(mapApp);
}
......
......@@ -6,7 +6,7 @@
#include <algorithm>
#include <memory>
#include <utility>
class MapAppABIWrapper;
class MapAppAPIWrapper;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
Lane::Lane(Lane &&other) noexcept = default;
......@@ -19,7 +19,7 @@ Lane::Lane(std::string name, std::string oppositeLaneName, const double length,
oppositeLaneName(std::move(oppositeLaneName)), speedLimit(speedLimit),
noPassing(noPassing) {}
void Lane::drawVehicles(MapAppABIWrapper &mapApp) const {
void Lane::drawVehicles(MapAppAPIWrapper &mapApp) const {
for (auto &&fahrzeug : vehicles) {
fahrzeug->draw(mapApp, getName(), length, speedLimit);
}
......
#include "Map.hpp"
#include "Junction.hpp"
#include "MapAppABIWrapper.hpp"
#include "MapAppAPIWrapper.hpp"
#include <algorithm>
#include <chrono>
#include <cstddef>
......@@ -52,7 +52,7 @@ std::weak_ptr<Junction> Map::getJunction(const std::string &name) {
[&name](const auto &junction) { return junction->getName() == name; });
}
void Map::extractJunctionAndDraw(std::istream &is, MapAppABIWrapper &mapApp) {
void Map::extractJunctionAndDraw(std::istream &is, MapAppAPIWrapper &mapApp) {
std::string name;
double fuelAmount;
is >> name >> fuelAmount;
......@@ -64,7 +64,7 @@ void Map::extractJunctionAndDraw(std::istream &is, MapAppABIWrapper &mapApp) {
mapApp.addJunction(x, y);
}
void Map::extractRoadAndDraw(std::istream &is, MapAppABIWrapper &mapApp) {
void Map::extractRoadAndDraw(std::istream &is, MapAppAPIWrapper &mapApp) {
std::string nameJunctionA;
std::string nameJunctionB;
std::string nameLaneAToB;
......
#include "MapAppABIWrapper.hpp"
#include "MapAppAPIWrapper.hpp"
#include "pi2-view.h"
#include <string>
#include <vector>
MapAppABIWrapper::MapAppABIWrapper(const std::string &windowTitle)
MapAppAPIWrapper::MapAppAPIWrapper(const std::string &windowTitle)
: mapApp(mapAppCreate(windowTitle.c_str())) {}
MapAppABIWrapper::~MapAppABIWrapper() {
MapAppAPIWrapper::~MapAppAPIWrapper() {
mapAppDestroy(mapApp);
mapApp = nullptr;
}
void MapAppABIWrapper::addJunction(const double x, const double y) {
void MapAppAPIWrapper::addJunction(const double x, const double y) {
mapAppAddJunction(mapApp, x, y);
}
void MapAppABIWrapper::addRoad(const std::string &laneThereName,
void MapAppAPIWrapper::addRoad(const std::string &laneThereName,
const std::string &laneBackName,
const std::vector<double> &coordinates) {
mapAppAddRoad(mapApp, laneThereName.c_str(), laneBackName.c_str(),
coordinates.data(), coordinates.size());
}
void MapAppABIWrapper::addOrReplaceBicycle(const std::string &vehicleName,
void MapAppAPIWrapper::addOrReplaceBicycle(const std::string &vehicleName,
const std::string &laneName,
const double positionOnLane,
const double speed) {
......@@ -30,7 +30,7 @@ void MapAppABIWrapper::addOrReplaceBicycle(const std::string &vehicleName,
positionOnLane, speed);
}
void MapAppABIWrapper::addOrReplaceCar(const std::string &vehicleName,
void MapAppAPIWrapper::addOrReplaceCar(const std::string &vehicleName,
const std::string &laneName,
const double positionOnLane,
const double speed,
......@@ -39,6 +39,6 @@ void MapAppABIWrapper::addOrReplaceCar(const std::string &vehicleName,
positionOnLane, speed, remainingFuel);
}
void MapAppABIWrapper::setDurationLabel(const std::chrono::minutes minutes) {
void MapAppAPIWrapper::setDurationLabel(const std::chrono::minutes minutes) {
mapAppSetDurationLabel(mapApp, minutes.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