storage metric: add generic implementation

Add the generic implementation for the storage metric, so there is no
need to add a new enum value and new code, every time a new storage
type needs to be added.

Change-Id: Idcd99455ca559eb6274a71613684a99b4b63a6f0
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/health_metric.hpp b/health_metric.hpp
index e79fce1..8d3dee4 100644
--- a/health_metric.hpp
+++ b/health_metric.hpp
@@ -25,6 +25,7 @@
 using BmcIntf = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Bmc;
 using MetricIntf =
     sdbusplus::server::object_t<ValueIntf, ThresholdIntf, AssociationIntf>;
+using MType = phosphor::health::metric::Type;
 
 struct MValue
 {
@@ -42,9 +43,10 @@
     HealthMetric(HealthMetric&&) = delete;
     virtual ~HealthMetric() = default;
 
-    HealthMetric(sdbusplus::bus_t& bus, phosphor::health::metric::Type type,
+    HealthMetric(sdbusplus::bus_t& bus, MType type,
                  const config::HealthMetric& config, const paths_t& bmcPaths) :
-        MetricIntf(bus, getPath(config.subType).c_str(), action::defer_emit),
+        MetricIntf(bus, getPath(type, config.name, config.subType).c_str(),
+                   action::defer_emit),
         bus(bus), type(type), config(config)
     {
         create(bmcPaths);
@@ -64,12 +66,13 @@
                         MValue value);
     /** @brief Check all thresholds for the given value */
     void checkThresholds(MValue value);
-    /** @brief Get the object path for the given subtype */
-    auto getPath(SubType subType) -> std::string;
+    /** @brief Get the object path for the given type, name and subtype */
+    auto getPath(phosphor::health::metric::Type type, std::string name,
+                 SubType subType) -> std::string;
     /** @brief D-Bus bus connection */
     sdbusplus::bus_t& bus;
     /** @brief Metric type */
-    phosphor::health::metric::Type type;
+    MType type;
     /** @brief Metric configuration */
     const config::HealthMetric config;
     /** @brief Window for metric history */