2 #include <Process/Dataflow/Port.hpp>
3 #include <Process/Process.hpp>
4 #include <Process/Script/ScriptEditor.hpp>
5 #include <Process/Script/ScriptProcess.hpp>
7 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentModel.hpp>
9 #include <Dataflow/Commands/CableHelpers.hpp>
11 #include <ossia/detail/algorithms.hpp>
16 template <
typename Process_T,
typename Property_T>
20 using param_type =
typename Property_T::param_type;
21 using score::Command::Command;
25 , m_newScript{std::move(newScript)}
26 , m_oldScript{(model.*Property_T::get)()}
28 m_oldCables = Dataflow::saveCables({
const_cast<Process_T*
>(&model)}, ctx);
30 for(
auto& port : model.inlets())
31 m_oldInlets.emplace_back(
SavedPort{port->name(), port->type(), port->saveData()});
32 for(
auto& port : model.outlets())
33 m_oldOutlets.emplace_back(
SavedPort{port->name(), port->type(), port->saveData()});
39 auto& cmt = m_path.find(ctx);
42 Dataflow::removeCables(m_oldCables, ctx);
50 SCORE_ASSERT(m_oldInlets.size() == cmt.inlets().size());
51 SCORE_ASSERT(m_oldOutlets.size() == cmt.outlets().size());
54 for(std::size_t i = 0; i < m_oldInlets.size(); i++)
56 cmt.inlets()[i]->loadData(m_oldInlets[i].data);
58 for(std::size_t i = 0; i < m_oldOutlets.size(); i++)
60 cmt.outlets()[i]->loadData(m_oldOutlets[i].data);
64 Dataflow::restoreCables(m_oldCables, ctx);
67 if constexpr(requires { cmt.isGpu(); })
72 void redo(const
score::DocumentContext& ctx)
const override
74 Dataflow::removeCables(m_oldCables, ctx);
76 auto& cmt = m_path.find(ctx);
80 Dataflow::reloadPortsInNewProcess(m_oldInlets, m_oldOutlets, m_oldCables, cmt, ctx);
84 if constexpr(requires { cmt.isGpu(); })
95 s << m_path << m_newScript << m_oldScript << m_oldInlets << m_oldOutlets
101 s >> m_path >> m_newScript >> m_oldScript >> m_oldInlets >> m_oldOutlets
106 param_type m_newScript;
107 param_type m_oldScript;
109 std::vector<SavedPort> m_oldInlets, m_oldOutlets;
111 Dataflow::SerializedCables m_oldCables;
116 struct is_custom_serialized<
Scenario::SavedPort> : std::true_type
125 s.stream() << tv.name << tv.type << tv.data;
130 s.stream() >> tv.name >> tv.type >> tv.data;
Definition: VisitorInterface.hpp:53
Definition: DataStreamVisitor.hpp:27
Definition: DataStreamVisitor.hpp:202
Definition: ScriptEditCommand.hpp:18
The Command class.
Definition: Command.hpp:34
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DataStreamHelpers.hpp:103
Definition: CableHelpers.hpp:66
Definition: ScriptProcess.hpp:14
Definition: VisitorInterface.hpp:13
Definition: DocumentContext.hpp:18