Serialization of NodeHandle<T> stays a mystery...

This commit is contained in:
Sebastian
2024-12-16 02:10:58 +01:00
parent 996ed16c01
commit 9b75b36c41
5 changed files with 103 additions and 56 deletions
+59 -14
View File
@@ -3,6 +3,7 @@
#include "config-node.h"
#include "midi-node.h"
#include "graph-item.h"
#include "node-handle.h"
#include "node.h"
#include "edge.h"
@@ -34,6 +35,46 @@ namespace nlohmann {
}
}
};
/**/
/*template <typename T>*/
/*struct adl_serializer<std::shared_ptr<NODES::NodeHandle<T>>> {*/
/* template< typename J> */
/* static void to_json(J& j, const std::shared_ptr<NODES::NodeHandle<T>>& opt) {*/
/* if (opt) {*/
/* j = *opt;*/
/* } else {*/
/* j = nullptr;*/
/* }*/
/* }*/
/* template< typename J>*/
/* static void from_json(const J& j, std::shared_ptr<NODES::NodeHandle<T>>& opt) {*/
/* if (j.is_null()) {*/
/* opt = nullptr;*/
/* } else {*/
/* opt.reset(new NODES::NodeHandle<T>(j.template get<NODES::NodeHandle<T>>()));*/
/* }*/
/* }*/
/*};*/
/*template <template<typename> class S, typename T>*/
/*struct adl_serializer<std::shared_ptr<S<T>>> {*/
/* static void to_json(json& j, const std::shared_ptr<S<T>>& opt) {*/
/* if (opt) {*/
/* j = *opt;*/
/* } else {*/
/* j = nullptr;*/
/* }*/
/* }*/
/**/
/* static void from_json(const json& j, std::shared_ptr<S<T>>& opt) {*/
/* if (j.is_null()) {*/
/* opt = nullptr;*/
/* } else {*/
/* opt.reset(new S<T>(j.get<S<T>>()));*/
/* }*/
/* }*/
/*};*/
}
namespace VISEQ::GRAPH::EDGES {
@@ -62,28 +103,32 @@ namespace VISEQ::GRAPH::NODES {
/* ------------------- MIDINODE ---------------------- */
inline void to_json(json& j, const std::shared_ptr<MidiNode>& N){
j = *N;
}
inline void from_json(const json& j, std::shared_ptr<MidiNode>& N){
N.reset(new MidiNode(j.get<MidiNode>()));
}
/*inline void to_json(json& j, const std::shared_ptr<MidiNode>& N){*/
/* j = *N;*/
/*}*/
/**/
/*inline void from_json(const json& j, std::shared_ptr<MidiNode>& N){*/
/* N.reset(new MidiNode(j.get<MidiNode>()));*/
/*}*/
inline void to_json(json& j, const MidiNode::NodeMidiOut& MO){
j = json{{"port_id", MO.i}, {"enabled", MO.enabled}, {"name", MO.name}};
}
/*template< typename T>*/
/*inline void to_json(json& j, const std::shared_ptr<NodeHandle<T>>& NH){*/
/* j = json{{"position", NH->position}};*/
/*}*/
/* ----------------- CONFIG NODE -----------------*/
inline void to_json(json& j, const std::shared_ptr<ConfigNode>& N){
j = *N;
}
inline void from_json(const json& j, std::shared_ptr<ConfigNode>& N){
N.reset(new ConfigNode(j.get<ConfigNode>()));
}
/*inline void to_json(json& j, const std::shared_ptr<ConfigNode>& N){*/
/* j = *N;*/
/*}*/
/**/
/*inline void from_json(const json& j, std::shared_ptr<ConfigNode>& N){*/
/* N.reset(new ConfigNode(j.get<ConfigNode>()));*/
/*}*/
/* ------------------- NODE ---------------------- */