From a229aa7f13febbc591ba4b907365a329102caf77 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 21 Nov 2023 14:15:18 -0500 Subject: [PATCH] JFactoryGenerators now have a pointer to JApplication This means we can get rid of the extra 'app' argument when declaring OmniFactories and ChainFactories --- src/libraries/JANA/JFactoryGenerator.h | 11 +++++++++++ src/libraries/JANA/Services/JComponentManager.cc | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libraries/JANA/JFactoryGenerator.h b/src/libraries/JANA/JFactoryGenerator.h index c5fb9c267..739465681 100644 --- a/src/libraries/JANA/JFactoryGenerator.h +++ b/src/libraries/JANA/JFactoryGenerator.h @@ -9,9 +9,12 @@ #ifndef _JFactoryGenerator_h_ #define _JFactoryGenerator_h_ +class JApplication; + class JFactoryGenerator { std::string m_plugin_name; + JApplication* m_app; public: @@ -26,6 +29,14 @@ class JFactoryGenerator { inline void SetPluginName(std::string plugin_name) { m_plugin_name = std::move(plugin_name); } + + inline void SetApplication(JApplication* app) { + m_app = app; + } + + inline JApplication* GetApplication() { + return m_app; + } }; /// JFactoryGeneratorT works for both JFactories and JMultifactories diff --git a/src/libraries/JANA/Services/JComponentManager.cc b/src/libraries/JANA/Services/JComponentManager.cc index ea8ab15d7..e57fdacb3 100644 --- a/src/libraries/JANA/Services/JComponentManager.cc +++ b/src/libraries/JANA/Services/JComponentManager.cc @@ -43,6 +43,7 @@ void JComponentManager::add(JEventSourceGenerator *source_generator) { void JComponentManager::add(JFactoryGenerator *factory_generator) { factory_generator->SetPluginName(m_current_plugin_name); + factory_generator->SetApplication(m_app); m_fac_gens.push_back(factory_generator); } @@ -52,7 +53,9 @@ void JComponentManager::add(JEventSource *event_source) { m_evt_srces.push_back(event_source); auto fac_gen = event_source->GetFactoryGenerator(); if (fac_gen != nullptr) { - m_fac_gens.push_back(event_source->GetFactoryGenerator()); + fac_gen->SetPluginName(m_current_plugin_name); + fac_gen->SetApplication(m_app); + m_fac_gens.push_back(fac_gen); } } @@ -94,6 +97,8 @@ void JComponentManager::resolve_event_sources() { source->SetApplication(m_app); auto fac_gen = source->GetFactoryGenerator(); if (fac_gen != nullptr) { + fac_gen->SetPluginName(m_current_plugin_name); + fac_gen->SetApplication(m_app); m_fac_gens.push_back(fac_gen); } m_evt_srces.push_back(source);