Skip to content

Commit

Permalink
JFactoryGenerators now have a pointer to JApplication
Browse files Browse the repository at this point in the history
This means we can get rid of the extra 'app' argument when declaring OmniFactories and ChainFactories
  • Loading branch information
nathanwbrei committed Nov 21, 2023
1 parent 5ae2275 commit a229aa7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/libraries/JANA/JFactoryGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
#ifndef _JFactoryGenerator_h_
#define _JFactoryGenerator_h_

class JApplication;

class JFactoryGenerator {

std::string m_plugin_name;
JApplication* m_app;

public:

Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/libraries/JANA/Services/JComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a229aa7

Please sign in to comment.