#include "clock.h"
+using namespace std;
using namespace Msp;
namespace R2C2 {
signal_minute.emit();
}
+void Clock::save(list<DataFile::Statement> &st) const
+{
+ st.push_back((DataFile::Statement("rate"), rate));
+ st.push_back((DataFile::Statement("time"), current_time.raw()));
+}
+
+
+Clock::Loader::Loader(Clock &c):
+ DataFile::ObjectLoader<Clock>(c)
+{
+ add("rate", &Clock::rate);
+ add("time", &Loader::time);
+}
+
+void Clock::Loader::time(Time::RawTime t)
+{
+ obj.set_current_time(Time::TimeDelta(t));
+}
+
} // namespace R2C2
#define LIBR2C2_CLOCK_H_
#include <sigc++/signal.h>
+#include <msp/datafile/objectloader.h>
#include <msp/time/timedelta.h>
namespace R2C2 {
class Clock
{
public:
+ class Loader: public Msp::DataFile::ObjectLoader<Clock>
+ {
+ public:
+ Loader(Clock &);
+
+ private:
+ void time(Msp::Time::RawTime);
+ };
+
sigc::signal<void> signal_minute;
private:
void set_current_time(const Msp::Time::TimeDelta &);
const Msp::Time::TimeDelta &get_current_time() const { return current_time; }
void tick(const Msp::Time::TimeDelta &);
+ void save(std::list<Msp::DataFile::Statement> &) const;
};
} // namespace R2C2
IO::BufferedFile out(fn, IO::M_WRITE);
DataFile::Writer writer(out);
+ {
+ DataFile::Statement st("clock");
+ clock.save(st.sub);
+ writer.write(st);
+ }
+
const set<Track *> &tracks = objects.get<Track>();
for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
if(unsigned taddr = (*i)->get_turnout_address())
{
add("base", &Layout::base);
add("beamgate", &Loader::beamgate);
+ add("clock", &Loader::clock);
add("route", &Loader::route);
add("signal", &Loader::signal);
add("terrain", &Loader::terrain);
load_sub(*gate);
}
+void Layout::Loader::clock()
+{
+ load_sub(obj.clock);
+}
+
void Layout::Loader::route()
{
Route *rte = new Route(obj);
Loader(Layout &);
private:
void beamgate();
+ void clock();
void route();
void signal(ArticleNumber);
void terrain(ArticleNumber);