3 #include "trafficmanager.h"
10 TrafficManager::TrafficManager(Control &c, Layout &l):
14 const TrackSeq &tracks=layout.get_tracks();
17 for(TrackSeq::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
19 if(unsigned tid=(*i)->get_turnout_id())
21 Turnout *t=control.get_turnout(tid);
23 t=new Turnout(control, tid);
24 //t->signal_route_changed.connect(sigc::mem_fun(*i, &Track::set_current_route));
26 if(unsigned sid=(*i)->get_sensor_id())
28 Sensor *s=control.get_sensor(sid);
30 s=new Sensor(control, sid);
32 if(used_tracks.count(*i)==0)
34 Block *block=new Block(*this, *i);
35 blocks.push_back(block);
36 used_tracks.insert(block->get_tracks().begin(), block->get_tracks().end());
40 for(BlockSeq::iterator i=blocks.begin(); i!=blocks.end(); ++i)
42 for(BlockSeq::iterator j=i; j!=blocks.end(); ++j)
44 (*i)->check_link(**j);
49 Block *TrafficManager::get_block_by_track(const Track *t) const
51 for(BlockSeq::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
53 const TrackSet &tracks=(*i)->get_tracks();
54 if(tracks.count(const_cast<Track *>(t)))
61 void TrafficManager::add_train(Train *t)
63 if(find(trains.begin(), trains.end(), t)==trains.end())
67 void TrafficManager::turnout_route_changed(unsigned, Turnout *)
71 } // namespace Marklin