From: Mikko Rasa Date: Fri, 11 Apr 2014 05:27:54 +0000 (+0300) Subject: Put signal_advanced in BlockAllocator X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4acf89b0ec739c0bef8b11d3a52a4c551efa881e;p=r2c2.git Put signal_advanced in BlockAllocator It's bad practice to emit other objects' signals. --- diff --git a/source/libr2c2/blockallocator.cpp b/source/libr2c2/blockallocator.cpp index 88fb12e..ba07e94 100644 --- a/source/libr2c2/blockallocator.cpp +++ b/source/libr2c2/blockallocator.cpp @@ -337,7 +337,7 @@ void BlockAllocator::advance_front(const Block *block, bool inclusive) // Update cur_blocks_end first to keep things consistent. cur_blocks_end = end; for(; i!=end; ++i) - train.signal_advanced.emit(**i); + signal_advanced.emit(**i); } void BlockAllocator::advance_front(const Sensor *sensor) diff --git a/source/libr2c2/blockallocator.h b/source/libr2c2/blockallocator.h index fe05603..6ba3cfb 100644 --- a/source/libr2c2/blockallocator.h +++ b/source/libr2c2/blockallocator.h @@ -27,6 +27,8 @@ public: void hint(unsigned); }; + sigc::signal signal_advanced; + private: struct BlockMatch; diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 78137b8..b278948 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -68,6 +68,8 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a, const string &p): layout.get_driver().signal_halt.connect(sigc::mem_fun(this, &Train::halt_event)); controller->signal_control_changed.connect(sigc::mem_fun(this, &Train::control_changed)); + + allocator.signal_advanced.connect(signal_advanced); } Train::~Train()