Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:36:42

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     bool use_short_names = wiring_svc->AreShortNamesUsed();
0022 
0023     if (wiring != nullptr) {
0024         wiring->is_used = true;
0025 
0026         if (wiring->action == services::JWiringService::Action::Remove) {
0027             m_is_enabled = false;
0028         }
0029         else {
0030             m_is_enabled = true;
0031             // The user can provide a component which is disabled by default,
0032             // in which case the wiring file is the only way to enable it.
0033         }
0034 
0035         m_level = wiring->level;
0036 
0037         for (auto param : m_parameters) {
0038             param->Wire(wiring->configs, wiring_svc->GetSharedParameters());
0039         }
0040 
0041         if (auto* i = dynamic_cast<JHasInputs*>(this)) {
0042             i->WireInputs(wiring->level, wiring->input_levels, wiring->input_names,
0043                         wiring->variadic_input_levels, wiring->variadic_input_names);
0044         }
0045 
0046         if (auto* o = dynamic_cast<JHasOutputs*>(this)) {
0047             o->WireOutputs(wiring->level, wiring->output_names, wiring->variadic_output_names, use_short_names);
0048         }
0049     }
0050 }
0051 
0052 void jana::components::JComponent::DoInit() {
0053     std::lock_guard<std::mutex> lock(m_mutex);
0054 
0055     if (m_is_initialized) return;
0056     for (auto* parameter : m_parameters) {
0057         parameter->Init(*(m_app->GetJParameterManager()), m_prefix);
0058     }
0059     for (auto* service : m_services) {
0060         service->Fetch(m_app);
0061     }
0062     CallWithJExceptionWrapper("Init", [&](){ Init(); });
0063 
0064     // Don't set status until Init() succeeds, so that if an exception gets swallowed
0065     // once it doesn't get accidentally swallowed everywhere
0066     m_is_initialized = true;
0067 }