Vehicle.hpp 1.19 KB
Newer Older
Martin Kröning's avatar
Martin Kröning committed
1
2
3
4
#pragma once

#include "Named.hpp"
#include <string>
5
#include <string_view>
6
class MapAppAPIWrapper;
Martin Kröning's avatar
Martin Kröning committed
7
8
9
10
11

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
12
  virtual void draw(MapAppAPIWrapper &mapApp, std::string_view laneName,
Martin Kröning's avatar
Martin Kröning committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
                    double laneLength, double speedLimit) const = 0;

  /// \returns The current speed in km/h
  virtual double getSpeed(double speedLimit) const = 0;

  /// Updates the total traveled distance, the total traveled time and
  /// the time of this tick
  virtual void process(double time, double maximumDistanceOnLane,
                       double speedLimit);

  double getDistanceOnLane() const;

  void resetDistanceOnLane();

protected:
  Vehicle(std::string name, double topSpeed, double timeOfStart, double time);

  double getTopSpeed() const;

  double getGesamtStrecke() const;

  bool isParking() const;

private:
  /// Maximum speed in km/h
  double topSpeed;

  /// Total travel distance in km
  double odometer;

  /// Current distance on lane in km
  double distanceOnLane;

  bool parking;

  double timeOfStart;

  double timeOfLastProcessing;
};