X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=d4e9d12d8ef7b08682f0f9c97d5f4cb36a3cce38;hb=66c2c7ca5a4bd369293959bc211b040834343381;hp=cf496c41ddae554b98da55d62e67bc2b3e0179b4;hpb=d15ac13f2e170f155b4bbd124df48400c339b644;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index cf496c4..d4e9d12 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -21,7 +21,8 @@ Track::Track(Layout &l, const TrackType &t): turnout_id(0), sensor_id(0), links(type.get_endpoints().size()), - active_path(0) + active_path(0), + path_changing(false) { if(type.is_turnout()) turnout_id = layout.allocate_turnout_id(); @@ -43,9 +44,9 @@ Track::~Track() void Track::set_block(Block *b) { if(b && !b->has_track(*this)) - throw InvalidParameterValue("Track is not in the Block"); + throw logic_error("track not in block"); if(!b && block && block->has_track(*this)) - throw InvalidState("Track is still in a Block"); + throw logic_error("track still in block"); block = b; } @@ -53,7 +54,7 @@ void Track::set_block(Block *b) Block &Track::get_block() const { if(!block) - throw InvalidState("No Block"); + throw logic_error("!block"); return *block; } @@ -116,7 +117,7 @@ void Track::check_slope() void Track::set_turnout_id(unsigned i) { if(!type.is_turnout()) - throw InvalidState("Not a turnout"); + throw logic_error("not a turnout"); turnout_id = i; layout.create_blocks(*this); @@ -128,7 +129,7 @@ void Track::set_turnout_id(unsigned i) void Track::set_sensor_id(unsigned i) { if(type.is_turnout()) - throw InvalidState("Can't set sensor on a turnout"); + throw logic_error("is a turnout"); sensor_id = i; layout.create_blocks(*this); @@ -139,10 +140,11 @@ void Track::set_sensor_id(unsigned i) void Track::set_active_path(unsigned p) { if(!turnout_id) - throw InvalidState("Not a turnout"); + throw logic_error("not a turnout"); if(!(type.get_paths()&(1<
&eps = type.get_endpoints();
if(epi>=eps.size())
- throw InvalidParameterValue("TrackType::Endpoint index out of range");
+ throw out_of_range("Track::get_endpoint_position");
const TrackType::Endpoint &ep = eps[epi];
@@ -176,7 +178,7 @@ float Track::get_endpoint_direction(unsigned epi) const
{
const vector