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 /****************************************************************************/
15 // The class for a PushButton
16 /****************************************************************************/
17 
18 #ifndef SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_
19 #define SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_
20 
21 #include <vector>
22 #include <map>
23 #include <string>
24 
25 class MSEdge;
26 class MSPhaseDefinition;
27 
31 class MSPushButton {
32 public:
33  virtual ~MSPushButton();
34 
39  virtual bool isActivated() const = 0;
40 
45  static bool anyActive(const std::vector<MSPushButton*>&);
46 protected:
52  MSPushButton(const MSEdge* edge, const MSEdge* crossingEdge);
53  const MSEdge* m_edge;
55 };
56 
61 public:
67  MSPedestrianPushButton(const MSEdge* walkingEdge, const MSEdge* crossingEdge);
69  }
70 
73  bool isActivated() const;
75 
81  static bool isActiveForEdge(const MSEdge* walkingEdge, const MSEdge* crossing);
82 
88  static bool isActiveOnAnySideOfTheRoad(const MSEdge* crossing);
89 
95  static std::vector<MSPushButton*> loadPushButtons(const MSPhaseDefinition*);
96 private:
97 // Map edge id -> list of crossing edges that crosses it
98  static std::map<std::string, std::vector<std::string> > m_crossingEdgeMap;
100 // Load the crossingEdgeMap
101  static void loadCrossingEdgeMap();
102 };
103 
104 #endif /* SRC_MICROSIM_TRAFFIC_LIGHTS_MSPUSHBUTTON_H_ */
MSPushButton::~MSPushButton
virtual ~MSPushButton()
Definition: MSPushButton.cpp:32
MSPushButton::anyActive
static bool anyActive(const std::vector< MSPushButton * > &)
Checks if any pushbutton in the vector is active.
Definition: MSPushButton.cpp:36
MSPushButton
Definition: MSPushButton.h:31
MSPedestrianPushButton::m_crossingEdgeMap
static std::map< std::string, std::vector< std::string > > m_crossingEdgeMap
Definition: MSPushButton.h:98
MSPushButton::m_edge
const MSEdge * m_edge
Definition: MSPushButton.h:53
MSPedestrianPushButton::~MSPedestrianPushButton
virtual ~MSPedestrianPushButton()
Definition: MSPushButton.h:68
MSPedestrianPushButton::MSPedestrianPushButton
MSPedestrianPushButton(const MSEdge *walkingEdge, const MSEdge *crossingEdge)
Definition: MSPushButton.cpp:48
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:54
MSPedestrianPushButton::loadCrossingEdgeMap
static void loadCrossingEdgeMap()
Definition: MSPushButton.cpp:182
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSPedestrianPushButton::m_crossingEdgeMapLoaded
static bool m_crossingEdgeMapLoaded
Definition: MSPushButton.h:99
MSPedestrianPushButton::loadPushButtons
static std::vector< MSPushButton * > loadPushButtons(const MSPhaseDefinition *)
Loads all the pushbuttons for all the controlled lanes of a stage.
Definition: MSPushButton.cpp:149
MSPushButton::MSPushButton
MSPushButton(const MSEdge *edge, const MSEdge *crossingEdge)
Definition: MSPushButton.cpp:27
MSPedestrianPushButton::isActivated
bool isActivated() const
abstract methods inherited from PedestrianState
Definition: MSPushButton.cpp:54
MSPedestrianPushButton
Definition: MSPushButton.h:60
MSPedestrianPushButton::isActiveForEdge
static bool isActiveForEdge(const MSEdge *walkingEdge, const MSEdge *crossing)
Static method with the same behavior of isActivated.
Definition: MSPushButton.cpp:58
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:52
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:137