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
63SCORE_PLUGIN_SCENARIO_EXPORT void
64notifyAddedCables(std::span<Process::Cable*>, const score::DocumentContext& ctx);
65
68SCORE_PLUGIN_SCENARIO_EXPORT
69void loadCables(
70 const ObjectPath& old_path, const ObjectPath& new_path,
71 Dataflow::SerializedCables& cables, const score::DocumentContext& ctx);
72
77SCORE_PLUGIN_SCENARIO_EXPORT
78void unstripCables(const ObjectPath& new_path, Dataflow::SerializedCables& cables);
79
81{
82 QString name;
83 Process::PortType type;
84 QByteArray data;
85};
86
90[[nodiscard]] SCORE_PLUGIN_SCENARIO_EXPORT ossia::small_vector<Process::Cable*, 4>
91reloadPortsInNewProcess(
92 const std::vector<SavedPort>& m_oldInlets,
93 const std::vector<SavedPort>& m_oldOutlets,
94 const Dataflow::SerializedCables& m_oldCables, Process::ProcessModel& cmt,
95 const score::DocumentContext& ctx);
96
98SCORE_PLUGIN_SCENARIO_EXPORT
99void reloadPortsInNewProcess(
100 const std::vector<SavedPort>& m_oldInlets,
101 const std::vector<SavedPort>& m_oldOutlets, Process::ProcessModel& cmt);
102}
103
104template <>
105struct is_custom_serialized<Dataflow::SavedPort> : std::true_type
106{
107};
108
109template <>
110struct TSerializer<DataStream, Dataflow::SavedPort>
111{
112 static void readFrom(DataStream::Serializer& s, const Dataflow::SavedPort& tv)
113 {
114 s.stream() << tv.name << tv.type << tv.data;
115 }
116
117 static void writeTo(DataStream::Deserializer& s, Dataflow::SavedPort& tv)
118 {
119 s.stream() >> tv.name >> tv.type >> tv.data;
120 }
121};
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:62
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition CableHelpers.hpp:81
Definition CableData.hpp:18
Definition VisitorInterface.hpp:13
Definition DocumentContext.hpp:18