Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PI2
PI2 View
Commits
2222f3b0
Commit
2222f3b0
authored
Jan 21, 2019
by
Martin Kröning
🦀
Browse files
Rename MapAppABIWrapper to MapAppABIWrapper
parent
781bc038
Changes
14
Hide whitespace changes
Inline
Side-by-side
pi2-demo/include/Bicycle.hpp
View file @
2222f3b0
...
...
@@ -2,13 +2,13 @@
#include
"Vehicle.hpp"
#include
<string>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
class
Bicycle
:
public
Vehicle
{
public:
Bicycle
(
std
::
string
name
,
double
topSpeed
,
double
timeOfStart
,
double
time
);
void
draw
(
MapAppA
B
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
void
draw
(
MapAppA
P
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
double
laneLength
,
double
speedLimit
)
const
override
;
double
getSpeed
(
double
speedLimit
)
const
override
;
...
...
pi2-demo/include/Car.hpp
View file @
2222f3b0
...
...
@@ -2,7 +2,7 @@
#include
"Vehicle.hpp"
#include
<string>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
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
(
MapAppA
B
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
void
draw
(
MapAppA
P
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
double
laneLength
,
double
speedLimit
)
const
override
;
double
getSpeed
(
double
speedLimit
)
const
override
;
...
...
pi2-demo/include/Junction.hpp
View file @
2222f3b0
...
...
@@ -7,7 +7,7 @@
#include
<string>
#include
<vector>
class
Vehicle
;
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
class
Junction
:
public
Named
{
public:
...
...
@@ -25,7 +25,7 @@ public:
void
processVehicles
(
double
time
);
void
drawVehicles
(
MapAppA
B
IWrapper
&
mapApp
)
const
;
void
drawVehicles
(
MapAppA
P
IWrapper
&
mapApp
)
const
;
void
createCar
(
std
::
string
name
,
double
topSpeed
,
double
fuelConsumption
,
double
fuelCapacity
,
double
timeOfStart
,
double
time
);
...
...
pi2-demo/include/Lane.hpp
View file @
2222f3b0
...
...
@@ -5,7 +5,7 @@
#include
<memory>
#include
<string>
#include
<vector>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
class
Junction
;
class
Lane
:
public
Named
{
...
...
@@ -16,7 +16,7 @@ public:
double
speedLimit
,
bool
noPassing
,
std
::
weak_ptr
<
Junction
>
destinationJunction
);
void
drawVehicles
(
MapAppA
B
IWrapper
&
mapApp
)
const
;
void
drawVehicles
(
MapAppA
P
IWrapper
&
mapApp
)
const
;
void
processVehicles
(
double
time
);
...
...
pi2-demo/include/Map.hpp
View file @
2222f3b0
#pragma once
#include
"MapAppA
B
IWrapper.hpp"
#include
"MapAppA
P
IWrapper.hpp"
#include
<chrono>
#include
<iosfwd>
#include
<memory>
...
...
@@ -18,18 +18,18 @@ public:
private:
double
time
;
std
::
vector
<
std
::
shared_ptr
<
Junction
>>
junctions
;
MapAppA
B
IWrapper
mapApp
;
MapAppA
P
IWrapper
mapApp
;
std
::
weak_ptr
<
Junction
>
getJunction
(
const
std
::
string
&
name
);
/// Required format:
/// `name` `fuelAmount` `x` `y`
void
extractJunctionAndDraw
(
std
::
istream
&
is
,
MapAppA
B
IWrapper
&
mapApp
);
void
extractJunctionAndDraw
(
std
::
istream
&
is
,
MapAppA
P
IWrapper
&
mapApp
);
/// Required format:
/// `nameJunctionA` `nameJunctionB` `nameLaneAToB` `nameLaneBToA` `length in km`
/// `speedLimit in {1,2,3}` `noPassing` `coordinateCount` `coordinates...`
void
extractRoadAndDraw
(
std
::
istream
&
is
,
MapAppA
B
IWrapper
&
mapApp
);
void
extractRoadAndDraw
(
std
::
istream
&
is
,
MapAppA
P
IWrapper
&
mapApp
);
/// Required format:
/// `name` `topSpeed` `nameStartJunction` `timeOfStart`
...
...
pi2-demo/include/MapAppA
B
IWrapper.hpp
→
pi2-demo/include/MapAppA
P
IWrapper.hpp
View file @
2222f3b0
...
...
@@ -5,10 +5,10 @@
#include
<vector>
struct
MapApp
;
class
MapAppA
B
IWrapper
{
class
MapAppA
P
IWrapper
{
public:
MapAppA
B
IWrapper
(
const
std
::
string
&
windowTitle
);
virtual
~
MapAppA
B
IWrapper
();
MapAppA
P
IWrapper
(
const
std
::
string
&
windowTitle
);
virtual
~
MapAppA
P
IWrapper
();
void
addJunction
(
double
x
,
double
y
);
void
addRoad
(
const
std
::
string
&
laneThereName
,
const
std
::
string
&
laneBackName
,
...
...
pi2-demo/include/Vehicle.hpp
View file @
2222f3b0
...
...
@@ -2,13 +2,13 @@
#include
"Named.hpp"
#include
<string>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
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
(
MapAppA
B
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
virtual
void
draw
(
MapAppA
P
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
double
laneLength
,
double
speedLimit
)
const
=
0
;
/// \returns The current speed in km/h
...
...
pi2-demo/meson.build
View file @
2222f3b0
...
...
@@ -8,7 +8,7 @@ pi2_demo_src = files(
'src/Lane.cpp'
,
'src/Map.cpp'
,
'src/main.cpp'
,
'src/MapAppA
B
IWrapper.cpp'
'src/MapAppA
P
IWrapper.cpp'
)
boost_po_dep
=
dependency
(
'boost'
,
modules
:
[
'program_options'
])
executable
(
'pi2-demo'
,
pi2_demo_src
,
...
...
pi2-demo/src/Bicycle.cpp
View file @
2222f3b0
#include
"Bicycle.hpp"
#include
"MapAppA
B
IWrapper.hpp"
#include
"MapAppA
P
IWrapper.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
(
MapAppA
B
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
void
Bicycle
::
draw
(
MapAppA
P
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
const
double
laneLength
,
const
double
speedLimit
)
const
{
const
auto
positionOnLane
=
getDistanceOnLane
()
/
laneLength
;
mapApp
.
addOrReplaceBicycle
(
getName
(),
laneName
,
positionOnLane
,
...
...
pi2-demo/src/Car.cpp
View file @
2222f3b0
#include
"Car.hpp"
#include
"MapAppA
B
IWrapper.hpp"
#include
"MapAppA
P
IWrapper.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
(
MapAppA
B
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
void
Car
::
draw
(
MapAppA
P
IWrapper
&
mapApp
,
const
std
::
string
&
laneName
,
const
double
laneLength
,
const
double
speedLimit
)
const
{
const
auto
positionOnLane
=
getDistanceOnLane
()
/
laneLength
;
mapApp
.
addOrReplaceCar
(
getName
(),
laneName
,
positionOnLane
,
...
...
pi2-demo/src/Junction.cpp
View file @
2222f3b0
...
...
@@ -5,7 +5,7 @@
#include
<random>
#include
<typeinfo>
#include
<utility>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
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
(
MapAppA
B
IWrapper
&
mapApp
)
const
{
void
Junction
::
drawVehicles
(
MapAppA
P
IWrapper
&
mapApp
)
const
{
for
(
auto
&&
weg
:
outboundLanes
)
{
weg
.
drawVehicles
(
mapApp
);
}
...
...
pi2-demo/src/Lane.cpp
View file @
2222f3b0
...
...
@@ -6,7 +6,7 @@
#include
<algorithm>
#include
<memory>
#include
<utility>
class
MapAppA
B
IWrapper
;
class
MapAppA
P
IWrapper
;
// 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
(
MapAppA
B
IWrapper
&
mapApp
)
const
{
void
Lane
::
drawVehicles
(
MapAppA
P
IWrapper
&
mapApp
)
const
{
for
(
auto
&&
fahrzeug
:
vehicles
)
{
fahrzeug
->
draw
(
mapApp
,
getName
(),
length
,
speedLimit
);
}
...
...
pi2-demo/src/Map.cpp
View file @
2222f3b0
#include
"Map.hpp"
#include
"Junction.hpp"
#include
"MapAppA
B
IWrapper.hpp"
#include
"MapAppA
P
IWrapper.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
,
MapAppA
B
IWrapper
&
mapApp
)
{
void
Map
::
extractJunctionAndDraw
(
std
::
istream
&
is
,
MapAppA
P
IWrapper
&
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
,
MapAppA
B
IWrapper
&
mapApp
)
{
void
Map
::
extractRoadAndDraw
(
std
::
istream
&
is
,
MapAppA
P
IWrapper
&
mapApp
)
{
std
::
string
nameJunctionA
;
std
::
string
nameJunctionB
;
std
::
string
nameLaneAToB
;
...
...
pi2-demo/src/MapAppA
B
IWrapper.cpp
→
pi2-demo/src/MapAppA
P
IWrapper.cpp
View file @
2222f3b0
#include
"MapAppA
B
IWrapper.hpp"
#include
"MapAppA
P
IWrapper.hpp"
#include
"pi2-view.h"
#include
<string>
#include
<vector>
MapAppA
B
IWrapper
::
MapAppA
B
IWrapper
(
const
std
::
string
&
windowTitle
)
MapAppA
P
IWrapper
::
MapAppA
P
IWrapper
(
const
std
::
string
&
windowTitle
)
:
mapApp
(
mapAppCreate
(
windowTitle
.
c_str
()))
{}
MapAppA
B
IWrapper
::~
MapAppA
B
IWrapper
()
{
MapAppA
P
IWrapper
::~
MapAppA
P
IWrapper
()
{
mapAppDestroy
(
mapApp
);
mapApp
=
nullptr
;
}
void
MapAppA
B
IWrapper
::
addJunction
(
const
double
x
,
const
double
y
)
{
void
MapAppA
P
IWrapper
::
addJunction
(
const
double
x
,
const
double
y
)
{
mapAppAddJunction
(
mapApp
,
x
,
y
);
}
void
MapAppA
B
IWrapper
::
addRoad
(
const
std
::
string
&
laneThereName
,
void
MapAppA
P
IWrapper
::
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
MapAppA
B
IWrapper
::
addOrReplaceBicycle
(
const
std
::
string
&
vehicleName
,
void
MapAppA
P
IWrapper
::
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
MapAppA
B
IWrapper
::
addOrReplaceCar
(
const
std
::
string
&
vehicleName
,
void
MapAppA
P
IWrapper
::
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
MapAppA
B
IWrapper
::
setDurationLabel
(
const
std
::
chrono
::
minutes
minutes
)
{
void
MapAppA
P
IWrapper
::
setDurationLabel
(
const
std
::
chrono
::
minutes
minutes
)
{
mapAppSetDurationLabel
(
mapApp
,
minutes
.
count
());
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment