@@ -20,13 +20,16 @@ struct JHasInputs {
20
20
21
21
std::vector<InputBase*> m_inputs;
22
22
std::vector<VariadicInputBase*> m_variadic_inputs;
23
+ std::vector<std::pair<InputBase*, VariadicInputBase*>> m_ordered_inputs;
23
24
24
25
void RegisterInput (InputBase* input) {
25
26
m_inputs.push_back (input);
27
+ m_ordered_inputs.push_back ({input, nullptr });
26
28
}
27
29
28
30
void RegisterInput (VariadicInputBase* input) {
29
31
m_variadic_inputs.push_back (input);
32
+ m_ordered_inputs.push_back ({nullptr , input});
30
33
}
31
34
32
35
struct InputOptions {
@@ -465,6 +468,11 @@ struct JHasInputs {
465
468
const std::vector<JEventLevel>& variadic_input_levels,
466
469
const std::vector<std::vector<std::string>>& variadic_input_databundle_names) {
467
470
471
+ if (m_variadic_inputs.size () == 1 && variadic_input_databundle_names.size () == 0 ) {
472
+ WireInputsCompatibility (component_level, single_input_levels, single_input_databundle_names);
473
+ return ;
474
+ }
475
+
468
476
// Validate that we have the correct number of input databundle names
469
477
if (single_input_databundle_names.size () != m_inputs.size ()) {
470
478
throw JException (" Wrong number of (nonvariadic) input databundle names! Expected %d, found %d" , m_inputs.size (), single_input_databundle_names.size ());
@@ -499,6 +507,45 @@ struct JHasInputs {
499
507
}
500
508
}
501
509
510
+ void WireInputsCompatibility (JEventLevel component_level,
511
+ const std::vector<JEventLevel>& single_input_levels,
512
+ const std::vector<std::string>& single_input_databundle_names) {
513
+
514
+ // Figure out how many collection names belong to the variadic input
515
+ int variadic_databundle_count = single_input_databundle_names.size () - m_inputs.size ();
516
+ int databundle_name_index = 0 ;
517
+ int databundle_level_index = 0 ;
518
+
519
+ for (auto & [single_input, variadic_input] : m_ordered_inputs) {
520
+ if (single_input != nullptr ) {
521
+ single_input->SetDatabundleName (single_input_databundle_names.at (databundle_name_index));
522
+ if (single_input_levels.empty ()) {
523
+ single_input->SetLevel (component_level);
524
+ }
525
+ else {
526
+ single_input->SetLevel (single_input_levels.at (databundle_level_index));
527
+ }
528
+ databundle_name_index += 1 ;
529
+ databundle_level_index += 1 ;
530
+ }
531
+ else {
532
+ std::vector<std::string> variadic_databundle_names;
533
+ for (int i=0 ; i<variadic_databundle_count; ++i) {
534
+ variadic_databundle_names.push_back (single_input_databundle_names.at (databundle_name_index+i));
535
+ }
536
+ variadic_input->SetRequestedDatabundleNames (variadic_databundle_names);
537
+ if (single_input_levels.empty ()) {
538
+ variadic_input->SetLevel (component_level);
539
+ }
540
+ else {
541
+ variadic_input->SetLevel (single_input_levels.at (databundle_level_index)); // Last one wins!
542
+ }
543
+ databundle_name_index += variadic_databundle_count;
544
+ databundle_level_index += 1 ;
545
+ }
546
+ }
547
+ }
548
+
502
549
void SummarizeInputs (JComponentSummary::Component& summary) const {
503
550
for (const auto * input : m_inputs) {
504
551
summary.AddInput (new JComponentSummary::Collection (" " , input->GetDatabundleName (), input->GetTypeName (), input->GetLevel ()));
0 commit comments