]> git.tdb.fi Git - r2c2.git/commitdiff
Put signal_advanced in BlockAllocator
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Apr 2014 05:27:54 +0000 (08:27 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Apr 2014 05:27:54 +0000 (08:27 +0300)
It's bad practice to emit other objects' signals.

source/libr2c2/blockallocator.cpp
source/libr2c2/blockallocator.h
source/libr2c2/train.cpp

index 88fb12e8145baaf3f4e636311f9664b5a0a86e1d..ba07e94e76e96baa746edbab655b7b34b9233414 100644 (file)
@@ -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)
index fe05603e0e0c997d56058a7904a72afb3dc34fe1..6ba3cfbb7559ca7e718b2471cd9fca952fec44ce 100644 (file)
@@ -27,6 +27,8 @@ public:
                void hint(unsigned);
        };
 
+       sigc::signal<void, Block &> signal_advanced;
+
 private:
        struct BlockMatch;
 
index 78137b8703ddfc7162ec173f83046ff31bfe877b..b278948a83ed9c8d38d7694f293037a48ef99842 100644 (file)
@@ -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()