sensors: Align source structure away from anti-patterns

The anti-patterns document comments on source structure, specifically
on placing internal headers in a parallel subtree[1]. dbus-sensors is an
example of violating this anti-pattern, so fix it.

[1]: https://github.com/openbmc/docs/blob/master/anti-patterns.md#placing-internal-headers-in-a-parallel-subtree

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I50ecaddd53fa9c9b7a0441af9de5e60bd94e47c6
diff --git a/src/DeviceMgmt.hpp b/src/DeviceMgmt.hpp
new file mode 100644
index 0000000..07b28b5
--- /dev/null
+++ b/src/DeviceMgmt.hpp
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "Utils.hpp"
+
+#include <boost/container/flat_map.hpp>
+
+#include <functional>
+#include <optional>
+#include <string_view>
+
+struct I2CDeviceType
+{
+    const char* name;
+    bool createsHWMon;
+};
+
+using I2CDeviceTypeMap =
+    boost::container::flat_map<std::string, I2CDeviceType, std::less<>>;
+
+struct I2CDeviceParams
+{
+    I2CDeviceParams(const I2CDeviceType& type, uint64_t bus, uint64_t address) :
+        type(&type), bus(bus), address(address){};
+
+    const I2CDeviceType* type;
+    uint64_t bus;
+    uint64_t address;
+
+    bool devicePresent(void) const;
+    bool deviceStatic(void) const;
+};
+
+std::optional<I2CDeviceParams>
+    getI2CDeviceParams(const I2CDeviceTypeMap& dtmap,
+                       const SensorBaseConfigMap& cfg);
+
+class I2CDevice
+{
+  public:
+    explicit I2CDevice(I2CDeviceParams params);
+    ~I2CDevice();
+
+  private:
+    I2CDeviceParams params;
+
+    int create(void) const;
+    int destroy(void) const;
+};
+
+// HACK: this declaration "should" live in Utils.hpp, but that leads to a
+// tangle of header-dependency hell because each header needs types declared
+// in the other.
+std::vector<std::unique_ptr<sdbusplus::bus::match_t>>
+    setupPropertiesChangedMatches(
+        sdbusplus::asio::connection& bus, const I2CDeviceTypeMap& typeMap,
+        const std::function<void(sdbusplus::message_t&)>& handler);