Loading...
Searching...
No Matches
CableHelpers.hpp
1#pragma once
2
3#include <Process/Dataflow/CableData.hpp>
4#include <Process/Dataflow/PortType.hpp>
5
7#include <score/serialization/IsTemplate.hpp>
8
9#include <ossia/detail/json.hpp>
10
11#include <score_plugin_scenario_export.h>
12
13#include <vector>
14#include <span>
15
17namespace Process
18{
19class Cable;
20struct CableData;
21class ProcessModel;
22}
23namespace Dataflow
24{
25using SerializedCables = std::vector<std::pair<Id<Process::Cable>, Process::CableData>>;
26
28SCORE_PLUGIN_SCENARIO_EXPORT
29std::vector<Process::Cable*>
30getCablesInChildObjects(QObjectList objs, const score::DocumentContext& ctx);
31
33SCORE_PLUGIN_SCENARIO_EXPORT
34SerializedCables saveCables(QObjectList objs, const score::DocumentContext& ctx);
35
38SCORE_PLUGIN_SCENARIO_EXPORT
39SerializedCables serializedCablesFromCableJson(
40 const ObjectPath& old_path, const ObjectPath& new_path,
41 const rapidjson::Document::Array& arr);
42SCORE_PLUGIN_SCENARIO_EXPORT
43SerializedCables serializedCablesFromCableJson(
44 const ObjectPath& old_path, const rapidjson::Document::Array& arr);
45
47SCORE_PLUGIN_SCENARIO_EXPORT
48void removeCables(const SerializedCables& cbls, const score::DocumentContext& ctx);
49
52[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
53restoreCables(const SerializedCables& cbls, const score::DocumentContext& ctx);
56[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
57restoreCablesWithoutTouchingPorts(
58 const SerializedCables& cbls, const score::DocumentContext& ctx);
59
64SCORE_PLUGIN_SCENARIO_EXPORT void
65reattachCablesToPorts(std::span<Process::Cable*>, const score::DocumentContext& ctx);
66
70SCORE_PLUGIN_SCENARIO_EXPORT void
71notifyAddedCables(std::span<Process::Cable*>, const score::DocumentContext& ctx);
72
75SCORE_PLUGIN_SCENARIO_EXPORT
76void loadCables(
77 const ObjectPath& old_path, const ObjectPath& new_path,
78 Dataflow::SerializedCables& cables, const score::DocumentContext& ctx);
79
84SCORE_PLUGIN_SCENARIO_EXPORT
85void unstripCables(const ObjectPath& new_path, Dataflow::SerializedCables& cables);
86
88{
89 QString name;
90 Process::PortType type;
91 QByteArray data;
92};
93
97[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
98reloadPortsInNewProcess(
99 const std::vector<SavedPort>& m_oldInlets,
100 const std::vector<SavedPort>& m_oldOutlets,
101 const Dataflow::SerializedCables& m_oldCables, Process::ProcessModel& cmt,
102 Process::PortLoadDataFlags, const score::DocumentContext& ctx,
103 std::span<const int> oldInletIds, std::span<const int> oldOutletIds);
104
106SCORE_PLUGIN_SCENARIO_EXPORT
107void reloadPortsInNewProcess(
108 const std::vector<SavedPort>& m_oldInlets,
109 const std::vector<SavedPort>& m_oldOutlets, Process::ProcessModel& cmt);
110}
111
112template <>
113struct is_custom_serialized<Dataflow::SavedPort> : std::true_type
114{
115};
116
117template <>
118struct TSerializer<DataStream, Dataflow::SavedPort>
119{
120 static void readFrom(DataStream::Serializer& s, const Dataflow::SavedPort& tv)
121 {
122 s.stream() << tv.name << tv.type << tv.data;
123 }
124
125 static void writeTo(DataStream::Deserializer& s, Dataflow::SavedPort& tv)
126 {
127 s.stream() >> tv.name >> tv.type >> tv.data;
128 }
129};
Definition VisitorInterface.hpp:53
Definition DataStreamVisitor.hpp:27
Definition DataStreamVisitor.hpp:202
The ObjectPath class.
Definition ObjectPath.hpp:37
The Process class.
Definition score-lib-process/Process/Process.hpp:75
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition CableHelpers.hpp:88
Definition CableData.hpp:18
Definition VisitorInterface.hpp:13
Definition DocumentContext.hpp:18