LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSPushButton.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 2 0.0 %
Date: 2024-05-19 15:37:39 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2010-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    MSPushButton.h
      15             : /// @author  Federico Caselli
      16             : /// @date    May 2015
      17             : ///
      18             : // The class for a PushButton
      19             : /****************************************************************************/
      20             : 
      21             : #pragma once
      22             : #include <config.h>
      23             : 
      24             : #include <vector>
      25             : #include <map>
      26             : #include <string>
      27             : 
      28             : class MSEdge;
      29             : class MSPhaseDefinition;
      30             : 
      31             : /**
      32             :  * Abstract push button class
      33             :  */
      34             : class MSPushButton {
      35             : public:
      36             :     virtual ~MSPushButton();
      37             : 
      38             :     /**
      39             :      * @brief Checks if the the pushbutton has been pressed
      40             :      * @return true if pressed, false otherwise
      41             :      */
      42             :     virtual bool isActivated() const = 0;
      43             : 
      44             :     /**
      45             :      * @brief Checks if any pushbutton in the vector is active
      46             :      * @return True if at least one pushbutton is active, false otherwise
      47             :      */
      48             :     static bool anyActive(const std::vector<MSPushButton*>&);
      49             : protected:
      50             :     /**
      51             :      * Protected constructor
      52             :      * @param[in] edge: the edge where the push button is located
      53             :      * @param[in] crossingEdge: the crossing controlled by the push button
      54             :      */
      55             :     MSPushButton(const MSEdge* edge, const MSEdge* crossingEdge);
      56             :     const MSEdge* m_edge;
      57             :     const MSEdge* m_crossingEdge;
      58             : };
      59             : 
      60             : /**
      61             :  * Pedestrian push button
      62             :  */
      63             : class MSPedestrianPushButton: MSPushButton {
      64             : public:
      65             :     /**
      66             :      * MSPedestrianPushButton constructor
      67             :      * @param[in] edge: the edge where the push button is located. Must be a walking area.
      68             :      * @param[in] crossingEdge: the crossing controlled by the push button. Must be a crossing.
      69             :      */
      70             :     MSPedestrianPushButton(const MSEdge* walkingEdge, const MSEdge* crossingEdge);
      71           0 :     virtual ~MSPedestrianPushButton() {
      72           0 :     }
      73             : 
      74             :     ///@brief  abstract methods inherited from PedestrianState
      75             :     ///@{
      76             :     bool isActivated() const;
      77             :     ///@}
      78             : 
      79             :     /**
      80             :      * @brief Static method with the same behavior of isActivated
      81             :      * @brief Checks if the the pushbutton has been pressed for a particular crossing from a edge.
      82             :      * @return true if pressed, false otherwise
      83             :      */
      84             :     static bool isActiveForEdge(const MSEdge* walkingEdge, const MSEdge* crossing);
      85             : 
      86             :     /**
      87             :      * @brief Static method to check if the push button is active on both side of the road
      88             :      * @param[in] A crossing edge
      89             :      * @return true if pressed, false otherwise
      90             :      */
      91             :     static bool isActiveOnAnySideOfTheRoad(const MSEdge* crossing);
      92             : 
      93             :     /**
      94             :      * @brief Loads all the pushbuttons for all the controlled lanes of a stage
      95             :      * @param[in] A phase definition
      96             :      * @return A list of pushbuttons
      97             :      */
      98             :     static std::vector<MSPushButton*> loadPushButtons(const MSPhaseDefinition*);
      99             : private:
     100             : //              Map edge id -> list of crossing edges that crosses it
     101             :     static std::map<std::string, std::vector<std::string> > m_crossingEdgeMap;
     102             :     static bool m_crossingEdgeMapLoaded;
     103             : //              Load the crossingEdgeMap
     104             :     static void loadCrossingEdgeMap();
     105             : };

Generated by: LCOV version 1.14