dbuswrite: Add another write() form to WriteInterface

Adding another form of the write() call,
which takes 3 arguments instead of 1,
providing an alternate interface for caller to use.

A compatibility function is provided,
which simply calls write(), so no API breakage.

The additional arguments to write() allow caller
to force the write to happen even if old value same,
and/or to learn the actual raw value written.

Adding boilerplate to Sensor and PluggableSensor,
to also pass the 3-argument write() through.

Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: Iaf35f674ef9ce38b56017f6cb0f821df6c789649
diff --git a/dbus/dbuswrite.cpp b/dbus/dbuswrite.cpp
index 288cb1a..fce95ae 100644
--- a/dbus/dbuswrite.cpp
+++ b/dbus/dbuswrite.cpp
@@ -54,6 +54,11 @@
 
 void DbusWritePercent::write(double value)
 {
+    return write(value, false, nullptr);
+}
+
+void DbusWritePercent::write(double value, bool force, int64_t* written)
+{
     double minimum = getMin();
     double maximum = getMax();
 
@@ -63,7 +68,14 @@
 
     if (oldValue == static_cast<int64_t>(ovalue))
     {
-        return;
+        if (!force)
+        {
+            if (written)
+            {
+                *written = oldValue;
+            }
+            return;
+        }
     }
     auto writeBus = sdbusplus::bus::new_default();
     auto mesg =
@@ -84,6 +96,10 @@
     }
 
     oldValue = static_cast<int64_t>(ovalue);
+    if (written)
+    {
+        *written = oldValue;
+    }
     return;
 }
 
@@ -108,9 +124,21 @@
 
 void DbusWrite::write(double value)
 {
+    return write(value, false, nullptr);
+}
+
+void DbusWrite::write(double value, bool force, int64_t* written)
+{
     if (oldValue == static_cast<int64_t>(value))
     {
-        return;
+        if (!force)
+        {
+            if (written)
+            {
+                *written = oldValue;
+            }
+            return;
+        }
     }
     auto writeBus = sdbusplus::bus::new_default();
     auto mesg =
@@ -131,6 +159,10 @@
     }
 
     oldValue = static_cast<int64_t>(value);
+    if (written)
+    {
+        *written = oldValue;
+    }
     return;
 }