Eclipse SUMO - Simulation of Urban MObility
MSPushButton.h
Go to the documentation of this file.
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 /****************************************************************************/
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 
34 class MSPushButton {
35 public:
36  virtual ~MSPushButton();
37 
42  virtual bool isActivated() const = 0;
43 
48  static bool anyActive(const std::vector<MSPushButton*>&);
49 protected:
55  MSPushButton(const MSEdge* edge, const MSEdge* crossingEdge);
56  const MSEdge* m_edge;
58 };
59 
64 public:
70  MSPedestrianPushButton(const MSEdge* walkingEdge, const MSEdge* crossingEdge);
72  }
73 
76  bool isActivated() const;
78 
84  static bool isActiveForEdge(const MSEdge* walkingEdge, const MSEdge* crossing);
85 
91  static bool isActiveOnAnySideOfTheRoad(const MSEdge* crossing);
92 
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;
103 // Load the crossingEdgeMap
104  static void loadCrossingEdgeMap();
105 };
A road/street connecting two junctions.
Definition: MSEdge.h:77
static bool isActiveOnAnySideOfTheRoad(const MSEdge *crossing)
Static method to check if the push button is active on both side of the road.
static bool isActiveForEdge(const MSEdge *walkingEdge, const MSEdge *crossing)
Static method with the same behavior of isActivated.
static std::vector< MSPushButton * > loadPushButtons(const MSPhaseDefinition *)
Loads all the pushbuttons for all the controlled lanes of a stage.
virtual ~MSPedestrianPushButton()
Definition: MSPushButton.h:71
bool isActivated() const
abstract methods inherited from PedestrianState
static bool m_crossingEdgeMapLoaded
Definition: MSPushButton.h:102
static void loadCrossingEdgeMap()
MSPedestrianPushButton(const MSEdge *walkingEdge, const MSEdge *crossingEdge)
static std::map< std::string, std::vector< std::string > > m_crossingEdgeMap
Definition: MSPushButton.h:101
The definition of a single phase of a tls logic.
MSPushButton(const MSEdge *edge, const MSEdge *crossingEdge)
virtual bool isActivated() const =0
Checks if the the pushbutton has been pressed.
const MSEdge * m_edge
Definition: MSPushButton.h:56
virtual ~MSPushButton()
const MSEdge * m_crossingEdge
Definition: MSPushButton.h:57
static bool anyActive(const std::vector< MSPushButton * > &)
Checks if any pushbutton in the vector is active.