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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <color/color.hpp>
       4             : #include <memory>
       5             : 
       6             : #include "Dynamic/Env/Vehicle.hpp"
       7             : #include "Dynamic/SUMOAdapter.hpp"
       8             : #include "Static/SUMOAdapter.hpp"
       9             : #include "Static/Solution.hpp"
      10             : #include "data/SUMO/Network.hpp"
      11             : #include "data/SUMO/SUMO.hpp"
      12             : #include "data/SUMO/TAZ.hpp"
      13             : #include "utils/shared_ptr.hpp"
      14             : 
      15             : namespace SUMO {
      16           0 : class Routes {
      17             :    public:
      18             :     template<typename T, typename... args>
      19             :     class Loader {
      20             :        public:
      21             :         Routes load(T var1, args... var2);
      22             :     };
      23             : 
      24             :     class VehicleFlow {
      25             :         friend Routes;
      26             : 
      27             :        public:
      28             :         typedef SUMO::ID ID;
      29             : 
      30             :         struct DepartPos {
      31             :             enum class Enum {
      32             :                 RANDOM,
      33             :                 FREE,
      34             :                 RANDOM_FREE,
      35             :                 BASE,
      36             :                 LAST,
      37             :                 STOP
      38             :             };
      39             :             std::optional<Enum>  e = std::nullopt;
      40             :             std::optional<float> f = std::nullopt;
      41             :         };
      42             : 
      43             :         struct DepartSpeed {
      44             :             enum class Enum {
      45             :                 RANDOM,
      46             :                 MAX,
      47             :                 DESIRED,
      48             :                 SPEED_LIMIT,
      49             :                 LAST,
      50             :                 AVG
      51             :             };
      52             :             std::optional<Enum>  e = std::nullopt;
      53             :             std::optional<float> f = std::nullopt;
      54             :         };
      55             : 
      56             :        private:
      57             :         ID                               id;
      58             :         std::optional<color::rgb<float>> color;
      59             :         std::optional<TAZ::ID>           fromTaz;
      60             :         std::optional<TAZ::ID>           toTaz;
      61             :         std::optional<DepartPos>         departPos;
      62             :         std::optional<DepartSpeed>       departSpeed;
      63             : 
      64             :         Route route;
      65             : 
      66             :        protected:
      67             :         virtual void toXML(rapidxml::xml_node<> &routesEl) const;
      68             :         virtual void addToXML(rapidxml::xml_node<> &routesEl) const = 0;
      69             : 
      70             :         VehicleFlow(
      71             :             ID    id,
      72             :             Route route
      73             :         );
      74             : 
      75             :        public:
      76             :         void setColor(color::rgb<float> color);
      77             :         void setFromTaz(SUMO::TAZ::ID fromTaz);
      78             :         void setToTaz(SUMO::TAZ::ID toTaz);
      79             :         void setDepartPos(DepartPos departPos);
      80             :         void setDepartSpeed(DepartSpeed departSpeed);
      81             : 
      82           0 :         virtual ~VehicleFlow() = default;
      83             :     };
      84             : 
      85             :     class Vehicle: public VehicleFlow {
      86             :         friend Routes;
      87             : 
      88             :         Time depart;
      89             : 
      90             :         Vehicle(
      91             :             ID    id,
      92             :             Route route,
      93             :             Time  depart
      94             :         );
      95             : 
      96             :         virtual void toXML(rapidxml::xml_node<> &flowEl) const override;
      97             :         virtual void addToXML(rapidxml::xml_node<> &routesEl) const override;
      98             : 
      99             :        public:
     100           0 :         virtual ~Vehicle() = default;
     101             : 
     102             :         bool operator<(const Vehicle &other) const;
     103             :     };
     104             : 
     105             :     class Flow: public VehicleFlow {
     106             :         friend Routes;
     107             : 
     108             :        public:
     109           0 :         struct Policy {
     110             :             virtual void saveToXML(rapidxml::xml_node<> &flowEl) const = 0;
     111             :         };
     112             :         struct PolicyVehsPerHour: public Policy {
     113             :             double vehsPerHour;
     114             :             PolicyVehsPerHour(double vehsPerHour);
     115             :             virtual void saveToXML(rapidxml::xml_node<> &flowEl) const override;
     116             :         };
     117             :         struct PolicyPeriod: public Policy {
     118             :             std::optional<double>      f;
     119             :             std::optional<std::string> s;
     120             :             virtual void               saveToXML(rapidxml::xml_node<> &flowEl) const override;
     121             :         };
     122             :         struct PolicyProbability: public Policy {
     123             :             double       probability;
     124             :             virtual void saveToXML(rapidxml::xml_node<> &flowEl) const override;
     125             :         };
     126             : 
     127             :        private:
     128             :         Time                    begin;
     129             :         Time                    end;
     130             :         std::shared_ptr<Policy> policy;
     131             : 
     132             :         Flow(
     133             :             ID                      id,
     134             :             Route                   route,
     135             :             Time                    begin,
     136             :             Time                    end,
     137             :             std::shared_ptr<Policy> policy
     138             :         );
     139             : 
     140             :         virtual void toXML(rapidxml::xml_node<> &flowEl) const override;
     141             :         virtual void addToXML(rapidxml::xml_node<> &routesEl) const override;
     142             : 
     143             :        public:
     144           0 :         virtual ~Flow() = default;
     145             :     };
     146             : 
     147             :    private:
     148             :     std::list<std::shared_ptr<Flow>> flows;
     149             : 
     150             :     // clang-format off
     151             :     std::set<
     152             :         std::shared_ptr<Vehicle>,
     153             :         utils::shared_ptr::less<Vehicle>
     154             :     > vehicles;
     155             :     // clang-format on
     156             : 
     157             :    public:
     158             :     Vehicle &createVehicle(
     159             :         ID    id,
     160             :         Route route,
     161             :         Time  depart
     162             :     );
     163             : 
     164             :     Flow &createFlow(
     165             :         ID                            id,
     166             :         Route                         route,
     167             :         Time                          begin,
     168             :         Time                          end,
     169             :         std::shared_ptr<Flow::Policy> policy
     170             :     );
     171             : 
     172             :     void saveToFile(const std::string &filePath) const;
     173             : };
     174             : 
     175             : // clang-format off
     176             : template<>
     177             : class Routes::Loader<
     178             :     const Static::Network &,
     179             :     const Static::Solution &,
     180             :     const Static::SUMOAdapter &
     181             : > {
     182             :    public:
     183             :     Routes load(
     184             :         const Static::Network &network,
     185             :         const Static::Solution &x,
     186             :         const Static::SUMOAdapter &adapter
     187             :     );
     188             : };
     189             : // clang-format on
     190             : 
     191             : // clang-format off
     192             : template<>
     193             : class Routes::Loader<
     194             :     const std::list<std::reference_wrapper<const Dynamic::Env::Vehicle>> &,
     195             :     const SUMO::TAZs &,
     196             :     const Dynamic::SUMOAdapter &
     197             : > {
     198             :    public:
     199             :     Routes load(
     200             :         const std::list<std::reference_wrapper<const Dynamic::Env::Vehicle>> &vehicles,
     201             :         const SUMO::TAZs &tazs,
     202             :         const Dynamic::SUMOAdapter &adapter
     203             :     );
     204             : };
     205             : // clang-format on
     206             : 
     207             : }  // namespace SUMO
     208             : 
     209             : namespace utils::stringify {
     210             : template<>
     211             : class stringify<SUMO::Routes::VehicleFlow::DepartPos> {
     212             :    public:
     213             :     static SUMO::Routes::VehicleFlow::DepartPos fromString(const std::string &s);
     214             : 
     215             :     static std::string toString(const SUMO::Routes::VehicleFlow::DepartPos &t);
     216             : };
     217             : 
     218             : template<>
     219             : class stringify<SUMO::Routes::VehicleFlow::DepartSpeed> {
     220             :    public:
     221             :     static SUMO::Routes::VehicleFlow::DepartSpeed fromString(const std::string &s);
     222             : 
     223             :     static std::string toString(const SUMO::Routes::VehicleFlow::DepartSpeed &t);
     224             : };
     225             : }  // namespace utils::stringify

Generated by: LCOV version 1.14