]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/dummy.h
Rename the project to R²C²
[r2c2.git] / source / libr2c2 / dummy.h
diff --git a/source/libr2c2/dummy.h b/source/libr2c2/dummy.h
new file mode 100644 (file)
index 0000000..5357bbd
--- /dev/null
@@ -0,0 +1,59 @@
+/* $Id$
+
+This file is part of R²C²
+Copyright © 2010  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef LIBR2C2_DUMMY_H_
+#define LIBR2C2_DUMMY_H_
+
+#include <map>
+#include "driver.h"
+
+namespace R2C2 {
+
+class Dummy: public Driver
+{
+private:
+       struct LocoState
+       {
+               unsigned speed;
+               bool reverse;
+       };
+
+       bool power;
+       std::map<unsigned, bool> turnouts;
+       std::map<unsigned, LocoState> locos;
+       std::map<unsigned, bool> sensors;
+
+public:
+       Dummy();
+
+       virtual void set_power(bool);
+       virtual bool get_power() const { return power; }
+       virtual void halt(bool) { }
+       virtual bool is_halted() const { return false; }
+
+       virtual const char *enumerate_protocols(unsigned) const;
+       virtual unsigned get_protocol_speed_steps(const std::string &) const;
+       virtual void add_loco(unsigned, const std::string &) { }
+       virtual void set_loco_speed(unsigned, unsigned);
+       virtual void set_loco_reverse(unsigned, bool);
+       virtual void set_loco_function(unsigned, unsigned, bool);
+
+       virtual void add_turnout(unsigned);
+       virtual void set_turnout(unsigned, bool);
+       virtual bool get_turnout(unsigned) const;
+
+       virtual void add_sensor(unsigned) { }
+       virtual void set_sensor(unsigned, bool);
+       virtual bool get_sensor(unsigned) const;
+
+       virtual void tick() { }
+       virtual void flush() { }
+};
+
+} // namespace R2C2
+
+#endif