-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
#ifndef LIBR2C2_BLOCK_H_
#define LIBR2C2_BLOCK_H_
class TrackIter;
class Train;
-class Block
+class Block: public sigc::trackable
{
public:
+ enum State
+ {
+ INACTIVE,
+ MAYBE_INACTIVE,
+ MAYBE_ACTIVE,
+ ACTIVE
+ };
+
struct Endpoint
{
Track *track;
Endpoint(Track *, unsigned);
};
+ sigc::signal<void, Train *> signal_reserved;
+ sigc::signal<void, State> signal_state_changed;
+
private:
Layout &layout;
unsigned id;
unsigned sensor_id;
unsigned turnout_id;
+ State state;
+ Msp::Time::TimeDelta state_confirm_timeout;
std::set<Track *> tracks;
std::vector<Endpoint> endpoints;
Train *train;
unsigned get_id() const { return id; }
unsigned get_sensor_id() const { return sensor_id; }
unsigned get_turnout_id() const { return turnout_id; }
+ State get_state() const { return state; }
const std::set<Track *> &get_tracks() const { return tracks; }
bool has_track(Track &) const;
const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
Block *get_link(unsigned) const;
bool reserve(Train *);
Train *get_train() const { return train; }
- void print_debug();
+ void tick(const Msp::Time::TimeDelta &);
private:
void find_paths(TrackIter, unsigned);
void determine_id();
+ void sensor_event(unsigned, bool);
};
} // namespace R2C2