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 <QStringList>
12
13#include <score_plugin_scenario_export.h>
14
15#include <vector>
16#include <span>
17
19namespace Process
20{
21class Cable;
22struct CableData;
23class ProcessModel;
24}
25namespace Dataflow
26{
27using SerializedCables = std::vector<std::pair<Id<Process::Cable>, Process::CableData>>;
28
30SCORE_PLUGIN_SCENARIO_EXPORT
31std::vector<Process::Cable*>
32getCablesInChildObjects(QObjectList objs, const score::DocumentContext& ctx);
33
35SCORE_PLUGIN_SCENARIO_EXPORT
36SerializedCables saveCables(QObjectList objs, const score::DocumentContext& ctx);
37
40SCORE_PLUGIN_SCENARIO_EXPORT
41SerializedCables serializedCablesFromCableJson(
42 const ObjectPath& old_path, const ObjectPath& new_path,
43 const rapidjson::Document::Array& arr);
44SCORE_PLUGIN_SCENARIO_EXPORT
45SerializedCables serializedCablesFromCableJson(
46 const ObjectPath& old_path, const rapidjson::Document::Array& arr);
47
49SCORE_PLUGIN_SCENARIO_EXPORT
50void removeCables(const SerializedCables& cbls, const score::DocumentContext& ctx);
51
54[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
55restoreCables(const SerializedCables& cbls, const score::DocumentContext& ctx);
58[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
59restoreCablesWithoutTouchingPorts(
60 const SerializedCables& cbls, const score::DocumentContext& ctx);
61
66SCORE_PLUGIN_SCENARIO_EXPORT void
67reattachCablesToPorts(std::span<Process::Cable*>, const score::DocumentContext& ctx);
68
72SCORE_PLUGIN_SCENARIO_EXPORT void
73notifyAddedCables(std::span<Process::Cable*>, const score::DocumentContext& ctx);
74
77SCORE_PLUGIN_SCENARIO_EXPORT
78void loadCables(
79 const ObjectPath& old_path, const ObjectPath& new_path,
80 Dataflow::SerializedCables& cables, const score::DocumentContext& ctx);
81
86SCORE_PLUGIN_SCENARIO_EXPORT
87void unstripCables(const ObjectPath& new_path, Dataflow::SerializedCables& cables);
88
90{
91 QString name;
92 Process::PortType type;
93 QByteArray data;
94};
95
99[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
100reloadPortsInNewProcess(
101 const std::vector<SavedPort>& m_oldInlets,
102 const std::vector<SavedPort>& m_oldOutlets,
103 const Dataflow::SerializedCables& m_oldCables, Process::ProcessModel& cmt,
104 Process::PortLoadDataFlags, const score::DocumentContext& ctx,
105 std::span<const int> oldInletIds, std::span<const int> oldOutletIds);
106
110SCORE_PLUGIN_SCENARIO_EXPORT
111QStringList reloadPortsInNewProcess(
112 const std::vector<SavedPort>& m_oldInlets,
113 const std::vector<SavedPort>& m_oldOutlets, Process::ProcessModel& cmt);
114}
115
116template <>
117struct is_custom_serialized<Dataflow::SavedPort> : std::true_type
118{
119};
120
121template <>
122struct TSerializer<DataStream, Dataflow::SavedPort>
123{
124 static void readFrom(DataStream::Serializer& s, const Dataflow::SavedPort& tv)
125 {
126 s.stream() << tv.name << tv.type << tv.data;
127 }
128
129 static void writeTo(DataStream::Deserializer& s, Dataflow::SavedPort& tv)
130 {
131 s.stream() >> tv.name >> tv.type >> tv.data;
132 }
133};
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:80
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition CableHelpers.hpp:90
Definition CableData.hpp:18
Definition VisitorInterface.hpp:13
Definition DocumentContext.hpp:18