Skip to content

Commit

Permalink
Use -> operator to access omni-style Services
Browse files Browse the repository at this point in the history
Symmetric with having a shared_ptr from GetService<>
  • Loading branch information
nathanwbrei committed Apr 18, 2024
1 parent 2775120 commit b6601e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/libraries/JANA/Omni/JComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class JComponent::Service : public JComponent::ServiceBase {
return *m_data;
}

ServiceT& operator->() {
ServiceT* operator->() {
if (m_data == nullptr) {
throw JException("Attempted to access a Service which hasn't been attached to this Component yet!");
}
return *m_data;
return m_data.get();
}

protected:
Expand Down
20 changes: 10 additions & 10 deletions src/libraries/JANA/Services/JComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ JComponentManager::~JComponentManager() {

void JComponentManager::Init() {

m_params().SetDefaultParameter("event_source_type", m_user_evt_src_typename, "Manually specifies which JEventSource should open the input file");
m_params().SetDefaultParameter("record_call_stack", m_enable_call_graph_recording, "Records a trace of who called each factory. Reduces performance but necessary for plugins such as janadot.");
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:");
m_params->SetDefaultParameter("event_source_type", m_user_evt_src_typename, "Manually specifies which JEventSource should open the input file");
m_params->SetDefaultParameter("record_call_stack", m_enable_call_graph_recording, "Records a trace of who called each factory. Reduces performance but necessary for plugins such as janadot.");
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.
Expand All @@ -48,23 +48,23 @@ void JComponentManager::Init() {
void JComponentManager::configure_components() {
for (auto* src : m_evt_srces) {
src->SetApplication(GetApplication());
src->SetLogger(m_logging().get_logger(src->GetLoggerName()));
src->SetLogger(m_logging->get_logger(src->GetLoggerName()));
}
for (auto* proc : m_evt_procs) {
proc->SetApplication(GetApplication());
proc->SetLogger(m_logging().get_logger(proc->GetLoggerName()));
proc->SetLogger(m_logging->get_logger(proc->GetLoggerName()));
}
for (auto* fac_gen : m_fac_gens) {
fac_gen->SetApplication(GetApplication());
//fac_gen->SetLogger(m_logging().get_logger(fac_gen->GetLoggerName()));
//fac_gen->SetLogger(m_logging->get_logger(fac_gen->GetLoggerName()));
}
for (auto* src_gen : m_src_gens) {
src_gen->SetJApplication(GetApplication());
//src_gen->SetLogger(m_logging().get_logger(src_gen->GetLoggerName()));
//src_gen->SetLogger(m_logging->get_logger(src_gen->GetLoggerName()));
}
for (auto* unfolder : m_unfolders) {
unfolder->SetApplication(GetApplication());
unfolder->SetLogger(m_logging().get_logger(unfolder->GetLoggerName()));
unfolder->SetLogger(m_logging->get_logger(unfolder->GetLoggerName()));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/libraries/JANA/Services/JPluginLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class JApplication;

void JPluginLoader::Init() {

m_params().SetDefaultParameter("plugins", m_plugins_to_include, "Comma-separated list of plugins to load.");
m_params().SetDefaultParameter("plugins_to_ignore", m_plugins_to_exclude, "Comma-separated list of plugins to NOT load, even if they are specified in 'plugins'.");
m_params().SetDefaultParameter("jana:plugin_path", m_plugin_paths_str, "Colon-separated list of paths to search for plugins");
m_params().SetDefaultParameter("jana:debug_plugin_loading", m_verbose, "Trace the plugin search path and display any loading errors");
m_params->SetDefaultParameter("plugins", m_plugins_to_include, "Comma-separated list of plugins to load.");
m_params->SetDefaultParameter("plugins_to_ignore", m_plugins_to_exclude, "Comma-separated list of plugins to NOT load, even if they are specified in 'plugins'.");
m_params->SetDefaultParameter("jana:plugin_path", m_plugin_paths_str, "Colon-separated list of paths to search for plugins");
m_params->SetDefaultParameter("jana:debug_plugin_loading", m_verbose, "Trace the plugin search path and display any loading errors");

if (m_verbose) {
// The jana:debug_plugin_loading parameter is kept around for backwards compatibility
Expand Down
2 changes: 1 addition & 1 deletion src/programs/unit_tests/JServiceLocatorTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct OmniService : public JService {

void Init() override {
LOG_INFO(GetLogger()) << "Calling OmniService::Init" << LOG_END;
REQUIRE(parman().GetParameterValue<int>("bucket_count") == 22);
REQUIRE(parman->GetParameterValue<int>("bucket_count") == 22);
REQUIRE(bucket_count() == 22);
}
};
Expand Down

0 comments on commit b6601e4

Please sign in to comment.