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

Rename MapAppABIWrapper to MapAppABIWrapper

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