]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/blockallocator.cpp
Simplify some interfaces by using track and block iterators
[r2c2.git] / source / libr2c2 / blockallocator.cpp
index ac840d3debfdfabb3b78c02eab31ed2120f0280f..c9cc5b44440fe6987dff33fb0939cfbf4ca79363 100644 (file)
@@ -30,12 +30,15 @@ BlockAllocator::BlockAllocator(Train &t):
                        (*i)->signal_path_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &BlockAllocator::turnout_path_changed), sigc::ref(**i))));
 }
 
-void BlockAllocator::start_from(Block &block, unsigned entry)
+void BlockAllocator::start_from(const BlockIter &block)
 {
+       if(!block)
+               throw invalid_argument("BlockAllocator::start_from");
+
        release_blocks(blocks.begin(), blocks.end());
 
-       blocks.push_back(BlockIter(&block, entry));
-       if(!block.reserve(&train))
+       blocks.push_back(block);
+       if(!block->reserve(&train))
        {
                blocks.pop_back();
                return;