@@ -399,6 +399,34 @@ void from_json(const json& j, Pipeline<T, V>& p) {
399399 p = Pipeline<T, V>(j.at (" id" ).get <string>(), j.at (" prog" ).dump ());
400400}
401401
402+ template <class T , class V >
403+ void to_json (json& j, const ConstantResampler<T, V>& p) {
404+ j = json{{" type" , p.typeName ()}, {" id" , p.id }, {" interval" , p.getInterval ()}};
405+ }
406+
407+ template <class T , class V >
408+ void from_json (const json& j, ConstantResampler<T, V>& p) {
409+ p = ConstantResampler<T, V>(j[" id" ].get <string>(), j[" interval" ].get <T>());
410+ }
411+
412+ template <class T , class V >
413+ void to_json (json& j, const Function<T, V>& p) {
414+ vector<vector<V>> points_array;
415+ for (const auto & point : p.getPoints ()) {
416+ points_array.push_back ({point.first , point.second });
417+ }
418+ j = json{{" type" , p.typeName ()}, {" id" , p.id }, {" points" , points_array}, {" type" , p.getInterpolationType ()}};
419+ }
420+
421+ template <class T , class V >
422+ void from_json (const json& j, Function<T, V>& p) {
423+ vector<pair<V, V>> points;
424+ for (const auto & point : j[" points" ]) {
425+ points.push_back ({point[0 ].get <V>(), point[1 ].get <V>()});
426+ }
427+ p = Function<T, V>(j[" id" ].get <string>(), points, j.value (" type" , " linear" ));
428+ }
429+
402430/* Operators serialization - deserialization - end */
403431
404432Bytes FactoryOp::serialize (string const & programId) {
@@ -463,6 +491,8 @@ FactoryOp::FactoryOp() {
463491 op_registry_add<Pipeline<uint64_t , double >, json>();
464492 op_registry_add<GreaterThanStream<uint64_t , double >, json>();
465493 op_registry_add<LessThanStream<uint64_t , double >, json>();
494+ op_registry_add<Function<uint64_t , double >, json>();
495+ op_registry_add<ConstantResampler<uint64_t , double >, json>();
466496}
467497
468498static FactoryOp factory;
0 commit comments