2 #include <Process/ProcessList.hpp>
4 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentModel.hpp>
5 #include <Scenario/Process/ScenarioModel.hpp>
7 #include <score/application/GUIApplicationContext.hpp>
8 #include <score/document/DocumentContext.hpp>
9 #include <score/model/EntitySerialization.hpp>
10 #include <score/plugins/SerializableHelpers.hpp>
11 #include <score/tools/IdentifierGeneration.hpp>
13 #include <ossia/detail/flat_map.hpp>
14 #include <ossia/detail/hash_map.hpp>
19 std::vector<Process::CableData>
20 cableDataFromCablesJson(
const rapidjson::Document::ConstArray& arr);
21 std::vector<Process::CableData>
22 cableDataFromCablesJson(
const rapidjson::Document::Array& arr);
25 template <
typename CopiedObjects,
typename ParentObject>
28 std::vector<CopiedObjects*>& intervals,
37 for(CopiedObjects* interval : intervals)
39 id_map[interval->id()] = interval_ids[i];
44 auto& doc = score::IDocument::modelDelegate<ScenarioDocumentModel>(ctx.document);
45 auto cable_ids = getStrongIdRange<Process::Cable>(cables.size(), doc.cables);
51 auto& source_vec = cd.source.unsafePath().vec();
52 auto& sink_vec = cd.sink.unsafePath().vec();
53 SCORE_ASSERT(!source_vec.empty());
54 SCORE_ASSERT(!sink_vec.empty());
55 int32_t source_itv_id = source_vec.front().id();
56 int32_t sink_itv_id = sink_vec.front().id();
58 for(CopiedObjects* interval : intervals)
60 auto id = interval->id().val();
61 if(
id == source_itv_id)
62 source_itv_id = id_map.at(interval->id()).val();
64 sink_itv_id = id_map.at(interval->id()).val();
68 sink_vec.front() =
ObjectIdentifier{sink_vec.front().objectName(), sink_itv_id};
71 source_vec.begin(), p.unsafePath().vec().begin(), p.unsafePath().vec().end());
73 sink_vec.begin(), p.unsafePath().vec().begin(), p.unsafePath().vec().end());
75 cable_map.insert({cable_ids[i], std::move(cd)});
79 for(CopiedObjects* interval : intervals)
81 const auto ports = interval->template findChildren<Process::Port*>();
84 while(!port->cables().empty())
86 port->removeCable(port->cables().back());
107 const auto& json_arr = obj[
"Intervals"].GetArray();
108 intervals.reserve(json_arr.Size());
109 for(
const auto& element : json_arr)
116 const auto& json_arr = obj[
"TimeNodes"].GetArray();
117 timesyncs.reserve(json_arr.Size());
118 for(
const auto& element : json_arr)
120 timesyncs.emplace_back(
125 const auto& json_arr = obj[
"Events"].GetArray();
126 events.reserve(json_arr.Size());
127 for(
const auto& element : json_arr)
133 const auto& json_arr = obj[
"States"].GetArray();
134 states.reserve(json_arr.Size());
135 for(
const auto& element : json_arr)
142 const auto& json_arr = obj[
"Cables"].GetArray();
143 cables = cableDataFromCablesJson(json_arr);
147 interval_ids = getStrongIdRange2<IntervalModel>(
148 intervals.size(), scenario.intervals, intervals);
149 timesync_ids = getStrongIdRange2<TimeSyncModel>(
150 timesyncs.size(), scenario.timeSyncs, timesyncs);
151 event_ids = getStrongIdRange2<EventModel>(events.size(), scenario.events, events);
152 state_ids = getStrongIdRange2<StateModel>(states.size(), scenario.states, states);
155 std::vector<TimeSyncModel*> timesyncs;
156 std::vector<IntervalModel*> intervals;
157 std::vector<EventModel*> events;
158 std::vector<StateModel*> states;
159 std::vector<Process::CableData> cables;
161 std::vector<Id<IntervalModel>> interval_ids;
162 std::vector<Id<TimeSyncModel>> timesync_ids;
163 std::vector<Id<EventModel>> event_ids;
164 std::vector<Id<StateModel>> state_ids;
170 const rapidjson::Value::Array& sourceProcesses,
180 const auto& json_arr = sourceProcesses;
181 processes.reserve(json_arr.Size());
182 for(
const auto& element : json_arr)
185 auto proc = deserialize_interface(
188 processes.emplace_back(proc);
193 processes_ids = getStrongIdRange2<Process::ProcessModel>(
194 processes.size(), parent.
processes, processes);
197 std::vector<Process::ProcessModel*> processes;
198 std::vector<Id<Process::ProcessModel>> processes_ids;
Definition: JSONVisitor.hpp:423
The ObjectIdentifier class.
Definition: ObjectIdentifier.hpp:21
The Path class is a typesafe wrapper around ObjectPath.
Definition: Path.hpp:52
Definition: ProcessList.hpp:10
Definition: EventModel.hpp:36
Definition: IntervalModel.hpp:50
score::EntityMap< Process::ProcessModel, true > processes
Definition: IntervalModel.hpp:62
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
Definition: StateModel.hpp:63
Definition: TimeSyncModel.hpp:34
The id_base_t class.
Definition: Identifier.hpp:57
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: CableData.hpp:18
Definition: ScenarioPaste.hpp:168
Definition: ScenarioPaste.hpp:96
const T & interfaces() const
Access to a specific interface list.
Definition: ApplicationContext.hpp:67
Definition: DocumentContext.hpp:18