]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/block.cpp
Add a utility function to get path length from Track
[r2c2.git] / source / libr2c2 / block.cpp
index f6818166d22c8996c58199abb45e464c2b54fcbc..f02762c85a958e668b5b4e200c86bcbb877f0767 100644 (file)
@@ -18,6 +18,7 @@ Block::Block(Layout &l, Track &start):
        id(0),
        sensor_id(start.get_sensor_id()),
        turnout_id(start.get_turnout_id()),
+       sensor(0),
        train(0)
 {
        add_track(start);
@@ -43,9 +44,10 @@ Block::Block(Layout &l, Track &start):
 
        determine_id();
 
-       sensor = new TrackCircuit(layout, *this);
+       if(sensor_id)
+               sensor = new TrackCircuit(layout, *this);
 
-       layout.add_block(*this);
+       layout.add(*this);
 }
 
 Block::~Block()
@@ -62,7 +64,7 @@ Block::~Block()
                        blk->break_link(*this);
                }
 
-       layout.remove_block(*this);
+       layout.remove(*this);
 
        delete sensor;
 }