-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa0d852
commit f4a5bd5
Showing
3 changed files
with
97 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2025, Jefferson Science Associates, LLC. | ||
// Subject to the terms in the LICENSE file found in the top-level directory. | ||
// Created by Nathan Brei | ||
|
||
#pragma once | ||
|
||
#include <JANA/JFactorySet.h> | ||
#include <JANA/JFactoryGenerator.h> | ||
#include <JANA/Services/JWiringService.h> | ||
|
||
|
||
namespace jana::components { | ||
|
||
template<class FactoryT> | ||
class JWiredFactoryGeneratorT : public JFactoryGenerator { | ||
|
||
public: | ||
using FactoryConfigType = typename FactoryT::ConfigType; | ||
|
||
explicit JWiredFactoryGeneratorT() = default; | ||
|
||
void GenerateFactories(JFactorySet *factory_set) override { | ||
|
||
auto wiring_svc = GetApplication()->template GetService<jana::services::JWiringService>(); | ||
const auto& type_name = JTypeInfo::demangle<FactoryT>(); | ||
for (const auto* wiring : wiring_svc->GetWirings(GetPluginName(), type_name)) { | ||
|
||
FactoryT *factory = new FactoryT; | ||
factory->SetApplication(GetApplication()); | ||
factory->SetPluginName(this->GetPluginName()); | ||
factory->SetTypeName(type_name); | ||
|
||
// Set the parameter values on the factory. This way, the values in the wiring file | ||
// show up as "defaults" and the values set on the command line show up as "overrides". | ||
factory->ConfigureAllParameters(wiring->configs); | ||
|
||
// Check that output levels in wiring file match the factory's level | ||
for (auto output_level : wiring->output_levels) { | ||
if (output_level != wiring->level) { | ||
throw JException("JOmniFactories are constrained to a single output level"); | ||
} | ||
} | ||
|
||
factory->PreInit(wiring->prefix, | ||
wiring->level, | ||
wiring->input_names, | ||
wiring->input_levels, | ||
wiring->output_names); | ||
|
||
factory_set->Add(factory); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace jana::components | ||
using jana::components::JWiredFactoryGeneratorT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters