sensorhandler: support setting analog sensors

Refactor YAML format to denote mutability of sensors.

Sensors which expect different formats for reads and writes
should present two entries in the sensor YAML, one with the read
interface and one with the write interface.  Sensors which
share a format for both reads and writes may present only one entry
in the YAML with both readable and writable enums specified.

If a sensor receives a write which has an interface of Sensor.Value,
the "Set" message is sent via DBus to the path provided in the YAML.
The previous codepath is maintained.

Change-Id: I292f95b6fe936de759fd65ce72c842a1bfe66448
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/types.hpp b/types.hpp
index 9c2237f..ae88faa 100644
--- a/types.hpp
+++ b/types.hpp
@@ -32,7 +32,6 @@
 {
 
 using Offset = uint8_t;
-using Value = ipmi::Value;
 
 struct Values
 {
@@ -42,10 +41,8 @@
 
 using OffsetValueMap = std::map<Offset,Values>;
 
-using DbusProperty = ipmi::DbusProperty;
 using DbusPropertyMap = std::map<DbusProperty,OffsetValueMap>;
 
-using DbusInterface = ipmi::DbusInterface;
 using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
 
 using InstancePath = std::string;
@@ -56,6 +53,24 @@
 using Exponent = uint8_t;
 using ScaledOffset = int64_t;
 
+enum class Mutability
+{
+   Read = 1 << 0,
+   Write = 1 << 1,
+};
+
+inline Mutability operator|(Mutability lhs, Mutability rhs)
+{
+  return static_cast<Mutability>(
+      static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
+}
+
+inline Mutability operator&(Mutability lhs, Mutability rhs)
+{
+  return static_cast<Mutability>(
+      static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
+}
+
 struct Info
 {
    Type sensorType;
@@ -67,6 +82,7 @@
    Exponent exponentB;
    ScaledOffset scaledOffset;
    std::function<uint8_t(SetSensorReadingReq&, const Info&)> updateFunc;
+   Mutability mutability;
    DbusInterfaceMap propertyInterfaces;
 };