Eclipse SUMO - Simulation of Urban MObility
MSRailSignalConstraint.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2020 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 // A constraint on rail signal switching
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
24 
25 // ===========================================================================
26 // class declarations
27 // ===========================================================================
28 class MSRailSignal;
29 class SUMOSAXAttributes;
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
40 public:
44 
47 
49  virtual bool cleared() const = 0;
50 
51  virtual std::string getDescription() const {
52  return "RailSignalConstraint";
53  }
54 
56  static void cleanup();
57 
59  static void saveState(OutputDevice& out);
60 
62  static void clearState();
63 
64 protected:
65  static std::string getVehID(const std::string& tripID);
66 };
67 
68 
70 public:
73  MSRailSignalConstraint_Predecessor(const MSRailSignal* signal, const std::string& tripId, int limit);
74 
77 
79  static void cleanup();
80 
82  static void saveState(OutputDevice& out);
83 
85  static void loadState(const SUMOSAXAttributes& attrs);
86 
88  static void clearState();
89 
90  bool cleared() const;
91 
92  std::string getDescription() const;
93 
94  class PassedTracker : public MSMoveReminder {
95  public:
96  PassedTracker(MSLane* lane);
97 
99 
100  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
103 
104  void raiseLimit(int limit);
105 
106  bool hasPassed(const std::string& tripId, int limit) const;
107 
109  void clearState();
110 
112  void saveState(OutputDevice& out);
113 
115  void loadState(int index, const std::vector<std::string>& tripIDs);
116 
118  std::vector<std::string> myPassed;
119 
122  };
123 
125  std::vector<PassedTracker*> myTrackers;
126 
128  const std::string myTripId;
129 
131  const int myLimit;
132 
133 
134  static std::map<const MSLane*, PassedTracker*> myTrackerLookup;
135 
136 private:
139 };
140 
141 
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
bool hasPassed(const std::string &tripId, int limit) const
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
tracks vehicles that passed this link (entered the next lane)
void loadState(int index, const std::vector< std::string > &tripIDs)
loads the current passed states into the given stream
void clearState()
Clear all passed states before quick-loading state.
std::vector< std::string > myPassed
passed tripIds
void saveState(OutputDevice &out)
Saves the current passed states into the given stream.
MSRailSignalConstraint_Predecessor & operator=(const MSRailSignalConstraint_Predecessor &s)=delete
invalidated assignment operator
bool cleared() const
whether the constraint has been met
static void loadState(const SUMOSAXAttributes &attrs)
loads the constraint state from the given attrs
static void saveState(OutputDevice &out)
Saves the current constraint states into the given stream.
const std::string myTripId
id of the predecessor that must already have passed
static void clearState()
Clear all constraint states before quick-loading state.
static std::map< const MSLane *, PassedTracker * > myTrackerLookup
std::vector< PassedTracker * > myTrackers
the tracker object for this constraint
const int myLimit
the number of passed vehicles within which tripId must have occured
MSRailSignalConstraint_Predecessor(const MSRailSignal *signal, const std::string &tripId, int limit)
Constructor.
A base class for constraints.
virtual std::string getDescription() const
static void saveState(OutputDevice &out)
Saves the current constraint states into the given stream.
static std::string getVehID(const std::string &tripID)
static void clearState()
Clear all constraint states before quick-loading state.
virtual bool cleared() const =0
whether the constraint has been met
static void cleanup()
clean up state
virtual ~MSRailSignalConstraint()
Destructor.
A signal for rails.
Definition: MSRailSignal.h:46
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.