+
+bool SMUX::UpdateTables()
+{
+Sensors newSensors;
+bool done = true;
+Tables::iterator it(tables.begin());
+while (it != tables.end())
+ {
+ try
+ {
+ it->second->UpdateSensors(newSensors);
+ }
+ catch (const std::runtime_error & ex)
+ {
+ printfd(__FILE__,
+ "SMUX::UpdateTables - failed to update table '%s': '%s'\n",
+ it->first.c_str(), ex.what());
+ done = false;
+ break;
+ }
+ ++it;
+ }
+if (!done)
+ {
+ Sensors::iterator it(newSensors.begin());
+ while (it != newSensors.end())
+ {
+ delete it->second;
+ ++it;
+ }
+ return false;
+ }
+
+it = tables.begin();
+while (it != tables.end())
+ {
+ std::pair<Sensors::iterator, Sensors::iterator> res;
+ res = std::equal_range(sensors.begin(),
+ sensors.end(),
+ std::pair<OID, Sensor *>(OID(it->first), NULL),
+ SPrefixLess);
+ Sensors::iterator sit(res.first);
+ while (sit != res.second)
+ {
+ delete sit->second;
+ ++sit;
+ }
+ sensors.erase(res.first, res.second);
+ ++it;
+ }
+
+sensors.insert(newSensors.begin(), newSensors.end());
+
+return true;
+}