return -1;
}
-int Block::traverse(unsigned epi, float *len) const
+unsigned Block::traverse(unsigned epi, float *len) const
{
if(epi>=endpoints.size())
throw InvalidParameterValue("Endpoint index out of range");
if(len)
*len += track->get_type().get_path_length(cur_path);
- int other_ep = track->traverse(track_ep, cur_path);
- if(other_ep<0)
- return -1;
-
+ unsigned other_ep = track->traverse(track_ep, cur_path);
for(unsigned i=0; i<endpoints.size(); ++i)
if(endpoints[i].track==track && endpoints[i].track_ep==static_cast<unsigned>(other_ep))
return i;
Track *next = track->get_link(other_ep);
- if(tracks.count(next)==0)
- return -1;
+ if(!tracks.count(next))
+ throw LogicError("Block traversal strayed out of the block");
track_ep = next->get_endpoint_by_link(*track);
track = next;
}
const std::set<Track *> &get_tracks() const { return tracks; }
const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
int get_endpoint_by_link(const Block &) const;
- int traverse(unsigned, float * =0) const;
+ unsigned traverse(unsigned, float * =0) const;
void check_link(Block &);
Block *get_link(unsigned) const;
bool reserve(const Train *);
return links[i];
}
-int Track::traverse(unsigned i, unsigned path) const
+unsigned Track::traverse(unsigned i, unsigned path) const
{
const vector<Endpoint> &eps = type.get_endpoints();
if(i>=eps.size())
return j;
}
- return -1;
+ throw Exception("Track endpoint did not have a counterpart");
}
Point Track::get_point(unsigned epi, unsigned path, float d) const
void break_links();
const std::vector<Track *> &get_links() const { return links; }
Track *get_link(unsigned) const;
- int traverse(unsigned, unsigned) const;
+ unsigned traverse(unsigned, unsigned) const;
Point get_point(unsigned, unsigned, float) const;
/**