Rework to weak_ptr from lots of shared_ptr.
This commit is contained in:
+21
-19
@@ -16,7 +16,6 @@
|
||||
#include "ui.h"
|
||||
|
||||
#include <memory>
|
||||
#include <ranges>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -91,8 +90,11 @@ namespace VISEQ::APP {
|
||||
int start_id = e.at("start").get<int>();
|
||||
int end_id = e.at("end").get<int>();
|
||||
|
||||
VEC_SPTR_Node start = gm.nodes | RANGE_FILTER([start_id](SPTR_Node n){return n->id == start_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
VEC_SPTR_Node end = gm.nodes | RANGE_FILTER([end_id](SPTR_Node n){return n->id == end_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
VEC_WPTR_Node start = gm.getNodesByID(start_id);
|
||||
VEC_WPTR_Node end = gm.getNodesByID(end_id);
|
||||
|
||||
// VEC_SPTR_Node start = gm.nodes | RANGE_FILTER([start_id](SPTR_Node n){return n->id == start_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
// VEC_SPTR_Node end = gm.nodes | RANGE_FILTER([end_id](SPTR_Node n){return n->id == end_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
|
||||
if(!start.empty() && !end.empty()) {
|
||||
std::cout << std::format("connection {} to {}", start_id, end_id) << std::endl;
|
||||
@@ -100,18 +102,17 @@ namespace VISEQ::APP {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gm.edges.back()->newId(highest_id); // set static id counter in base class to highest value from json file
|
||||
gm.lastEdge().lock()->newId(highest_id);
|
||||
|
||||
for(auto s : graph.at("signalmanager").at("signals")){
|
||||
int start_id = s.at("start").get<int>();
|
||||
int next_id = s.at("next").get<int>();
|
||||
int last_id = s.at("last").get<int>();
|
||||
std::shared_ptr<VISEQ::SIGNAL::Signal> ms = s;
|
||||
VEC_WPTR_Node start = gm.getNodesByID(start_id);
|
||||
VEC_WPTR_Node last = gm.getNodesByID(last_id);
|
||||
VEC_WPTR_Node next = gm.getNodesByID(next_id);
|
||||
|
||||
VEC_SPTR_Node start = gm.nodes | RANGE_FILTER([start_id](SPTR_Node n){return n->id == start_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
VEC_SPTR_Node last = gm.nodes | RANGE_FILTER([last_id](SPTR_Node n){return n->id == last_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
VEC_SPTR_Node next = gm.nodes | RANGE_FILTER([next_id](SPTR_Node n){return n->id == next_id;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||
ms->start = start.front();
|
||||
ms->next = next.front();
|
||||
ms->last = last.front();
|
||||
@@ -129,16 +130,16 @@ namespace VISEQ::APP {
|
||||
}
|
||||
|
||||
for(int i = 0; i < 8; ++i){
|
||||
gm.addConnection(gm.nodes[i], gm.nodes[(i+1) % 8]);
|
||||
gm.addConnection(gm.getNode(i), gm.getNode((i+1) % 8));
|
||||
}
|
||||
sm.addSignalAtNode(gm.nodes.front());
|
||||
sm.addSignalAtNode(gm.getFirstNode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void updateMidiPorts(){
|
||||
for(auto&n : gm.nodes | RANGE_FILTER([](VISEQ::GRAPH::NODES::SPTR_Node n){return n->getNodeType() == NodeType::MIDINODE;})){
|
||||
auto nc = std::dynamic_pointer_cast<MidiNode>(n);
|
||||
for(auto&n : gm.getMidiNodes()){
|
||||
auto nc = std::dynamic_pointer_cast<MidiNode>(n.lock());
|
||||
for(auto& mo : sm.midi.midi_out_ports){
|
||||
if(!nc->midi_outs.contains(mo.number) && mo.enabled){
|
||||
nc->midi_outs[mo.number] = {mo.number, mo.port.port_name, false};
|
||||
@@ -186,13 +187,14 @@ namespace VISEQ::APP {
|
||||
ui.draw(SCREEN_MOUSE, canvas->camera);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
/*inline void to_json(json& j, const AppManager& A){*/
|
||||
/* j = json{{"graphmanager", A.gm}, {"signalmanager", A.sm}};*/
|
||||
/*}*/
|
||||
/**/
|
||||
/*inline void from_json(const json& j, AppManager& A){*/
|
||||
/* j.at("graphmanager").get_to(A.gm); // = json{{"graphmanager", A.gm}, {"signalmanager", A.sm}};*/
|
||||
/*}*/
|
||||
};
|
||||
|
||||
inline void to_json(json& j, const AppManager& A){
|
||||
j = json{{"graphmanager", A.gm}, {"signalmanager", A.sm}};
|
||||
}
|
||||
|
||||
inline void from_json(const json& j, AppManager& A){
|
||||
j.at("graphmanager").get_to(A.gm); // = json{{"graphmanager", A.gm}, {"signalmanager", A.sm}};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user