Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 09:43:26

0001 
0002 #include <JANA/JApplication.h>
0003 #include <JANA/Components/JComponentFwd.h>
0004 #include <JANA/Components/JHasInputs.h>
0005 #include <JANA/Components/JHasOutputs.h>
0006 #include <JANA/Services/JWiringService.h>
0007 
0008 
0009 void jana::components::JComponent::Wire(JApplication* app) {
0010     // Prefix is already set (either in the ctor or in a {Factory,EventSource}Generator
0011     // TODO: Support multiple event levels for Fold/Unfold/Source
0012     // TODO: Support short names in wiring file
0013 
0014     m_app = app;
0015 
0016     // Configure logger
0017     m_logger = m_app->GetService<JParameterManager>()->GetLogger(GetLoggerName());
0018 
0019     auto wiring_svc = m_app->GetService<services::JWiringService>();
0020     auto wiring = wiring_svc->GetWiring(m_prefix);
0021 
0022     if (wiring != nullptr) {
0023         wiring->is_used = true;
0024 
0025         if (wiring->action == services::JWiringService::Action::Remove) {
0026             m_is_enabled = false;
0027         }
0028         else {
0029             m_is_enabled = true;
0030             // The user can provide a component which is disabled by default,
0031             // in which case the wiring file is the only way to enable it.
0032         }
0033 
0034         m_level = wiring->level;
0035 
0036         for (auto param : m_parameters) {
0037             param->Wire(wiring->configs, wiring_svc->GetSharedParameters());
0038         }
0039 
0040         if (auto* i = dynamic_cast<JHasInputs*>(this)) {
0041             i->WireInputs(wiring->level, wiring->input_levels, wiring->input_names,
0042                         wiring->variadic_input_levels, wiring->variadic_input_names);
0043         }
0044 
0045         if (auto* o = dynamic_cast<JHasOutputs*>(this)) {
0046             o->WireOutputs(wiring->level, wiring->output_names, wiring->variadic_output_names, false);
0047         }
0048     }
0049 }
0050 
0051 void jana::components::JComponent::DoInit() {
0052     std::lock_guard<std::mutex> lock(m_mutex);
0053 
0054     if (m_is_initialized) return;
0055     for (auto* parameter : m_parameters) {
0056         parameter->Init(*(m_app->GetJParameterManager()), m_prefix);
0057     }
0058     for (auto* service : m_services) {
0059         service->Fetch(m_app);
0060     }
0061     CallWithJExceptionWrapper("Init", [&](){ Init(); });
0062 
0063     // Don't set status until Init() succeeds, so that if an exception gets swallowed
0064     // once it doesn't get accidentally swallowed everywhere
0065     m_is_initialized = true;
0066 }