]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/controller.h
Rename ControlModel to Controller
[r2c2.git] / source / libmarklin / controller.h
diff --git a/source/libmarklin/controller.h b/source/libmarklin/controller.h
new file mode 100644 (file)
index 0000000..b807548
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2010  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef LIBMARKLIN_CONTROLLER_H_
+#define LIBMARKLIN_CONTROLLER_H_
+
+#include <string>
+#include <sigc++/signal.h>
+#include <msp/time/timedelta.h>
+
+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;
+
+protected:
+       Controller() { }
+public:
+       virtual ~Controller() { }
+
+       virtual void set_control(const std::string &, float) = 0;
+       virtual const TrainControl &get_control(const std::string &) const = 0;
+
+       /** Returns the current speed.  Always non-negative. */
+       virtual float get_speed() const = 0;
+
+       /** Returns true if traveling in reverse. */
+       virtual bool get_reverse() const = 0;
+
+       /** Determines the distance required to come to a full stop. */
+       virtual float get_braking_distance() const = 0;
+
+       virtual void tick(const Msp::Time::TimeDelta &) = 0;
+};
+
+} // namespace Marklin
+
+#endif