Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
project_registry.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3#pragma once
4
5#include <memory>
6
7#include "utils/iobject_registry.h"
8
9#include <nlohmann/json_fwd.hpp>
10
11namespace zrythm::plugins
12{
13class PluginFactory;
14}
15namespace zrythm::structure::tracks
16{
17class TrackFactory;
18}
19namespace zrythm::structure::arrangement
20{
22}
23
24namespace zrythm::structure::project
25{
26
27class ProjectRegistry final : public QObject, public utils::IObjectRegistry
28{
29 Q_OBJECT
30 Q_DISABLE_COPY_MOVE (ProjectRegistry)
31
32public:
34 {
36 structure::arrangement::ArrangerObjectFactory &arranger_object_factory;
37 plugins::PluginFactory &plugin_factory;
38 };
39
40 ProjectRegistry (QObject * parent = nullptr);
41 ~ProjectRegistry () override;
42
43 void set_deserialization_dependencies (DeserializationDependencies deps);
44
45private:
46 using ObjectVisitor = utils::IObjectRegistry::ObjectVisitor;
47
48 void register_object_impl (utils::UuidIdentifiableBase &obj) override;
49 void acquire_reference_impl (const QUuid &id) override;
50 void release_reference_impl (const QUuid &id) override;
51
52 [[gnu::hot]] utils::UuidIdentifiableBase *
53 find_by_raw_uuid_impl (const QUuid &id) const override;
54
55 bool contains_impl (const QUuid &id) const override;
56
57 void
58 for_each_matching_impl (const QMetaObject &meta_type, ObjectVisitor visitor)
59 const override;
60
61 void delete_object_by_id (const QUuid &id);
62
63 // ============================================================================
64 // Serialization
65 // ============================================================================
66
67 friend void to_json (nlohmann::json &j, const ProjectRegistry &registry);
68 friend void from_json (const nlohmann::json &j, ProjectRegistry &registry);
69
70private:
71 struct Impl;
72 bool destroying_ = false;
73 std::unique_ptr<Impl> impl_;
74};
75
76} // namespace zrythm::structure::project
Abstract interface for a UUID-keyed object registry.
QObject-based base for all UUID-identifiable objects.