Skip to content

Commit

Permalink
Move Autoactivator from JApplication to JComponentManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Apr 15, 2024
1 parent 6f60aae commit b862bd6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/libraries/JANA/JApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <JANA/Services/JGlobalRootLock.h>
#include <JANA/Engine/JArrowProcessingController.h>
#include <JANA/Utils/JCpuInfo.h>
#include <JANA/Utils/JAutoActivator.h>
#include <JANA/Engine/JTopologyBuilder.h>

JApplication *japp = nullptr;
Expand Down Expand Up @@ -122,14 +121,14 @@ void JApplication::Initialize() {
// Obtain final values of parameters and loggers
m_plugin_loader->InitPhase2();
m_component_manager->InitPhase2();
m_logger = m_service_locator->get<JLoggingService>()->get_logger("JApplication");
m_logger.show_classname = false;

// Attach all plugins
m_plugin_loader->attach_plugins(m_component_manager.get());

// Look for factories to auto-activate
if (JAutoActivator::IsRequested(m_params)) {
m_component_manager->add(new JAutoActivator);
}
// Resolve all event sources now that all plugins have been loaded
m_component_manager->resolve_event_sources();

// Set desired nthreads. We parse the 'nthreads' parameter two different ways for backwards compatibility.
m_desired_nthreads = 1;
Expand All @@ -141,7 +140,6 @@ void JApplication::Initialize() {
m_params->SetDefaultParameter("jana:ticker_interval", m_ticker_interval_ms, "Controls the ticker interval (in ms)");
m_params->SetDefaultParameter("jana:extended_report", m_extended_report, "Controls whether the ticker shows simple vs detailed performance metrics");

m_component_manager->resolve_event_sources();

/*
int engine_choice = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/JANA/JApplicationFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>
#include <atomic>
#include <memory>
#include <chrono>

class JEventProcessor;
class JEventSource;
Expand Down
1 change: 1 addition & 0 deletions src/libraries/JANA/Omni/JComponentFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class JParameterManager;
#include <JANA/Utils/JEventLevel.h>
#include <JANA/JLogger.h>
#include <JANA/JException.h>
#include <vector>

namespace jana {
namespace omni {
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/JANA/Services/JComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <JANA/JEventProcessor.h>
#include <JANA/JFactoryGenerator.h>
#include <JANA/JEventUnfolder.h>
#include <JANA/Utils/JAutoActivator.h>

JComponentManager::JComponentManager() {}

Expand Down Expand Up @@ -38,6 +39,12 @@ void JComponentManager::InitPhase2() {
m_params().SetDefaultParameter("jana:nevents", m_nevents, "Max number of events that sources can emit");
m_params().SetDefaultParameter("jana:nskip", m_nskip, "Number of events that sources should skip before starting emitting");
m_params().FilterParameters(m_default_tags, "DEFTAG:");

// Look for factories to auto-activate
// Right now AutoActivator parameter won't show up in parameters list. Reconsider this.
if (JAutoActivator::IsRequested(m_params())) {
add(new JAutoActivator);
}
}

void JComponentManager::next_plugin(std::string plugin_name) {
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/JANA/Utils/JAutoActivator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ JAutoActivator::JAutoActivator() {
SetTypeName("JAutoActivator");
}

bool JAutoActivator::IsRequested(std::shared_ptr <JParameterManager> params) {
return params->Exists("autoactivate") && (!params->GetParameterValue<string>("autoactivate").empty());
bool JAutoActivator::IsRequested(JParameterManager& params) {
return params.Exists("autoactivate") && (!params.GetParameterValue<string>("autoactivate").empty());
}

void JAutoActivator::AddAutoActivatedFactory(string factory_name, string factory_tag) {
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/JANA/Utils/JAutoActivator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class JAutoActivator : public JEventProcessor {

public:
JAutoActivator();
static bool IsRequested(std::shared_ptr<JParameterManager> params);
static bool IsRequested(JParameterManager& params);
static std::pair<std::string, std::string> Split(std::string factory_name);
void AddAutoActivatedFactory(string factory_name, string factory_tag);
void Init() override;
Expand Down

0 comments on commit b862bd6

Please sign in to comment.