Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::utils::UuidIdentifiableObject< Derived > Class Template Reference

CRTP base that adds a typed UUID strong-typedef to a class hierarchy. More...

#include <src/utils/uuid_identifiable_object.h>

Inheritance diagram for zrythm::utils::UuidIdentifiableObject< Derived >:
Collaboration diagram for zrythm::utils::UuidIdentifiableObject< Derived >:

Data Structures

struct  Uuid

Public Types

using uuid_base_type = Derived
 Exposes the CRTP parameter for concept checking.

Public Member Functions

 UuidIdentifiableObject (QObject *parent=nullptr)
 UuidIdentifiableObject (const Uuid &id, QObject *parent=nullptr)
auto get_uuid () const
Public Member Functions inherited from zrythm::utils::UuidIdentifiableBase
 UuidIdentifiableBase (QObject *parent=nullptr)
 UuidIdentifiableBase (const QUuid &id, QObject *parent=nullptr)
QUuid raw_uuid () const

Friends

void init_from (UuidIdentifiableObject &obj, const UuidIdentifiableObject &other, utils::ObjectCloneType clone_type)
void to_json (nlohmann::json &j, const UuidIdentifiableObject &obj)
void from_json (const nlohmann::json &j, UuidIdentifiableObject &obj)
bool operator== (const UuidIdentifiableObject &lhs, const UuidIdentifiableObject &rhs)

Additional Inherited Members

Protected Member Functions inherited from zrythm::utils::UuidIdentifiableBase
void set_raw_uuid (const QUuid &id)

Detailed Description

template<typename Derived>
class zrythm::utils::UuidIdentifiableObject< Derived >

CRTP base that adds a typed UUID strong-typedef to a class hierarchy.

Each distinct "family" of objects (e.g., Track, ArrangerObject, Plugin) should have ONE class that inherits from UuidIdentifiableObject<ThatClass>. Derived types (e.g., MidiTrack from Track) inherit the UUID through the base — they must NOT inherit from UuidIdentifiableObject again, since each object has exactly one UUID identity.

The uuid_base_type alias exposes the CRTP parameter so the UuidIdentifiable concept can verify the inheritance chain structurally (no duck-typing).

Inherits UuidIdentifiableBase (which is a QObject), so derived types do NOT need to inherit QObject separately.

Example: class Track : public UuidIdentifiableObject<Track> { ... }; class MidiTrack : public Track { ... }; // inherits Track's UUID

Template Parameters
DerivedThe class at the top of the hierarchy that "owns" the UUID type.

Definition at line 41 of file uuid_identifiable_object.h.

Member Typedef Documentation

◆ uuid_base_type

template<typename Derived>
using zrythm::utils::UuidIdentifiableObject< Derived >::uuid_base_type = Derived

Exposes the CRTP parameter for concept checking.

Definition at line 45 of file uuid_identifiable_object.h.

Constructor & Destructor Documentation

◆ UuidIdentifiableObject() [1/2]

template<typename Derived>
zrythm::utils::UuidIdentifiableObject< Derived >::UuidIdentifiableObject ( QObject * parent = nullptr)
inlineexplicit

Definition at line 76 of file uuid_identifiable_object.h.

◆ UuidIdentifiableObject() [2/2]

template<typename Derived>
zrythm::utils::UuidIdentifiableObject< Derived >::UuidIdentifiableObject ( const Uuid & id,
QObject * parent = nullptr )
inline

Definition at line 80 of file uuid_identifiable_object.h.

Member Function Documentation

◆ get_uuid()

template<typename Derived>
auto zrythm::utils::UuidIdentifiableObject< Derived >::get_uuid ( ) const
inline

Definition at line 88 of file uuid_identifiable_object.h.

◆ from_json

template<typename Derived>
void from_json ( const nlohmann::json & j,
UuidIdentifiableObject< Derived > & obj )
friend

Definition at line 109 of file uuid_identifiable_object.h.

◆ init_from

template<typename Derived>
void init_from ( UuidIdentifiableObject< Derived > & obj,
const UuidIdentifiableObject< Derived > & other,
utils::ObjectCloneType clone_type )
friend

Definition at line 90 of file uuid_identifiable_object.h.

◆ operator==

template<typename Derived>
bool operator== ( const UuidIdentifiableObject< Derived > & lhs,
const UuidIdentifiableObject< Derived > & rhs )
friend

Definition at line 114 of file uuid_identifiable_object.h.

◆ to_json

template<typename Derived>
void to_json ( nlohmann::json & j,
const UuidIdentifiableObject< Derived > & obj )
friend

Definition at line 105 of file uuid_identifiable_object.h.


The documentation for this class was generated from the following file: