]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/controller.h
Rename ControlModel to Controller
[r2c2.git] / source / libmarklin / controller.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_CONTROLLER_H_
9 #define LIBMARKLIN_CONTROLLER_H_
10
11 #include <string>
12 #include <sigc++/signal.h>
13 #include <msp/time/timedelta.h>
14
15 namespace Marklin {
16
17 struct TrainControl;
18
19 /**
20 Interface class for train controllers.  Takes input through a uniform named
21 control interface.  Provides information about train movement on output.
22 */
23 class Controller
24 {
25 public:
26         sigc::signal<void, const TrainControl &> signal_control_changed;
27
28 protected:
29         Controller() { }
30 public:
31         virtual ~Controller() { }
32
33         virtual void set_control(const std::string &, float) = 0;
34         virtual const TrainControl &get_control(const std::string &) const = 0;
35
36         /** Returns the current speed.  Always non-negative. */
37         virtual float get_speed() const = 0;
38
39         /** Returns true if traveling in reverse. */
40         virtual bool get_reverse() const = 0;
41
42         /** Determines the distance required to come to a full stop. */
43         virtual float get_braking_distance() const = 0;
44
45         virtual void tick(const Msp::Time::TimeDelta &) = 0;
46 };
47
48 } // namespace Marklin
49
50 #endif