X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fblock.cpp;h=386f2378a3b20011733cb54a17880cdd64a2d50b;hb=51d3c122fb489f9e3f00060f885f00c1fae7ceb5;hp=57cb4d30eb7fb62a3f0b15edb7d666f48b8bbdf8;hpb=b14059de03324aecde3efc649293d98ce5b7aaf2;p=r2c2.git diff --git a/source/libr2c2/block.cpp b/source/libr2c2/block.cpp index 57cb4d3..386f237 100644 --- a/source/libr2c2/block.cpp +++ b/source/libr2c2/block.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include "block.h" @@ -59,7 +52,7 @@ Block::Block(Layout &l, Track &start): { unsigned path = 1<=endpoints.size()) - throw InvalidParameterValue("Endpoint index out of range"); + throw out_of_range("Block::get_endpoint"); return endpoints[i]; } @@ -110,9 +103,9 @@ int Block::get_endpoint_by_link(Block &other) const float Block::get_path_length(unsigned entry, const Route *route) const { if(entry>=endpoints.size()) - throw InvalidParameterValue("Endpoint index out of range"); + throw out_of_range("Block::get_path_length"); - TrackIter t_iter(endpoints[entry].track, endpoints[entry].track_ep); + TrackIter t_iter = endpoints[entry].track_iter(); float result = 0; while(t_iter && has_track(*t_iter)) @@ -159,7 +152,7 @@ void Block::break_link(Block &other) Block *Block::get_link(unsigned epi) const { if(epi>=endpoints.size()) - throw InvalidParameterValue("Endpoint index out of range"); + throw out_of_range("Block::get_link"); return endpoints[epi].link; } @@ -192,7 +185,7 @@ void Block::tick(const Time::TimeDelta &dt) } } -void Block::find_paths(TrackIter track, unsigned path) +void Block::find_paths(const TrackIter &track, unsigned path) { unsigned mask = track.endpoint().paths; for(unsigned i=0; mask>>i; ++i) @@ -261,4 +254,9 @@ Block::Endpoint::Endpoint(Track *t, unsigned e): paths(0) { } +TrackIter Block::Endpoint::track_iter() const +{ + return TrackIter(track, track_ep); +} + } // namespace R2C2