From 1801a8f1a082a7502e46c396ec71ee08d881e5bd Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 18 Nov 2024 13:25:46 -0500 Subject: [PATCH] Added after start hook --- src/mtconnect/agent.cpp | 2 ++ src/mtconnect/agent.hpp | 9 +++++++++ src/mtconnect/sink/sink.hpp | 1 + 3 files changed, 12 insertions(+) diff --git a/src/mtconnect/agent.cpp b/src/mtconnect/agent.cpp index d350f92c..a14c15cb 100644 --- a/src/mtconnect/agent.cpp +++ b/src/mtconnect/agent.cpp @@ -232,6 +232,8 @@ namespace mtconnect { // Start all the sources for (auto source : m_sources) source->start(); + + m_afterStartHooks.exec(*this); } catch (std::runtime_error &e) { diff --git a/src/mtconnect/agent.hpp b/src/mtconnect/agent.hpp index 76dc4f90..9179c8ce 100644 --- a/src/mtconnect/agent.hpp +++ b/src/mtconnect/agent.hpp @@ -112,6 +112,10 @@ namespace mtconnect { /// @brief Hooks to run when before the agent starts all the soures and sinks /// @return configuration::HookManager& auto &beforeStartHooks() { return m_beforeStartHooks; } + + /// @brief Hooks to run when after the agent starts all the soures and sinks + /// @return configuration::HookManager& + auto &afterStartHooks() { return m_afterStartHooks; } /// @brief Hooks before the agent stops all the sources and sinks /// @return configuration::HookManager& @@ -546,6 +550,7 @@ namespace mtconnect { configuration::HookManager m_beforeInitializeHooks; configuration::HookManager m_afterInitializeHooks; configuration::HookManager m_beforeStartHooks; + configuration::HookManager m_afterStartHooks; configuration::HookManager m_beforeStopHooks; configuration::HookManager m_beforeDeviceXmlUpdateHooks; configuration::HookManager m_afterDeviceXmlUpdateHooks; @@ -665,6 +670,10 @@ namespace mtconnect { return m_agent->beforeStartHooks(); break; + case AFTER_START: + return m_agent->afterStartHooks(); + break; + case BEFORE_STOP: return m_agent->beforeStopHooks(); break; diff --git a/src/mtconnect/sink/sink.hpp b/src/mtconnect/sink/sink.hpp index 16de18c5..14d38e1f 100644 --- a/src/mtconnect/sink/sink.hpp +++ b/src/mtconnect/sink/sink.hpp @@ -58,6 +58,7 @@ namespace mtconnect { enum HookType { BEFORE_STOP, BEFORE_START, + AFTER_START, BEFORE_DEVICE_XML_UPDATE, AFTER_DEVICE_XML_UPDATE, BEFORE_INITIALIZE,