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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <cstddef>
       4             : #include <functional>
       5             : #include <limits>
       6             : #include <list>
       7             : #include <map>
       8             : #include <queue>
       9             : #include <set>
      10             : 
      11             : #include "Dynamic/Dynamic.hpp"
      12             : #include "Dynamic/Env/Event/EventSpawnVehicle.hpp"
      13             : #include "Dynamic/Env/Vehicle.hpp"
      14             : #include "utils/orderstat.hpp"
      15             : 
      16             : namespace Dynamic::Env {
      17             : 
      18             : class Env;
      19             : class Edge;
      20             : class Connection;
      21             : class Vehicle;
      22             : class EventUpdateVehicle;
      23             : class EventMoveVehicle;
      24             : class EventPopQueue;
      25             : class Action;
      26             : 
      27             : class Lane {
      28             :     friend Env;
      29             : 
      30             :    public:
      31             :     typedef size_t Index;
      32             : 
      33             :     /**
      34             :      * @brief Frequency at which vehicles leave a queue.
      35             :      */
      36             :     static constexpr double JUNCTION_CAPACITY = 1900.0 / 60.0 / 60.0;
      37             :     static const double     QUEUE_PERIOD;
      38             :     static const double     QUEUE_SPEED;
      39             :     static const Length     K_JAM;
      40             : 
      41             :    private:
      42             :     typedef long EdgeID;
      43             : 
      44             :     std::map<EdgeID, std::map<Index, std::reference_wrapper<Connection>>> outgoingConnections;
      45             :     std::map<EdgeID, std::map<Index, std::reference_wrapper<Connection>>> incomingConnections;
      46             : 
      47             :    public:
      48             :     Edge &edge;
      49             :     Index index;
      50             : 
      51             :     std::queue<Dynamic::Vehicle> uninstantiated;
      52             : 
      53             :     std::set<VehicleID> moving;
      54             : 
      55             :     // TODO: move implementation to cpp file
      56             :     struct cmp {
      57           0 :         bool operator()(
      58             :             const std::pair<std::reference_wrapper<Vehicle>, std::shared_ptr<Action>> &a,
      59             :             const std::pair<std::reference_wrapper<Vehicle>, std::shared_ptr<Action>> &b
      60             :         ) const {
      61           0 :             return a.first.get().id < b.first.get().id;
      62             :         }
      63             :     };
      64             : 
      65             :     // clang-format off
      66             :     utils::orderstat::queue<
      67             :         std::pair<std::reference_wrapper<Vehicle>, std::shared_ptr<Action>>,
      68             :         cmp
      69             :     > stopped;
      70             :     // clang-format on
      71             : 
      72             :     Time nextPopTime = -std::numeric_limits<Time>::infinity();
      73             : 
      74             :    public:
      75             :     Lane(Edge &edge, Index index);
      76             : 
      77             :     bool operator==(const Lane &other) const;
      78             :     bool operator!=(const Lane &other) const;
      79             :     bool operator<(const Lane &other) const;
      80             : 
      81             :     std::list<std::reference_wrapper<Connection>> getOutgoingConnections() const;
      82             :     std::list<std::reference_wrapper<Connection>> getOutgoingConnections(
      83             :         const Edge &nextEdge
      84             :     ) const;
      85             :     Connection &getOutgoingConnection(
      86             :         const Lane &nextLane
      87             :     ) const;
      88             : 
      89             :     std::list<std::reference_wrapper<Connection>> getIncomingConnections() const;
      90             : 
      91             :     Speed calculateSpeed() const;
      92             : 
      93             :     Length queueLength() const;
      94             :     Length queuePosition() const;
      95             :     size_t queueCapacity() const;
      96             : 
      97             :     bool isFull() const;
      98             : 
      99             :     void processNextWaitingVehicle(Env &env);
     100             : 
     101             :     std::string idAsString() const;
     102             : 
     103             :     static Lane INVALID;
     104             : };
     105             : }  // namespace Dynamic::Env
     106             : 
     107             : namespace std {
     108             : template<>
     109             : struct hash<Dynamic::Env::Lane> {
     110             :     size_t operator()(const Dynamic::Env::Lane &lane) const;
     111             : };
     112             : }  // namespace std

Generated by: LCOV version 1.14