namespace Marklin {
-struct TrainControl;
-
/**
Interface class for train controllers. Takes input through a uniform named
control interface. Provides information about train movement on output.
class Controller
{
public:
- sigc::signal<void, const TrainControl &> signal_control_changed;
+ struct Control
+ {
+ enum Type
+ {
+ BINARY,
+ DISCRETE,
+ CONTINUOUS
+ };
+
+ std::string name;
+ Type type;
+ float min_value;
+ float max_value;
+ float step;
+ float value;
+
+ private:
+ Control() { }
+
+ public:
+ void set(float);
+
+ static Control binary(const std::string &);
+ static Control discrete(const std::string &, float, float, float);
+ static Control continuous(const std::string &, float, float);
+ };
+
+ sigc::signal<void, const Control &> signal_control_changed;
protected:
Controller() { }
virtual ~Controller() { }
virtual void set_control(const std::string &, float) = 0;
- virtual const TrainControl &get_control(const std::string &) const = 0;
+ virtual const Control &get_control(const std::string &) const = 0;
/** Returns the current speed. Always non-negative. */
virtual float get_speed() const = 0;