File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,17 @@ namespace dsm {
142142 }
143143 }
144144
145+ bool TrafficLight::isDefault () const {
146+ for (auto const & [streetId, cycles] : m_cycles) {
147+ for (auto const & cycle : cycles) {
148+ if (!cycle.isDefault ()) {
149+ return false ;
150+ }
151+ }
152+ }
153+ return true ;
154+ }
155+
145156 bool TrafficLight::isGreen (Id const streetId, Direction direction) const {
146157 if (!m_cycles.contains (streetId)) {
147158 throw std::invalid_argument (buildLog (
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ namespace dsm {
2929
3030 inline Delay greenTime () const { return m_greenTime; }
3131 inline Delay phase () const { return m_phase; }
32+ // / @brief Returns true if the cycle has its default values
33+ inline bool isDefault () const {
34+ return m_greenTime == m_defaultValues.first && m_phase == m_defaultValues.second ;
35+ }
3236 // / @brief Returns true if the traffic light is green
3337 // / @param cycleTime Delay, the total time of a red-green cycle
3438 // / @param counter Delay, the current counter
@@ -111,6 +115,8 @@ namespace dsm {
111115 inline std::unordered_map<Id, std::vector<TrafficLightCycle>> const & cycles () const {
112116 return m_cycles;
113117 }
118+ // / @brief Returns true if all the cycles are set to their default values
119+ bool isDefault () const ;
114120 // / @brief Returns true if the traffic light is green for a street and a direction
115121 // / @param streetId Id, the street's id
116122 // / @param direction Direction, the direction
You can’t perform that action at this time.
0 commit comments