GstShmTreeUpdater::GstShmTreeUpdater(Quiddity* quid, GstElement* element, const std::string& shmpath, Direction dir, on_caps_cb_t on_caps_cb, on_delete_t on_delete_cb) : quid_(quid), shmpath_(shmpath), dir_(dir), key_(dir_ == Direction::writer ? ".shmdata.writer." : ".shmdata.reader."), on_del_(on_delete_cb), shm_sub_(element, [this, on_caps_cb](const std::string& caps) { auto parent_path = key_ + shmpath_; quid_->graft_tree(parent_path + ".caps", InfoTree::make(caps), false); quid_->graft_tree(parent_path + ".category", InfoTree::make(ShmdataUtils::get_category(caps)), false); quid_->notify_tree_updated(parent_path); if (on_caps_cb) on_caps_cb(caps); }, ShmdataStat::make_tree_updater(quid_, key_ + shmpath_)) { auto path = key_ + shmpath_; auto tree = quid_->prune_tree(path, false); // adding default informations for this shmdata quid_->graft_tree(path, Quiddity::get_shm_information_template(), false); if (tree) { for (auto& it : tree->get_child_keys(".")) { quid_->graft_tree(path + "." + it, tree->prune(it), false); } } }
QuiddityManager::CommandHistory QuiddityManager::get_command_history_from_serialization( const std::string& save) { CommandHistory res; // building the tree auto tree = JSONSerializer::deserialize(save); if (!tree) { g_warning("saved history is malformed"); return res; } // history auto histo_str = std::string("history."); auto commands_paths = tree->get_child_keys(histo_str); for (auto& it : commands_paths) { res.history_.push_back(QuiddityCommand::make_command_from_tree(tree->get_tree(histo_str + it))); } // trees res.quiddities_user_data_ = tree->get_tree("userdata."); res.quiddities_ = tree->get_tree(".quiddities"); res.properties_ = tree->get_tree(".properties"); res.readers_ = tree->get_tree(".readers"); res.custom_states_ = tree->get_tree(".custom_states"); return res; }