3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_CONTROLLER_H_
9 #define LIBR2C2_CONTROLLER_H_
12 #include <sigc++/signal.h>
13 #include <msp/time/timedelta.h>
18 Interface class for train controllers. Takes input through a uniform named
19 control interface. Provides information about train movement on output.
46 static Control binary(const std::string &);
47 static Control discrete(const std::string &, float, float, float);
48 static Control continuous(const std::string &, float, float);
51 sigc::signal<void, const Control &> signal_control_changed;
56 virtual ~Controller() { }
58 virtual void set_control(const std::string &, float) = 0;
59 virtual const Control &get_control(const std::string &) const = 0;
61 /** Returns the current speed. Always non-negative. */
62 virtual float get_speed() const = 0;
64 /** Returns true if traveling in reverse. */
65 virtual bool get_reverse() const = 0;
67 /** Determines the distance required to come to a full stop. */
68 virtual float get_braking_distance() const = 0;
70 virtual void tick(const Msp::Time::TimeDelta &) = 0;