void Catalogue::Loader::track(ArticleNumber art_nr)
{
+ if(obj.tracks.count(art_nr))
+ throw KeyError("Duplicate track type", art_nr.str());
+
RefPtr<TrackType> trk = new TrackType(art_nr);
load_sub(*trk);
- obj.add_track(*trk);
- trk.release();
+ obj.add_track(*trk.release());
}
void Catalogue::Loader::vehicle(unsigned art_nr)
void Catalogue::Loader::vehicle(ArticleNumber art_nr)
{
+ if(obj.vehicles.count(art_nr))
+ throw KeyError("Duplicate vehicle type", art_nr.str());
+
RefPtr<VehicleType> veh = new VehicleType(art_nr);
load_sub(*veh);
- obj.add_vehicle(*veh);
- veh.release();
+ obj.add_vehicle(*veh.release());
}
} // namespace Marklin