MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / duplicate_tree

Method duplicate_tree

src/session/src/session_actor.cpp:2234–2293  ·  view source on GitHub ↗

session actors container groups/dividers and playlists..

Source from the content-addressed store, hash-verified

2232
2233// session actors container groups/dividers and playlists..
2234void SessionActor::duplicate_tree(
2235 utility::UuidTree<utility::PlaylistItem> &tree,
2236 caf::actor source_session,
2237 const bool rename) {
2238
2239 if (rename)
2240 tree.value().set_name(tree.value().name() + " - copy");
2241
2242 if (tree.value().type() == "ContainerDivider") {
2243 tree.value().set_uuid(Uuid::generate());
2244 mail(utility::event_atom_v, playlist::create_divider_atom_v, tree.uuid())
2245 .send(base_.event_group());
2246 } else if (tree.value().type() == "ContainerGroup") {
2247 tree.value().set_uuid(Uuid::generate());
2248 mail(utility::event_atom_v, playlist::create_group_atom_v, tree.uuid())
2249 .send(base_.event_group());
2250 } else if (tree.value().type() == "Playlist") {
2251 // need to issue a duplicate action, as we actors are blackboxes..
2252 // try not to confuse this with duplicating a container, as opposed to the actor..
2253 // we need to insert the new playlist in to the session and update the UUID
2254 try {
2255 caf::scoped_actor sys(system());
2256
2257 // request playlist actor from source, may not be local..
2258 caf::actor playlist;
2259 caf::actor bookmarks = bookmarks_;
2260 if (source_session == this)
2261 playlist = playlists_[tree.value().uuid()];
2262 else {
2263 // request bookmarks..
2264 bookmarks = request_receive<caf::actor>(
2265 *sys, source_session, bookmark::get_bookmark_atom_v);
2266 playlist = request_receive<caf::actor>(
2267 *sys, source_session, get_playlist_atom_v, tree.value().uuid());
2268 }
2269
2270 auto result = request_receive<UuidActor>(
2271 *sys, playlist, duplicate_atom_v, bookmarks, bookmarks_);
2272
2273 tree.value().set_uuid(result.uuid());
2274 playlists_[result.uuid()] = result.actor();
2275 if (rename) {
2276 auto name = request_receive<std::string>(*sys, result.actor(), name_atom_v);
2277 tree.value().set_name(name + " - copy");
2278 mail(name_atom_v, tree.value().name()).send(result.actor());
2279 }
2280
2281 link_to(result.actor());
2282 mail(utility::event_atom_v, add_playlist_atom_v, result).send(base_.event_group());
2283 } catch (const std::exception &err) {
2284 spdlog::warn("{} {}", __PRETTY_FUNCTION__, err.what());
2285 // set to invalid uuid ?
2286 tree.value().set_uuid(Uuid());
2287 }
2288 }
2289
2290 for (auto &i : tree.children_) {
2291 duplicate_tree(i, source_session);

Callers

nothing calls this directly

Calls 11

UuidClass · 0.85
event_groupMethod · 0.80
actorMethod · 0.80
whatMethod · 0.80
set_nameMethod · 0.45
valueMethod · 0.45
nameMethod · 0.45
typeMethod · 0.45
set_uuidMethod · 0.45
sendMethod · 0.45
uuidMethod · 0.45

Tested by

no test coverage detected