Break out dbus telemetry watcher

EventServiceManager is too large.  Make it smaller by breaking out the
dbus log watching mechanisims into a class.

No changes are made, with the exception of the addition of
sendTelemetryReportToSubs to allow sending events from outside the
class, without needing the subscription list, which should be private.

Tested: On last patch in series.

Change-Id: Idf17886971ddff5dddeabeeb6ae44e733063b909
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/meson.build b/meson.build
index 6fa3aa5..cc08869 100644
--- a/meson.build
+++ b/meson.build
@@ -341,6 +341,7 @@
 
 srcfiles_bmcweb = files(
     'http/mutual_tls.cpp',
+    'redfish-core/src/dbus_log_watcher.cpp',
     'redfish-core/src/error_messages.cpp',
     'redfish-core/src/event_log.cpp',
     'redfish-core/src/filesystem_log_watcher.cpp',
diff --git a/redfish-core/include/dbus_log_watcher.hpp b/redfish-core/include/dbus_log_watcher.hpp
new file mode 100644
index 0000000..86e4a9d
--- /dev/null
+++ b/redfish-core/include/dbus_log_watcher.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <sdbusplus/message.hpp>
+namespace redfish
+{
+
+void getReadingsForReport(sdbusplus::message_t& msg);
+
+} // namespace redfish
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index a0d70a7..f3fb11c 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -14,6 +14,7 @@
 limitations under the License.
 */
 #pragma once
+#include "dbus_log_watcher.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "event_log.hpp"
@@ -541,6 +542,17 @@
         return true;
     }
 
+    static void sendTelemetryReportToSubs(
+        const std::string& reportId, const telemetry::TimestampReadings& var)
+    {
+        for (const auto& it :
+             EventServiceManager::getInstance().subscriptionsMap)
+        {
+            Subscription& entry = *it.second;
+            entry.filterAndSendReports(reportId, var);
+        }
+    }
+
     void sendEvent(nlohmann::json::object_t eventMessage,
                    std::string_view origin, std::string_view resourceType)
     {
@@ -687,55 +699,6 @@
         }
     }
 
-    static void getReadingsForReport(sdbusplus::message_t& msg)
-    {
-        if (msg.is_method_error())
-        {
-            BMCWEB_LOG_ERROR("TelemetryMonitor Signal error");
-            return;
-        }
-
-        sdbusplus::message::object_path path(msg.get_path());
-        std::string id = path.filename();
-        if (id.empty())
-        {
-            BMCWEB_LOG_ERROR("Failed to get Id from path");
-            return;
-        }
-
-        std::string interface;
-        dbus::utility::DBusPropertiesMap props;
-        std::vector<std::string> invalidProps;
-        msg.read(interface, props, invalidProps);
-
-        auto found = std::ranges::find_if(props, [](const auto& x) {
-            return x.first == "Readings";
-        });
-        if (found == props.end())
-        {
-            BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
-            return;
-        }
-
-        const telemetry::TimestampReadings* readings =
-            std::get_if<telemetry::TimestampReadings>(&found->second);
-        if (readings == nullptr)
-        {
-            BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
-            return;
-        }
-
-        for (const auto& it :
-             EventServiceManager::getInstance().subscriptionsMap)
-        {
-            Subscription& entry = *it.second;
-            if (entry.userSub->eventFormatType == metricReportFormatType)
-            {
-                entry.filterAndSendReports(id, *readings);
-            }
-        }
-    }
-
     void unregisterMetricReportSignal()
     {
         if (matchTelemetryMonitor)
diff --git a/redfish-core/src/dbus_log_watcher.cpp b/redfish-core/src/dbus_log_watcher.cpp
new file mode 100644
index 0000000..77f1f02
--- /dev/null
+++ b/redfish-core/src/dbus_log_watcher.cpp
@@ -0,0 +1,57 @@
+#include "dbus_log_watcher.hpp"
+
+#include "dbus_utility.hpp"
+#include "event_service_manager.hpp"
+#include "logging.hpp"
+#include "metric_report.hpp"
+
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/message/native_types.hpp>
+
+#include <algorithm>
+#include <string>
+#include <variant>
+#include <vector>
+
+namespace redfish
+{
+void getReadingsForReport(sdbusplus::message_t& msg)
+{
+    if (msg.is_method_error())
+    {
+        BMCWEB_LOG_ERROR("TelemetryMonitor Signal error");
+        return;
+    }
+
+    sdbusplus::message::object_path path(msg.get_path());
+    std::string id = path.filename();
+    if (id.empty())
+    {
+        BMCWEB_LOG_ERROR("Failed to get Id from path");
+        return;
+    }
+
+    std::string interface;
+    dbus::utility::DBusPropertiesMap props;
+    std::vector<std::string> invalidProps;
+    msg.read(interface, props, invalidProps);
+
+    auto found = std::ranges::find_if(props, [](const auto& x) {
+        return x.first == "Readings";
+    });
+    if (found == props.end())
+    {
+        BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
+        return;
+    }
+
+    const telemetry::TimestampReadings* readings =
+        std::get_if<telemetry::TimestampReadings>(&found->second);
+    if (readings == nullptr)
+    {
+        BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
+        return;
+    }
+    EventServiceManager::sendTelemetryReportToSubs(id, *readings);
+}
+} // namespace redfish