Permit dynamic insertion of sensor type codes

The existing sensorTypes flat_map is an immutable data structure. This
makes adding OEM style sensor types difficult. New entries, that may
not be general purpose either need to be pushed upstream for all, or
they have to be updated by carrying a patch. Keeping a patch up to
date is an undesirable method.

Instead of using either of the prior methods, make the flat_map a
writable object. Adding new entries can be done at run time using the
flat_map emplace() function. Adding new sensor types is recommended to
be done by overriding the weak linked getOtherSensorsCount(), placed
in the sensorcommands_oem.cpp file. Using a GCC 'constructor' style
function does not work due to uncertainty of initialization order.

See commit 777cfaf2b3:bb6667fbbea7612255137970c3dbdb
Enable OEM creation of non-Type1 SDRs

Tested:
Added an emplace() call into the strong linked getOtherSensorCommands
Used 'ipmitool sdr dump sdrs.bin'
Inspected the resulting SDR data and confirmed the sensors of interest
had an OEM type code as dictated by the sensorTypes map

Change-Id: Ifcf6297a8b161b720651bc6411409014c37ce88c
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index fa96c6b..b8cf3fa 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -36,6 +36,38 @@
 
 #endif
 
+boost::container::flat_map<
+    const char*, std::pair<SensorTypeCodes, SensorEventTypeCodes>, CmpStr>
+    sensorTypes{
+        {{"temperature", std::make_pair(SensorTypeCodes::temperature,
+                                        SensorEventTypeCodes::threshold)},
+         {"voltage", std::make_pair(SensorTypeCodes::voltage,
+                                    SensorEventTypeCodes::threshold)},
+         {"current", std::make_pair(SensorTypeCodes::current,
+                                    SensorEventTypeCodes::threshold)},
+         {"fan_tach", std::make_pair(SensorTypeCodes::fan,
+                                     SensorEventTypeCodes::threshold)},
+         {"fan_pwm", std::make_pair(SensorTypeCodes::fan,
+                                    SensorEventTypeCodes::threshold)},
+         {"intrusion", std::make_pair(SensorTypeCodes::physical_security,
+                                      SensorEventTypeCodes::sensorSpecified)},
+         {"processor", std::make_pair(SensorTypeCodes::processor,
+                                      SensorEventTypeCodes::sensorSpecified)},
+         {"power", std::make_pair(SensorTypeCodes::other,
+                                  SensorEventTypeCodes::threshold)},
+         {"memory", std::make_pair(SensorTypeCodes::memory,
+                                   SensorEventTypeCodes::sensorSpecified)},
+         {"state", std::make_pair(SensorTypeCodes::power_unit,
+                                  SensorEventTypeCodes::sensorSpecified)},
+         {"buttons", std::make_pair(SensorTypeCodes::buttons,
+                                    SensorEventTypeCodes::sensorSpecified)},
+         {"watchdog", std::make_pair(SensorTypeCodes::watchdog2,
+                                     SensorEventTypeCodes::sensorSpecified)},
+         {"entity", std::make_pair(SensorTypeCodes::entity,
+                                   SensorEventTypeCodes::sensorSpecified)},
+         {"energy", std::make_pair(SensorTypeCodes::other,
+                                   SensorEventTypeCodes::threshold)}}};
+
 namespace details
 {