File indexing completed on 2025-02-22 10:41:08
0001
0002
0003
0004
0005 #pragma once
0006
0007 #include <JANA/JFactorySet.h>
0008 #include <JANA/JFactoryGenerator.h>
0009 #include <JANA/Services/JWiringService.h>
0010
0011
0012 namespace jana::components {
0013
0014 template<class FactoryT>
0015 class JWiredFactoryGeneratorT : public JFactoryGenerator {
0016
0017 public:
0018 using FactoryConfigType = typename FactoryT::ConfigType;
0019
0020 explicit JWiredFactoryGeneratorT() = default;
0021
0022 void GenerateFactories(JFactorySet *factory_set) override {
0023
0024 auto wiring_svc = GetApplication()->template GetService<jana::services::JWiringService>();
0025 const auto& shared_params = wiring_svc->GetSharedParameters();
0026
0027 const auto& type_name = JTypeInfo::demangle<FactoryT>();
0028 for (const auto* wiring : wiring_svc->GetWirings(GetPluginName(), type_name)) {
0029
0030 FactoryT *factory = new FactoryT;
0031 factory->SetApplication(GetApplication());
0032 factory->SetPluginName(this->GetPluginName());
0033 factory->SetTypeName(type_name);
0034
0035
0036
0037 for (auto parameter : factory->GetAllParameters()) {
0038 parameter->Wire(wiring->configs, shared_params);
0039 }
0040
0041
0042 for (auto output_level : wiring->output_levels) {
0043 if (output_level != wiring->level) {
0044 throw JException("JOmniFactories are constrained to a single output level");
0045 }
0046 }
0047
0048 factory->PreInit(wiring->prefix,
0049 wiring->level,
0050 wiring->input_names,
0051 wiring->input_levels,
0052 wiring->output_names);
0053
0054 factory_set->Add(factory);
0055 }
0056 }
0057 };
0058
0059 }
0060 using jana::components::JWiredFactoryGeneratorT;