Workaround for vector_shared_ptr_templated serialization mess.

This commit is contained in:
Sebastian
2024-12-19 01:00:38 +01:00
parent 9b75b36c41
commit c3543cffce
3 changed files with 15 additions and 29 deletions
+7 -2
View File
@@ -6,7 +6,6 @@
#include "node-handle.h"
#include "node.h"
#include "raylib.h"
#include "raymath.h"
#include "state.h"
#include <map>
#include <memory>
@@ -404,6 +403,12 @@ namespace VISEQ::GRAPH::NODES {
friend void to_json(json& j, const MidiNode& N){
std::vector<int> conns;
std::ranges::transform(N.connections.begin(), N.connections.end(), std::back_inserter(conns), [](VISEQ::GRAPH::EDGES::SPTR_Edge e){ return e->id;});
std::map<std::string, Vec2Df> noteHandles;
//std::ranges::transform(N.midiNoteHandles.begin(), N.midiNoteHandles.end(), std::back_inserter(noteHandles), [](std::shared_ptr<NodeHandle<int>> n){ return n->position;});
for(auto i : N.midiNoteHandles){
noteHandles.insert(std::make_pair(i->name, i->position));
}
j = json{
{"id", N.id},
{"position", N.position},
@@ -415,7 +420,7 @@ namespace VISEQ::GRAPH::NODES {
{"midiPitchBend", N.midiPitchBend},
{"midiAftertouch", N.midiAftertouch},
{"midiPolyPressure", N.midiPolyPressure},
//{"midiNoteHandle", N.midiNoteHandles},
{"midiNoteHandle", noteHandles},
/*{"midiCCHandle", N.midiCCHandles},*/
/*{"midiPCHandle", N.midiPCHandles},*/
/*{"midiPitchBendHandle", N.midiPitchBendHandles},*/
+1 -1
View File
@@ -131,6 +131,6 @@ namespace VISEQ::GRAPH::NODES{
/*friend void to_json(json& j, const NodeHandle<T>& N){*/
/* j = json{{"position",N.position}};*/
/*}*/
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(NodeHandle<T>, position, name);
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(NodeHandle, position, name);
};
}
+5 -24
View File
@@ -36,30 +36,10 @@ namespace nlohmann {
}
};
/**/
/*template <typename T>*/
/*struct adl_serializer<std::shared_ptr<NODES::NodeHandle<T>>> {*/
/*struct adl_serializer<std::shared_ptr<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) {*/
/* static void to_json(J& j, const std::shared_ptr<T>& opt) {*/
/* if (opt) {*/
/* j = *opt;*/
/* } else {*/
@@ -67,11 +47,12 @@ namespace nlohmann {
/* }*/
/* }*/
/**/
/* static void from_json(const json& j, std::shared_ptr<S<T>>& opt) {*/
/* template <typename J>*/
/* static void from_json(const J& j, std::shared_ptr<T>& opt) {*/
/* if (j.is_null()) {*/
/* opt = nullptr;*/
/* } else {*/
/* opt.reset(new S<T>(j.get<S<T>>()));*/
/* opt.reset(new T(j.template get<T>()));*/
/* }*/
/* }*/
/*};*/