LCOV - code coverage report
Current view: top level - app/src/Dynamic/Env - Edge.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 72 6.9 %
Date: 2023-08-17 16:45:52 Functions: 1 15 6.7 %

          Line data    Source code
       1             : #include "Dynamic/Env/Edge.hpp"
       2             : 
       3             : #include "Dynamic/Env/Lane.hpp"
       4             : 
       5             : using namespace std;
       6             : using namespace Dynamic;
       7             : using namespace Dynamic::Env;
       8             : 
       9           1 : Edge::Edge(
      10             :     ID       id_,
      11             :     Node     u_,
      12             :     Node     v_,
      13             :     Length   length_,
      14             :     Speed    maxSpeed_,
      15             :     Priority priority_,
      16             :     size_t   nLanes
      17           1 : ):
      18             :     id(id_),
      19             :     u(u_),
      20             :     v(v_),
      21             :     length(length_),
      22             :     maxSpeed(maxSpeed_),
      23           1 :     priority(priority_) {
      24           1 :     for(Lane::Index i = 0; i < nLanes; i++)
      25           0 :         lanes.emplace_back(*this, i);
      26           1 : }
      27             : 
      28           0 : Edge::Edge(const Edge &e):
      29             :     Edge(
      30           0 :         e.id,
      31           0 :         e.u,
      32           0 :         e.v,
      33           0 :         e.length,
      34           0 :         e.maxSpeed,
      35           0 :         e.priority,
      36             :         e.lanes.size()
      37           0 :     ) {}
      38             : 
      39           0 : Edge::Edge() {}
      40             : 
      41           0 : Edge &Edge::operator=(const Edge &e) {
      42           0 :     id       = e.id;
      43           0 :     u        = e.u;
      44           0 :     v        = e.v;
      45           0 :     length   = e.length;
      46           0 :     maxSpeed = e.maxSpeed;
      47             : 
      48           0 :     size_t nLanes = e.lanes.size();
      49           0 :     lanes.clear();
      50           0 :     for(Lane::Index i = 0; i < nLanes; i++)
      51           0 :         lanes.emplace_back(*this, i);
      52             : 
      53           0 :     return *this;
      54             : }
      55             : 
      56           0 : Speed Edge::calculateSpeed() const {
      57           0 :     return maxSpeed;
      58             : }
      59             : 
      60           0 : list<reference_wrapper<const Connection>> Edge::getOutgoingConnections() const {
      61           0 :     list<reference_wrapper<const Connection>> ret;
      62           0 :     for(const Lane &lane: lanes) {
      63           0 :         for(Connection &connection: lane.getOutgoingConnections())
      64           0 :             ret.push_back(connection);
      65             :     }
      66           0 :     return ret;
      67             : }
      68             : 
      69           0 : list<reference_wrapper<Connection>> Edge::getOutgoingConnections() {
      70           0 :     list<reference_wrapper<Connection>> ret;
      71           0 :     for(Lane &lane: lanes) {
      72           0 :         for(Connection &connection: lane.getOutgoingConnections())
      73           0 :             ret.push_back(connection);
      74             :     }
      75           0 :     return ret;
      76             : }
      77             : 
      78           0 : list<reference_wrapper<const Connection>> Edge::getOutgoingConnections(const Edge &destinationEdge) const {
      79           0 :     list<reference_wrapper<const Connection>> ret;
      80           0 :     for(const Lane &lane: lanes) {
      81           0 :         for(Connection &connection: lane.getOutgoingConnections(destinationEdge))
      82           0 :             ret.push_back(connection);
      83             :     }
      84           0 :     return ret;
      85             : }
      86             : 
      87           0 : list<reference_wrapper<Connection>> Edge::getOutgoingConnections(const Edge &destinationEdge) {
      88           0 :     list<reference_wrapper<Connection>> ret;
      89           0 :     for(Lane &lane: lanes) {
      90           0 :         for(Connection &connection: lane.getOutgoingConnections(destinationEdge))
      91           0 :             ret.push_back(connection);
      92             :     }
      93           0 :     return ret;
      94             : }
      95             : 
      96           0 : list<reference_wrapper<Connection>> Edge::getIncomingConnections() {
      97           0 :     list<reference_wrapper<Connection>> ret;
      98           0 :     for(Lane &lane: lanes) {
      99           0 :         for(Connection &connection: lane.getIncomingConnections())
     100           0 :             ret.push_back(connection);
     101             :     }
     102           0 :     return ret;
     103             : }
     104             : 
     105           0 : list<reference_wrapper<const Connection>> Edge::getIncomingConnections() const {
     106           0 :     list<reference_wrapper<const Connection>> ret;
     107           0 :     for(const Lane &lane: lanes) {
     108           0 :         for(Connection &connection: lane.getIncomingConnections())
     109           0 :             ret.push_back(connection);
     110             :     }
     111           0 :     return ret;
     112             : }
     113             : 
     114           0 : bool Edge::operator==(const Edge &e) const {
     115           0 :     return id == e.id;
     116             : }
     117             : 
     118           0 : bool Edge::operator!=(const Edge &e) const {
     119           0 :     return !(*this == e);
     120             : }
     121             : 
     122           0 : bool Edge::operator<(const Edge &e) const {
     123           0 :     return id < e.id;
     124             : }
     125             : 
     126             : Edge Edge::INVALID = {-1, NODE_INVALID, NODE_INVALID, 0, 0, -1000, 0};
     127             : 
     128           0 : size_t std::hash<Edge>::operator()(const Edge &edge) const {
     129           0 :     return hash<Edge::ID>()(edge.id);
     130             : }

Generated by: LCOV version 1.14