LCOV - code coverage report
Current view: top level - app/include/Dynamic/Env - Vehicle.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 0 -

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <functional>
       4             : #include <map>
       5             : 
       6             : #include "Dynamic/Dynamic.hpp"
       7             : #include "Dynamic/Env/Position.hpp"
       8             : #include "Dynamic/Policy/Action.hpp"
       9             : #include "Dynamic/Vehicle.hpp"
      10             : 
      11             : namespace Dynamic::Env {
      12             : class Vehicle: public Dynamic::Vehicle {
      13             :    public:
      14             :     enum class State : int {
      15             :         MOVING  = 1,  /// @brief Vehicle is moving
      16             :         STOPPED = 2,  /// @brief Vehicle is stopped at a queue
      17             :         LEFT    = 3   /// @brief Vehicle has left the simulation
      18             :     };
      19             : 
      20           0 :     class Path {
      21             :         std::vector<std::pair<Time, std::reference_wrapper<const Lane>>> v;
      22             : 
      23             :         // clang-format off
      24             :         std::map<
      25             :             std::reference_wrapper<const Lane>,
      26             :             size_t,
      27             :             std::less<Lane>
      28             :         > ms;
      29             :         // clang-format on
      30             : 
      31             :        public:
      32             :         typedef std::vector<std::pair<Time, std::reference_wrapper<const Lane>>>::iterator       iterator;
      33             :         typedef std::vector<std::pair<Time, std::reference_wrapper<const Lane>>>::const_iterator const_iterator;
      34             : 
      35             :         iterator begin();
      36             :         iterator end();
      37             : 
      38             :         const_iterator begin() const;
      39             :         const_iterator end() const;
      40             : 
      41             :         const std::pair<Time, std::reference_wrapper<const Lane>> &front() const;
      42             :         const std::pair<Time, std::reference_wrapper<const Lane>> &back() const;
      43             : 
      44             :         void emplace_connection(Time t, const Connection &connection);
      45             :         void emplace_lane(Time t, const Lane &lane);
      46             : 
      47             :         size_t count(const Lane &lane) const;
      48             : 
      49             :         size_t size() const;
      50             :         bool   empty() const;
      51             :     };
      52             : 
      53             :     static const Length LENGTH;
      54             : 
      55             :     Time     lastUpdateTime;
      56             :     Time     lastMoveTime;
      57             :     Position position;
      58             :     Speed    speed;
      59             :     State    state;
      60             : 
      61             :     std::shared_ptr<Action> prevAction;
      62             : 
      63             :     Time enteredLane;
      64             : 
      65             :     Path path;
      66             : 
      67             :     Vehicle(
      68             :         const Dynamic::Vehicle &vehicle,
      69             :         Time                    t,
      70             :         Position                position,
      71             :         Speed                   speed,
      72             :         State                   state
      73             :     );
      74             : 
      75             :     std::shared_ptr<Action> pickConnection(Env &env) const;
      76             : 
      77             :     void moveToAnotherEdge(Env &env, std::shared_ptr<Action> action);
      78             : 
      79             :     bool operator==(const Dynamic::Env::Vehicle &other) const;
      80             :     bool operator!=(const Dynamic::Env::Vehicle &other) const;
      81             : };
      82             : }  // namespace Dynamic::Env

Generated by: LCOV version 1.14