]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/controller.h
Make LCD output selectable at runtime through an extra I/O pin
[r2c2.git] / source / libmarklin / controller.h
index b8075482ebf83f71a3428fc44eb3be1322dde57e..ac5128bcd0e724505a90dc4f923b0ce29af2caae 100644 (file)
@@ -14,8 +14,6 @@ Distributed under the GPL
 
 namespace Marklin {
 
-struct TrainControl;
-
 /**
 Interface class for train controllers.  Takes input through a uniform named
 control interface.  Provides information about train movement on output.
@@ -23,7 +21,34 @@ 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() { }
@@ -31,7 +56,7 @@ public:
        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;