+/* $Id$
+
+This file is part of R²C²
+Copyright © 2011 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef LIBR2C2_TRAINAI_H_
+#define LIBR2C2_TRAINAI_H_
+
+#include <string>
+#include <sigc++/signal.h>
+#include <msp/core/variant.h>
+#include <msp/time/timedelta.h>
+#include <msp/time/timestamp.h>
+
+namespace R2C2 {
+
+class Train;
+
+/**
+Base class for train AIs.
+
+AIs can help the user in various ways, ranging from automatically stopping the
+train at the end of allocated track to autonomously running a train.
+
+XXX The timestamp should be removed from tick, but Timetable depends on it
+*/
+class TrainAI
+{
+public:
+ struct Message
+ {
+ std::string type;
+ Msp::Variant value;
+
+ Message(const std::string &t): type(t) { }
+
+ template<typename T>
+ Message(const std::string &t, const T &v): type(t), value(v) { }
+ };
+
+ sigc::signal<void, const Message &> signal_event;
+
+protected:
+ Train &train;
+ std::string tag;
+
+ TrainAI(Train &);
+public:
+ virtual ~TrainAI();
+
+ void set_tag(const std::string &);
+ const std::string &get_tag() const { return tag; }
+
+ virtual void message(const Message &) { }
+ virtual void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &) { }
+};
+
+} // namespace R2C2
+
+#endif