]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/block.cpp
Add some shortcut functions for getting endpoints
[r2c2.git] / source / libmarklin / block.cpp
index 1519401220edf59481427c68621985c0cf528f69..e8e367f7255715dc3c7ac2343763ae7da11021bf 100644 (file)
@@ -84,6 +84,14 @@ bool Block::has_track(Track &t) const
        return tracks.count(&t);
 }
 
+const Block::Endpoint &Block::get_endpoint(unsigned i) const
+{
+       if(i>=endpoints.size())
+               throw InvalidParameterValue("Endpoint index out of range");
+
+       return endpoints[i];
+}
+
 int Block::get_endpoint_by_link(Block &other) const
 {
        for(unsigned i=0; i<endpoints.size(); ++i)
@@ -163,7 +171,7 @@ bool Block::reserve(Train *t)
 
 void Block::find_paths(TrackIter track, unsigned path)
 {
-       unsigned mask = track->get_type().get_endpoints()[track.entry()].paths;
+       unsigned mask = track.endpoint().paths;
        for(unsigned i=0; mask>>i; ++i)
                if(mask&(1<<i))
                {