3 This file is part of R²C²
4 Copyright © 2007-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_ROUTE_H_
9 #define LIBR2C2_ROUTE_H_
14 #include <sigc++/trackable.h>
15 #include <msp/datafile/loader.h>
24 class Route: public sigc::trackable
27 typedef std::map<unsigned, int> TurnoutMap;
29 class Loader: public Msp::DataFile::BasicLoader<Route>
37 virtual void finish();
38 void turnout(unsigned, unsigned);
41 sigc::signal<void, const std::string &> signal_name_changed;
47 std::set<Track *> tracks;
54 void set_name(const std::string &);
55 const std::string &get_name() const { return name; }
56 void set_temporary(bool);
57 bool is_temporary() const { return temporary; }
58 void set_turnout(unsigned, unsigned);
59 void update_turnouts();
60 int get_turnout(unsigned) const;
61 unsigned get_path(Track &) const;
62 const std::map<unsigned, int> &get_turnouts() const { return turnouts; }
63 void add_track(Track &);
64 void add_tracks(const std::set<Track *> &);
65 void add_track_chain(Track &, unsigned, const TurnoutMap &);
66 const std::set<Track *> &get_tracks() const { return tracks; }
67 bool has_track(Track &) const;
68 void save(std::list<Msp::DataFile::Statement> &) const;
70 unsigned check_validity(Track &) const;
71 void track_removed(Track &);
74 static Route *find(const TrackIter &, Track &);
75 static Route *find(const TrackIter &, const Route &);
76 static Route *find(const TrackIter &, const Zone &);
77 static Route *find(const TrackIter &, const std::set<Track *> &);