regulators: Add hardware presence service

The regulators application needs to determine whether hardware is
present or absent.  Some voltage regulators are optional, and
configuration should only be performed if the regulator is present.

Add a new class to obtain hardware presence data from the D-Bus
xyz.openbmc_project.Inventory.Item interface.

Also define an abstract base class and a mock implementation to enable
use of gmock in test cases related to hardware presence.

Tested:
* Tested where inventory path is present
* Tested where inventory path is not present
* Tested where inventory path is invalid and results in an exception
* Verified that mock implementation could be used in a gmock test case
* Full test plan available at
  https://gist.github.com/smccarney/2b6ea6ecbbeaf5a8b1793e2321799972

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ia25a92815efc506c3ef4ac72844c17120c4ce9b7
diff --git a/phosphor-regulators/src/services.hpp b/phosphor-regulators/src/services.hpp
index 1e38e7c..8d6fc0d 100644
--- a/phosphor-regulators/src/services.hpp
+++ b/phosphor-regulators/src/services.hpp
@@ -17,6 +17,7 @@
 
 #include "error_logging.hpp"
 #include "journal.hpp"
+#include "presence_service.hpp"
 
 #include <sdbusplus/bus.hpp>
 
@@ -63,6 +64,13 @@
      * @return journal interface
      */
     virtual Journal& getJournal() = 0;
+
+    /**
+     * Returns the interface to hardware presence data.
+     *
+     * @return hardware presence interface
+     */
+    virtual PresenceService& getPresenceService() = 0;
 };
 
 /**
@@ -86,7 +94,8 @@
      *
      * @param bus D-Bus bus object
      */
-    explicit BMCServices(sdbusplus::bus::bus& bus) : bus{bus}, errorLogging{bus}
+    explicit BMCServices(sdbusplus::bus::bus& bus) :
+        bus{bus}, errorLogging{bus}, presenceService{bus}
     {
     }
 
@@ -108,6 +117,12 @@
         return journal;
     }
 
+    /** @copydoc Services::getPresenceService() */
+    virtual PresenceService& getPresenceService() override
+    {
+        return presenceService;
+    }
+
   private:
     /**
      * D-Bus bus object.
@@ -124,6 +139,11 @@
      * journal.
      */
     SystemdJournal journal{};
+
+    /**
+     * Implementation of the PresenceService interface using D-Bus method calls.
+     */
+    DBusPresenceService presenceService;
 };
 
 } // namespace phosphor::power::regulators