Skip to content

Commit ec12ba2

Browse files
committed
DPL: add support for serializing / deserialising ContextRef
1 parent b309589 commit ec12ba2

File tree

1 file changed

+77
-16
lines changed

1 file changed

+77
-16
lines changed

Framework/Core/src/WorkflowSerializationHelpers.cxx

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
5757
IN_INPUT_ORIGIN,
5858
IN_INPUT_DESCRIPTION,
5959
IN_INPUT_SUBSPEC,
60+
IN_INPUT_ORIGIN_REF,
61+
IN_INPUT_DESCRIPTION_REF,
62+
IN_INPUT_SUBSPEC_REF,
6063
IN_INPUT_LIFETIME,
6164
IN_INPUT_STARTTIME,
6265
IN_INPUT_MATCHER,
@@ -154,6 +157,15 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
154157
case State::IN_INPUT_SUBSPEC:
155158
s << "IN_INPUT_SUBSPEC";
156159
break;
160+
case State::IN_INPUT_ORIGIN_REF:
161+
s << "IN_INPUT_ORIGIN_REF";
162+
break;
163+
case State::IN_INPUT_DESCRIPTION_REF:
164+
s << "IN_INPUT_DESCRIPTION_REF";
165+
break;
166+
case State::IN_INPUT_SUBSPEC_REF:
167+
s << "IN_INPUT_SUBSPEC_REF";
168+
break;
157169
case State::IN_INPUT_MATCHER:
158170
s << "IN_INPUT_MATCHER";
159171
break;
@@ -546,6 +558,12 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
546558
push(State::IN_INPUT_DESCRIPTION);
547559
} else if (in(State::IN_INPUT) && strncmp(str, "subspec", length) == 0) {
548560
push(State::IN_INPUT_SUBSPEC);
561+
} else if (in(State::IN_INPUT) && strncmp(str, "originRef", length) == 0) {
562+
push(State::IN_INPUT_ORIGIN_REF);
563+
} else if (in(State::IN_INPUT) && strncmp(str, "descriptionRef", length) == 0) {
564+
push(State::IN_INPUT_DESCRIPTION_REF);
565+
} else if (in(State::IN_INPUT) && strncmp(str, "subspecRef", length) == 0) {
566+
push(State::IN_INPUT_SUBSPEC_REF);
549567
} else if (in(State::IN_INPUT) && strncmp(str, "matcher", length) == 0) {
550568
// the outermost matcher is starting here
551569
// we create a placeholder which is being updated later
@@ -573,6 +591,18 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
573591
push(State::IN_INPUT_SUBSPEC);
574592
} else if (in(State::IN_INPUT_RIGHT_MATCHER) && strncmp(str, "subspec", length) == 0) {
575593
push(State::IN_INPUT_SUBSPEC);
594+
} else if (in(State::IN_INPUT_LEFT_MATCHER) && strncmp(str, "originRef", length) == 0) {
595+
push(State::IN_INPUT_ORIGIN_REF);
596+
} else if (in(State::IN_INPUT_RIGHT_MATCHER) && strncmp(str, "originRef", length) == 0) {
597+
push(State::IN_INPUT_ORIGIN_REF);
598+
} else if (in(State::IN_INPUT_LEFT_MATCHER) && strncmp(str, "descriptionRef", length) == 0) {
599+
push(State::IN_INPUT_DESCRIPTION_REF);
600+
} else if (in(State::IN_INPUT_RIGHT_MATCHER) && strncmp(str, "descriptionRef", length) == 0) {
601+
push(State::IN_INPUT_DESCRIPTION_REF);
602+
} else if (in(State::IN_INPUT_LEFT_MATCHER) && strncmp(str, "subspecRef", length) == 0) {
603+
push(State::IN_INPUT_SUBSPEC_REF);
604+
} else if (in(State::IN_INPUT_RIGHT_MATCHER) && strncmp(str, "subspecRef", length) == 0) {
605+
push(State::IN_INPUT_SUBSPEC_REF);
576606
} else if (in(State::IN_INPUT_LEFT_MATCHER) && strncmp(str, "starttime", length) == 0) {
577607
push(State::IN_INPUT_STARTTIME);
578608
} else if (in(State::IN_INPUT_RIGHT_MATCHER) && strncmp(str, "starttime", length) == 0) {
@@ -740,6 +770,15 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
740770
if (in(State::IN_INPUT_SUBSPEC)) {
741771
subspec = i;
742772
inputMatcherNodes.push_back(SubSpecificationTypeValueMatcher{i});
773+
} else if (in(State::IN_INPUT_ORIGIN_REF)) {
774+
ref = i;
775+
inputMatcherNodes.push_back(OriginValueMatcher{ContextRef{i}});
776+
} else if (in(State::IN_INPUT_DESCRIPTION_REF)) {
777+
ref = i;
778+
inputMatcherNodes.push_back(DescriptionValueMatcher{ContextRef{i}});
779+
} else if (in(State::IN_INPUT_SUBSPEC_REF)) {
780+
ref = i;
781+
inputMatcherNodes.push_back(SubSpecificationTypeValueMatcher{ContextRef{i}});
743782
} else if (in(State::IN_OUTPUT_SUBSPEC)) {
744783
subspec = i;
745784
} else if (in(State::IN_INPUT_LIFETIME)) {
@@ -823,6 +862,7 @@ struct WorkflowImporter : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
823862
header::DataOrigin origin;
824863
header::DataDescription description;
825864
size_t subspec;
865+
size_t ref;
826866
Lifetime lifetime;
827867
std::string optionName;
828868
VariantType optionType;
@@ -923,22 +963,43 @@ void WorkflowSerializationHelpers::dump(std::ostream& out,
923963
[&w](auto) {}};
924964
auto leafWalker = overloaded{
925965
[&w](OriginValueMatcher const& origin) {
926-
w.Key("origin");
927-
std::stringstream ss;
928-
ss << origin;
929-
w.String(ss.str().c_str());
966+
origin.visit(overloaded{
967+
[&w](ContextRef const& ref) {
968+
w.Key("originRef");
969+
w.Uint64(ref.index);
970+
},
971+
[&w](auto const& value) {
972+
w.Key("origin");
973+
std::stringstream ss;
974+
ss << value;
975+
w.String(ss.str().c_str());
976+
}});
930977
},
931978
[&w](DescriptionValueMatcher const& description) {
932-
w.Key("description");
933-
std::stringstream ss;
934-
ss << description;
935-
w.String(ss.str().c_str());
979+
description.visit(overloaded{
980+
[&w](ContextRef const& ref) {
981+
w.Key("descriptionRef");
982+
w.Uint64(ref.index);
983+
},
984+
[&w](auto const& value) {
985+
w.Key("description");
986+
std::stringstream ss;
987+
ss << value;
988+
w.String(ss.str().c_str());
989+
}});
936990
},
937991
[&w](SubSpecificationTypeValueMatcher const& subspec) {
938-
w.Key("subspec");
939-
std::stringstream ss;
940-
ss << subspec;
941-
w.Uint64(std::stoul(ss.str()));
992+
subspec.visit(overloaded{
993+
[&w](ContextRef const& ref) {
994+
w.Key("subspecRef");
995+
w.Uint64(ref.index);
996+
},
997+
[&w](auto const& value) {
998+
w.Key("subspec");
999+
std::stringstream ss;
1000+
ss << value;
1001+
w.Uint64(std::stoul(ss.str()));
1002+
}});
9421003
},
9431004
[&w](StartTimeValueMatcher const& startTime) {
9441005
w.Key("starttime");
@@ -977,10 +1038,10 @@ void WorkflowSerializationHelpers::dump(std::ostream& out,
9771038
w.String(concrete->description.str, strnlen(concrete->description.str, 16));
9781039
w.Key("subspec");
9791040
w.Uint64(concrete->subSpec);
980-
//auto tmp = DataSpecUtils::dataDescriptorMatcherFrom(*concrete);
981-
//DataMatcherWalker::walk(tmp,
982-
// edgeWalker,
983-
// leafWalker);
1041+
// auto tmp = DataSpecUtils::dataDescriptorMatcherFrom(*concrete);
1042+
// DataMatcherWalker::walk(tmp,
1043+
// edgeWalker,
1044+
// leafWalker);
9841045
} else if (auto const* matcher = std::get_if<DataDescriptorMatcher>(&input.matcher)) {
9851046
DataMatcherWalker::walk(*matcher,
9861047
edgeWalker,

0 commit comments

Comments
 (0)