File indexing completed on 2025-01-18 10:17:33
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& type_name = JTypeInfo::demangle<FactoryT>();
0026 for (const auto* wiring : wiring_svc->GetWirings(GetPluginName(), type_name)) {
0027
0028 FactoryT *factory = new FactoryT;
0029 factory->SetApplication(GetApplication());
0030 factory->SetPluginName(this->GetPluginName());
0031 factory->SetTypeName(type_name);
0032
0033
0034
0035 factory->ConfigureAllParameters(wiring->configs);
0036
0037
0038 for (auto output_level : wiring->output_levels) {
0039 if (output_level != wiring->level) {
0040 throw JException("JOmniFactories are constrained to a single output level");
0041 }
0042 }
0043
0044 factory->PreInit(wiring->prefix,
0045 wiring->level,
0046 wiring->input_names,
0047 wiring->input_levels,
0048 wiring->output_names);
0049
0050 factory_set->Add(factory);
0051 }
0052 }
0053 };
0054
0055 }
0056 using jana::components::JWiredFactoryGeneratorT;