--- /dev/null
+#ifndef LIBR2C2_SIGNAL_H_
+#define LIBR2C2_SIGNAL_H_
+
+#include <msp/datafile/objectloader.h>
+#include <msp/time/timedelta.h>
+#include "geometry.h"
+
+namespace R2C2 {
+
+class Block;
+class Layout;
+class SignalType;
+class Track;
+class Train;
+
+class Signal
+{
+public:
+ class Loader: public Msp::DataFile::ObjectLoader<Signal>
+ {
+ public:
+ Loader(Signal &);
+
+ private:
+ void address(unsigned);
+ void direction(float);
+ void position(float, float, float);
+ };
+
+private:
+ Layout &layout;
+ const SignalType &type;
+ unsigned address;
+ Vector position;
+ float direction;
+ Track *track;
+ Block *block;
+ unsigned entry;
+ Train *train;
+ bool check_train_direction;
+ sigc::connection train_conn;
+ bool check_allocated_blocks;
+ bool passing;
+
+public:
+ Signal(Layout &, const SignalType &);
+ ~Signal();
+
+ const SignalType &get_type() const { return type; }
+
+ void set_address(unsigned);
+ void set_position(const Vector &);
+ void set_direction(float);
+private:
+ void normalize_location();
+public:
+ const Vector &get_position() const { return position; }
+ float get_direction() const { return direction; }
+
+ void tick(const Msp::Time::TimeDelta &);
+
+private:
+ void block_reserved(const Block &, Train *);
+ void train_advanced(Block &);
+ void reset();
+
+public:
+ void save(std::list<Msp::DataFile::Statement> &) const;
+};
+} // namespace R2C2
+
+
+#endif