Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_span.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "plugins/plugin_all.h"
7#include "utils/uuid_identifiable_object.h"
8
13 : public utils::UuidIdentifiableObjectView<plugins::PluginRegistry>
14{
15public:
17 using VariantType = typename Base::VariantType;
18 using PluginUuid = typename Base::UuidType;
19 using Base::Base; // Inherit constructors
20
21 static auto name_projection (const VariantType &pl_var)
22 {
23 return std::visit ([] (const auto &pl) { return pl->get_name (); }, pl_var);
24 }
25 static auto visible_projection (const VariantType &pl_var)
26 {
27 return std::visit ([] (const auto &pl) { return pl->uiVisible (); }, pl_var);
28 }
29 static auto state_dir_projection (const VariantType &pl_var)
30 {
31 return std::visit (
32 [] (auto &&pl) { return pl->get_state_directory (); }, pl_var);
33 }
34 static auto instantiation_failed_projection (const VariantType &pl_var)
35 {
36 return std::visit (
37 [] (const auto &pl) {
38 return pl->instantiationStatus ()
40 },
41 pl_var);
42 }
43
44 bool contains_uninstantiated_due_to_failure () const
45 {
46 return !std::ranges::all_of (*this, instantiation_failed_projection);
47 }
48
56 std::vector<VariantType> create_snapshots (QObject &owner) const
57 {
58 // TODO
59 return {};
60#if 0
61 return std::ranges::to<std::vector> (
62 *this | std::views::transform ([&] (const auto &plugin_var) {
63 return std::visit (
64 [&] (auto &&pl) -> VariantType {
65 return utils::clone_qobject (*pl, &owner);
66 },
67 plugin_var);
68 }));
69#endif
70 }
71
75 bool can_be_pasted (const plugins::PluginSlot &slot) const;
76};
77
78static_assert (std::ranges::random_access_range<PluginSpan>);
Span of plugins that offers helper methods.
Definition plugin_span.h:14
bool can_be_pasted(const plugins::PluginSlot &slot) const
Returns whether the plugins can be pasted to the given slot.
std::vector< VariantType > create_snapshots(QObject &owner) const
Creates a snapshot of the plugin collection.
Definition plugin_span.h:56
A unified view over UUID-identified objects that supports: