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.org/sumo
3 // Copyright (C) 2010-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // The class for a PushButton
15 /****************************************************************************/
16 
17 #ifndef SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_
18 #define SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_
19 
20 #include <vector>
21 #include <map>
22 #include <string>
23 
24 class MSEdge;
25 class MSPhaseDefinition;
26 
30 class MSPushButton {
31 public:
32  virtual ~MSPushButton();
33 
38  virtual bool isActivated() const = 0;
39 
44  static bool anyActive(const std::vector<MSPushButton*>&);
45 protected:
51  MSPushButton(const MSEdge* edge, const MSEdge* crossingEdge);
52  const MSEdge* m_edge;
54 };
55 
60 public:
66  MSPedestrianPushButton(const MSEdge* walkingEdge, const MSEdge* crossingEdge);
68  }
69 
72  bool isActivated() const;
74 
80  static bool isActiveForEdge(const MSEdge* walkingEdge, const MSEdge* crossing);
81 
87  static bool isActiveOnAnySideOfTheRoad(const MSEdge* crossing);
88 
94  static std::vector<MSPushButton*> loadPushButtons(const MSPhaseDefinition*);
95 private:
96 // Map edge id -> list of crossing edges that crosses it
97  static std::map<std::string, std::vector<std::string> > m_crossingEdgeMap;
99 // Load the crossingEdgeMap
100  static void loadCrossingEdgeMap();
101 };
102 
103 #endif /* SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_ */
MSPushButton::~MSPushButton
virtual ~MSPushButton()
Definition: MSPushButton.cpp:31
MSPushButton::anyActive
static bool anyActive(const std::vector< MSPushButton * > &)
Checks if any pushbutton in the vector is active.
Definition: MSPushButton.cpp:35
MSPushButton
Definition: MSPushButton.h:30
MSPedestrianPushButton::m_crossingEdgeMap
static std::map< std::string, std::vector< std::string > > m_crossingEdgeMap
Definition: MSPushButton.h:97
MSPushButton::m_edge
const MSEdge * m_edge
Definition: MSPushButton.h:52
MSPedestrianPushButton::~MSPedestrianPushButton
virtual ~MSPedestrianPushButton()
Definition: MSPushButton.h:67
MSPedestrianPushButton::MSPedestrianPushButton
MSPedestrianPushButton(const MSEdge *walkingEdge, const MSEdge *crossingEdge)
Definition: MSPushButton.cpp:47
MSPushButton::isActivated
virtual bool isActivated() const =0
Checks if the the pushbutton has been pressed.
MSPushButton::m_crossingEdge
const MSEdge * m_crossingEdge
Definition: MSPushButton.h:53
MSPedestrianPushButton::loadCrossingEdgeMap
static void loadCrossingEdgeMap()
Definition: MSPushButton.cpp:181
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSPedestrianPushButton::m_crossingEdgeMapLoaded
static bool m_crossingEdgeMapLoaded
Definition: MSPushButton.h:98
MSPedestrianPushButton::loadPushButtons
static std::vector< MSPushButton * > loadPushButtons(const MSPhaseDefinition *)
Loads all the pushbuttons for all the controlled lanes of a stage.
Definition: MSPushButton.cpp:148
MSPushButton::MSPushButton
MSPushButton(const MSEdge *edge, const MSEdge *crossingEdge)
Definition: MSPushButton.cpp:26
MSPedestrianPushButton::isActivated
bool isActivated() const
abstract methods inherited from PedestrianState
Definition: MSPushButton.cpp:53
MSPedestrianPushButton
Definition: MSPushButton.h:59
MSPedestrianPushButton::isActiveForEdge
static bool isActiveForEdge(const MSEdge *walkingEdge, const MSEdge *crossing)
Static method with the same behavior of isActivated.
Definition: MSPushButton.cpp:57
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSPedestrianPushButton::isActiveOnAnySideOfTheRoad
static bool isActiveOnAnySideOfTheRoad(const MSEdge *crossing)
Static method to check if the push button is active on both side of the road.
Definition: MSPushButton.cpp:136