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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <ctpl_stl.h>
       4             : 
       5             : #include <fstream>
       6             : #include <future>
       7             : #include <map>
       8             : #include <string>
       9             : 
      10             : #include "Dynamic/Env/Env.hpp"
      11             : #include "Dynamic/SUMOAdapter.hpp"
      12             : #include "data/SUMO/Network.hpp"
      13             : #include "data/SUMO/SUMO.hpp"
      14             : #include "utils/synchronizer.hpp"
      15             : 
      16             : namespace SUMO {
      17             : class NetState: private std::mutex {
      18             :     std::queue<std::future<std::stringstream>> futuresQueue;
      19             : 
      20             :     const size_t maxQueueSize = 8;
      21             : 
      22             :     ctpl::thread_pool pool = ctpl::thread_pool(1);
      23             : 
      24             :    public:
      25           0 :     struct Timestep {
      26             :         template<typename T, typename... args>
      27             :         class Loader {
      28             :            public:
      29             :             Timestep load(T var1, args... var2);
      30             :         };
      31             : 
      32           0 :         struct Edge {
      33           0 :             struct Lane {
      34             :                 Network::Edge::Lane::ID id;
      35             : 
      36           0 :                 struct Vehicle {
      37             :                     typedef std::string ID;
      38             : 
      39             :                     ID     id;
      40             :                     Length pos;
      41             :                     Speed  speed;
      42             :                 };
      43             : 
      44             :                 std::vector<Vehicle> vehicles = {};
      45             : 
      46             :                 Vehicle &addVehicle(Vehicle::ID id, Length pos, Speed speed);
      47             : 
      48             :                 Index index() const;
      49             :             };
      50             : 
      51             :             Network::Edge::ID id;
      52             : 
      53             :             std::map<Network::Edge::Lane::ID, Lane> lanes = {};
      54             : 
      55             :             Lane &addLane(Network::Edge::Lane::ID id);
      56             :         };
      57             : 
      58             :         Time                              time;
      59             :         std::map<Network::Edge::ID, Edge> edges = {};
      60             : 
      61             :         Edge &addEdge(Network::Edge::ID id);
      62             : 
      63             :         void            toXML(rapidxml::xml_document<> &doc) const;
      64             :         static Timestep fromXML(rapidxml::xml_node<> &node);
      65             :     };
      66             : 
      67             :     NetState &operator<<(const Timestep &ts);
      68             :     NetState &operator>>(Timestep &ts);
      69             : 
      70             :    private:
      71             :     std::ofstream os;
      72             : 
      73             :     std::ifstream        is;
      74             :     std::queue<Timestep> tsBuffer;
      75             : 
      76             :    public:
      77             :     NetState(const std::string &filePath, std::ios_base::openmode openMode);
      78             : 
      79             :     operator bool() const;
      80             : 
      81             :     void close();
      82             : 
      83             :     ~NetState();
      84             : };
      85             : 
      86             : // clang-format off
      87             : template<>
      88             : class NetState::Timestep::Loader<
      89             :     Dynamic::Env::Env &,
      90             :     const Dynamic::SUMOAdapter &,
      91             :     Dynamic::Time
      92             : > {
      93             :     // clang-format on
      94             :    public:
      95             :     Timestep load(
      96             :         Dynamic::Env::Env          &env,
      97             :         const Dynamic::SUMOAdapter &adapter,
      98             :         Dynamic::Time               t
      99             :     );
     100             : };
     101             : 
     102             : }  // namespace SUMO

Generated by: LCOV version 1.14