Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
uuid_identifiable.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3#pragma once
4
5#include <QObject>
6#include <QUuid>
7
8#include <boost/describe/class.hpp>
9#include <nlohmann/json_fwd.hpp>
10
11namespace zrythm::utils
12{
13
26class UuidIdentifiableBase : public QObject
27{
28 Q_OBJECT
29
30public:
31 explicit UuidIdentifiableBase (QObject * parent = nullptr)
32 : QObject (parent), uuid_ (QUuid::createUuid ())
33 {
34 }
35 UuidIdentifiableBase (const QUuid &id, QObject * parent = nullptr)
36 : QObject (parent), uuid_ (id)
37 {
38 }
39
40 Q_DISABLE_COPY_MOVE (UuidIdentifiableBase)
41 ~UuidIdentifiableBase () override = default;
42
43 QUuid raw_uuid () const { return uuid_; }
44
45 friend bool
46 operator== (const UuidIdentifiableBase &lhs, const UuidIdentifiableBase &rhs)
47 {
48 return lhs.uuid_ == rhs.uuid_;
49 }
50
51 friend void to_json (nlohmann::json &j, const UuidIdentifiableBase &obj);
52 friend void from_json (const nlohmann::json &j, UuidIdentifiableBase &obj);
53
54protected:
55 void set_raw_uuid (const QUuid &id) { uuid_ = id; }
56
57private:
58 QUuid uuid_;
59
60 BOOST_DESCRIBE_CLASS (UuidIdentifiableBase, (), (), (), (uuid_))
61};
62
63} // namespace zrythm::utils
String utilities.