- if(sensors.count(s->get_address())==0)
- {
- sensors.insert(SensorMap::value_type(s->get_address(), s));
- poll_sensors=true;
- }
+ locomotives[l.get_address()]=&l;
+}
+
+Locomotive &Control::get_locomotive(unsigned id) const
+{
+ map<unsigned, Locomotive *>::const_iterator i=locomotives.find(id);
+ if(i==locomotives.end())
+ throw KeyError("Unknown locomotive");
+
+ return *i->second;
+}
+
+void Control::add_sensor(Sensor &s)
+{
+ sensors[s.get_address()]=&s;
+ poll_sensors=true;
+}
+
+Sensor &Control::get_sensor(unsigned id) const
+{
+ map<unsigned, Sensor *>::const_iterator i=sensors.find(id);
+ if(i==sensors.end())
+ throw KeyError("Unknown sensor");
+
+ return *i->second;