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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <initializer_list>
       4             : #include <list>
       5             : #include <optional>
       6             : #include <string>
       7             : #include <vector>
       8             : 
       9             : #include "Vector2.hpp"
      10             : #include "utils/stringify.hpp"
      11             : 
      12             : /**
      13             :  * @brief SUMO (Simulation of Urban MObility) is an open source, portable,
      14             :  * microscopic and continuous multi-modal traffic simulation package designed to
      15             :  * handle large networks.
      16             :  *
      17             :  * SUMO is developed by the German Aerospace Center and community users. It has
      18             :  * been freely available as open-source since 2001, and since 2017 it is an
      19             :  * Eclipse Foundation project. (Wikipedia)
      20             :  */
      21             : namespace SUMO {
      22             : typedef std::string ID;
      23             : typedef double      Time;
      24             : typedef double      Length;
      25             : typedef double      Speed;
      26             : typedef size_t      Index;
      27             : 
      28             : struct Coord: public Vector2 {
      29             :     double Z = 0.0;
      30             : 
      31           0 :     Coord() = default;
      32             :     Coord(double x, double y, double z = 0.0);
      33             : 
      34             :     Coord operator+(const Coord &rhs) const;
      35             :     Coord operator+(const Vector2 &rhs) const;
      36             : 
      37             :     Coord operator-(const Coord &rhs) const;
      38             :     Coord operator-(const Vector2 &rhs) const;
      39             : 
      40             :     Coord operator*(double rhs) const;
      41             :     Coord operator/(double rhs) const;
      42             : };
      43             : 
      44             : class Shape {
      45             :    private:
      46             :     std::vector<Coord>            v;
      47             :     mutable std::vector<Length>   lengths;
      48             :     mutable std::optional<Length> len;
      49             : 
      50             :     void computeLengths() const;
      51             : 
      52             :    public:
      53             :     typedef std::vector<Coord>::iterator         iterator;
      54             :     typedef std::vector<Coord>::const_iterator   const_iterator;
      55             :     typedef std::vector<Coord>::reverse_iterator reverse_iterator;
      56             : 
      57             :     Shape(std::initializer_list<Coord> il);
      58             : 
      59             :     template<class Iterator>
      60       64478 :     Shape(Iterator begin, Iterator end):
      61       64478 :         v(begin, end) {}
      62             : 
      63             :     Coord       front();
      64             :     const Coord front() const;
      65             : 
      66             :     Coord       back();
      67             :     const Coord back() const;
      68             : 
      69             :     iterator begin();
      70             :     iterator end();
      71             : 
      72             :     const_iterator begin() const;
      73             :     const_iterator end() const;
      74             : 
      75             :     size_t size() const;
      76             :     bool   empty() const;
      77             : 
      78             :     Coord       &at(size_t i);
      79             :     const Coord &at(size_t i) const;
      80             : 
      81             :     Coord       &operator[](size_t i);
      82             :     const Coord &operator[](size_t i) const;
      83             : 
      84             :     Coord   locationAtProgress(double progress) const;
      85             :     Vector2 directionAtProgress(double progress) const;
      86             :     Length  length() const;
      87             : 
      88             :     double getProgress(SUMO::Length l) const;
      89             : };
      90             : }  // namespace SUMO
      91             : 
      92             : namespace std {
      93             : template<>
      94             : struct hash<SUMO::Coord> {
      95             :     size_t operator()(const SUMO::Coord &v) const;
      96             : };
      97             : }  // namespace std
      98             : 
      99             : namespace utils::stringify {
     100             : 
     101             : template<>
     102             : class stringify<SUMO::Coord> {
     103             :    public:
     104             :     static SUMO::Coord fromString(const std::string &s);
     105             :     static std::string toString(const SUMO::Coord &t);
     106             : };
     107             : 
     108             : template<>
     109             : class stringify<std::pair<SUMO::Coord, SUMO::Coord>> {
     110             :    public:
     111             :     static std::pair<SUMO::Coord, SUMO::Coord> fromString(const std::string &s);
     112             :     static std::string                         toString(const std::pair<SUMO::Coord, SUMO::Coord> &t);
     113             : };
     114             : 
     115             : template<>
     116             : class stringify<SUMO::Shape> {
     117             :    public:
     118             :     static SUMO::Shape fromString(const std::string &s);
     119             :     static std::string toString(const SUMO::Shape &t);
     120             : };
     121             : 
     122             : }  // namespace utils::stringify

Generated by: LCOV version 1.14