Skip to content

Commit

Permalink
Added after start hook
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobel committed Nov 18, 2024
1 parent b8270e7 commit 1801a8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mtconnect/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 9 additions & 0 deletions src/mtconnect/agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ namespace mtconnect {
/// @brief Hooks to run when before the agent starts all the soures and sinks
/// @return configuration::HookManager<Agent>&
auto &beforeStartHooks() { return m_beforeStartHooks; }

/// @brief Hooks to run when after the agent starts all the soures and sinks
/// @return configuration::HookManager<Agent>&
auto &afterStartHooks() { return m_afterStartHooks; }

/// @brief Hooks before the agent stops all the sources and sinks
/// @return configuration::HookManager<Agent>&
Expand Down Expand Up @@ -546,6 +550,7 @@ namespace mtconnect {
configuration::HookManager<Agent> m_beforeInitializeHooks;
configuration::HookManager<Agent> m_afterInitializeHooks;
configuration::HookManager<Agent> m_beforeStartHooks;
configuration::HookManager<Agent> m_afterStartHooks;
configuration::HookManager<Agent> m_beforeStopHooks;
configuration::HookManager<Agent> m_beforeDeviceXmlUpdateHooks;
configuration::HookManager<Agent> m_afterDeviceXmlUpdateHooks;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/mtconnect/sink/sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace mtconnect {
enum HookType {
BEFORE_STOP,
BEFORE_START,
AFTER_START,
BEFORE_DEVICE_XML_UPDATE,
AFTER_DEVICE_XML_UPDATE,
BEFORE_INITIALIZE,
Expand Down

0 comments on commit 1801a8f

Please sign in to comment.