@@ -51,6 +51,7 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
5151 IN_INPUT_DESCRIPTION,
5252 IN_INPUT_SUBSPEC,
5353 IN_INPUT_LIFETIME,
54+ IN_INPUT_OPTIONS,
5455 IN_OUTPUT,
5556 IN_OUTPUT_BINDING,
5657 IN_OUTPUT_ORIGIN,
@@ -135,6 +136,9 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
135136 case State::IN_INPUT_LIFETIME:
136137 s << " IN_INPUT_LIFETIME" ;
137138 break ;
139+ case State::IN_INPUT_OPTIONS:
140+ s << " IN_INPUT_OPTIONS" ;
141+ break ;
138142 case State::IN_OUTPUT:
139143 s << " IN_OUTPUT" ;
140144 break ;
@@ -202,7 +206,7 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
202206 WorkflowImporter (std::vector<DataProcessorSpec>& o,
203207 std::vector<DataProcessorInfo>& m)
204208 : states{},
205- output {o},
209+ dataProcessors {o},
206210 metadata{m}
207211 {
208212 push (State::IN_START);
@@ -215,9 +219,9 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
215219 push (State::IN_EXECUTION);
216220 } else if (in (State::IN_DATAPROCESSORS)) {
217221 push (State::IN_DATAPROCESSOR);
218- output .push_back (DataProcessorSpec{});
222+ dataProcessors .push_back (DataProcessorSpec{});
219223 } else if (in (State::IN_DATAPROCESSOR)) {
220- output .push_back (DataProcessorSpec{});
224+ dataProcessors .push_back (DataProcessorSpec{});
221225 } else if (in (State::IN_INPUTS)) {
222226 push (State::IN_INPUT);
223227 inputHasSubSpec = false ;
@@ -242,16 +246,17 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
242246 enter (" END_OBJECT" );
243247 if (in (State::IN_INPUT)) {
244248 if (inputHasSubSpec) {
245- output .back ().inputs .push_back (InputSpec (binding, origin, description, subspec, lifetime));
249+ dataProcessors .back ().inputs .push_back (InputSpec (binding, origin, description, subspec, lifetime, inputOptions ));
246250 } else {
247- output .back ().inputs .push_back (InputSpec (binding, {origin, description}, lifetime));
251+ dataProcessors .back ().inputs .push_back (InputSpec (binding, {origin, description}, lifetime, inputOptions ));
248252 }
253+ inputOptions.clear ();
249254 inputHasSubSpec = false ;
250255 } else if (in (State::IN_OUTPUT)) {
251256 if (outputHasSubSpec) {
252- output .back ().outputs .push_back (OutputSpec ({binding}, origin, description, subspec, lifetime));
257+ dataProcessors .back ().outputs .push_back (OutputSpec ({binding}, origin, description, subspec, lifetime));
253258 } else {
254- output .back ().outputs .push_back (OutputSpec ({binding}, {origin, description}, lifetime));
259+ dataProcessors .back ().outputs .push_back (OutputSpec ({binding}, {origin, description}, lifetime));
255260 }
256261 outputHasSubSpec = false ;
257262 } else if (in (State::IN_OPTION)) {
@@ -282,9 +287,11 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
282287 }
283288 // Depending on the previous state, push options to the right place.
284289 if (previousIs (State::IN_OPTIONS)) {
285- output .back ().options .push_back (*opt);
290+ dataProcessors .back ().options .push_back (*opt);
286291 } else if (previousIs (State::IN_WORKFLOW_OPTIONS)) {
287292 metadata.back ().workflowOptions .push_back (*opt);
293+ } else if (previousIs (State::IN_INPUT_OPTIONS)) {
294+ inputOptions.push_back (*opt);
288295 } else {
289296 assert (false );
290297 }
@@ -301,6 +308,8 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
301308 } else if (in (State::IN_INPUTS)) {
302309 push (State::IN_INPUT);
303310 inputHasSubSpec = false ;
311+ } else if (in (State::IN_INPUT_OPTIONS)) {
312+ push (State::IN_OPTION);
304313 } else if (in (State::IN_OUTPUTS)) {
305314 push (State::IN_OUTPUT);
306315 outputHasSubSpec = false ;
@@ -345,6 +354,8 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
345354 inputHasSubSpec = true ;
346355 } else if (in (State::IN_INPUT) && strncmp (str, " lifetime" , length) == 0 ) {
347356 push (State::IN_INPUT_LIFETIME);
357+ } else if (in (State::IN_INPUT) && strncmp (str, " metadata" , length) == 0 ) {
358+ push (State::IN_INPUT_OPTIONS);
348359 } else if (in (State::IN_OUTPUT) && strncmp (str, " binding" , length) == 0 ) {
349360 push (State::IN_OUTPUT_BINDING);
350361 } else if (in (State::IN_OUTPUT) && strncmp (str, " origin" , length) == 0 ) {
@@ -404,8 +415,8 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
404415 enter (str);
405416 auto s = std::string (str, length);
406417 if (in (State::IN_DATAPROCESSOR_NAME)) {
407- assert (output .size ());
408- output .back ().name = s;
418+ assert (dataProcessors .size ());
419+ dataProcessors .back ().name = s;
409420 } else if (in (State::IN_METADATUM_NAME)) {
410421 assert (metadata.size ());
411422 metadata.back ().name = s;
@@ -459,13 +470,13 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
459470 } else if (in (State::IN_OUTPUT_LIFETIME)) {
460471 lifetime = (Lifetime)i;
461472 } else if (in (State::IN_DATAPROCESSOR_RANK)) {
462- output .back ().rank = i;
473+ dataProcessors .back ().rank = i;
463474 } else if (in (State::IN_DATAPROCESSOR_N_SLOTS)) {
464- output .back ().nSlots = i;
475+ dataProcessors .back ().nSlots = i;
465476 } else if (in (State::IN_DATAPROCESSOR_TIMESLICE_ID)) {
466- output .back ().inputTimeSliceId = i;
477+ dataProcessors .back ().inputTimeSliceId = i;
467478 } else if (in (State::IN_DATAPROCESSOR_MAX_TIMESLICES)) {
468- output .back ().maxInputTimeslices = i;
479+ dataProcessors .back ().maxInputTimeslices = i;
469480 }
470481 pop ();
471482 return true ;
@@ -526,8 +537,9 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
526537 std::ostringstream debug;
527538 std::vector<State> states;
528539 std::string spec;
529- std::vector<DataProcessorSpec>& output ;
540+ std::vector<DataProcessorSpec>& dataProcessors ;
530541 std::vector<DataProcessorInfo>& metadata;
542+ std::vector<ConfigParamSpec> inputOptions;
531543 std::string binding;
532544 header::DataOrigin origin;
533545 header::DataDescription description;
@@ -612,6 +624,26 @@ void WorkflowSerializationHelpers::dump(std::ostream& out,
612624 }
613625 w.Key (" lifetime" );
614626 w.Uint ((int )input.lifetime );
627+ if (input.metadata .empty () == false ) {
628+ w.Key (" metadata" );
629+ w.StartArray ();
630+ for (auto & metadata : input.metadata ) {
631+ w.StartObject ();
632+ w.Key (" name" );
633+ w.String (metadata.name .c_str ());
634+ auto s = std::to_string (int (metadata.type ));
635+ w.Key (" type" );
636+ w.String (s.c_str ());
637+ std::ostringstream oss;
638+ oss << metadata.defaultValue ;
639+ w.Key (" defaultValue" );
640+ w.String (oss.str ().c_str ());
641+ w.Key (" help" );
642+ w.String (metadata.help .c_str ());
643+ w.EndObject ();
644+ }
645+ w.EndArray ();
646+ }
615647 w.EndObject ();
616648 }
617649 w.EndArray ();
0 commit comments