3 This file is part of R²C²
4 Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_BLOCK_H_
9 #define LIBR2C2_BLOCK_H_
22 class Block: public sigc::trackable
40 Endpoint(Track *, unsigned);
43 sigc::signal<void, Train *> signal_reserved;
44 sigc::signal<void, State> signal_state_changed;
52 Msp::Time::TimeDelta state_confirm_timeout;
53 std::set<Track *> tracks;
54 std::vector<Endpoint> endpoints;
58 Block(Layout &, Track &);
61 unsigned get_id() const { return id; }
62 unsigned get_sensor_id() const { return sensor_id; }
63 unsigned get_turnout_id() const { return turnout_id; }
64 State get_state() const { return state; }
65 const std::set<Track *> &get_tracks() const { return tracks; }
66 bool has_track(Track &) const;
67 const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
68 const Endpoint &get_endpoint(unsigned) const;
69 int get_endpoint_by_link(Block &) const;
70 float get_path_length(unsigned, const Route * = 0) const;
71 void check_link(Block &);
72 void break_link(Block &);
73 Block *get_link(unsigned) const;
74 bool reserve(Train *);
75 Train *get_train() const { return train; }
76 void tick(const Msp::Time::TimeDelta &);
78 void find_paths(TrackIter, unsigned);
80 void sensor_event(unsigned, bool);