Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::utils::TypedUuidReference< T > Class Template Reference

Typed, reference-counted UUID reference into an IObjectRegistry. More...

#include <src/utils/typed_uuid_reference.h>

Public Types

using UuidType = typename T::Uuid

Public Member Functions

 TypedUuidReference (const UuidType &id, IObjectRegistry &registry)
 TypedUuidReference (IObjectRegistry &registry)
 TypedUuidReference (const TypedUuidReference &other)=default
TypedUuidReference & operator= (const TypedUuidReference &other)=default
 TypedUuidReference (TypedUuidReference &&other) noexcept=default
TypedUuidReference & operator= (TypedUuidReference &&other) noexcept=default
template<UuidIdentifiable U>
 TypedUuidReference (const TypedUuidReference< U > &other)
UuidType id () const
void set_id (const UuidType &id)
T * get () const
template<typename DerivedT>
DerivedT * get_object_as () const
UuidIdentifiableBaseget_object_base () const
T * get_or_throw () const
bool has_value () const
IObjectRegistryget_registry () const
const UuidReferenceas_untyped () const

Friends

void to_json (nlohmann::json &j, const TypedUuidReference &ref)
void from_json (const nlohmann::json &j, TypedUuidReference &ref)
auto format_as (const TypedUuidReference &ref)

Detailed Description

template<UuidIdentifiable T>
class zrythm::utils::TypedUuidReference< T >

Typed, reference-counted UUID reference into an IObjectRegistry.

Wraps UuidReference and adds type safety. Holds the typed UUID (typename T::Uuid) and resolves to T* via qobject_cast. Works for both base types (e.g., TypedUuidReference<Track>) and concrete derived types (e.g., TypedUuidReference<MidiTrack>) — the only difference is which qobject_cast is performed on lookup.

T must satisfy the UuidIdentifiable concept (i.e., inherit from a UuidIdentifiableObject for some U, and be a QObject).

Use as_untyped() to access the underlying UuidReference when the typed interface is not needed (e.g., for storage in heterogeneous containers).

Definition at line 29 of file typed_uuid_reference.h.

Member Typedef Documentation

◆ UuidType

template<UuidIdentifiable T>
using zrythm::utils::TypedUuidReference< T >::UuidType = typename T::Uuid

Definition at line 32 of file typed_uuid_reference.h.

Constructor & Destructor Documentation

◆ TypedUuidReference() [1/3]

template<UuidIdentifiable T>
zrythm::utils::TypedUuidReference< T >::TypedUuidReference ( const UuidType & id,
IObjectRegistry & registry )
inline

Definition at line 36 of file typed_uuid_reference.h.

◆ TypedUuidReference() [2/3]

template<UuidIdentifiable T>
zrythm::utils::TypedUuidReference< T >::TypedUuidReference ( IObjectRegistry & registry)
inline

Definition at line 41 of file typed_uuid_reference.h.

◆ TypedUuidReference() [3/3]

template<UuidIdentifiable T>
template<UuidIdentifiable U>
zrythm::utils::TypedUuidReference< T >::TypedUuidReference ( const TypedUuidReference< U > & other)
inline

Definition at line 50 of file typed_uuid_reference.h.

Member Function Documentation

◆ as_untyped()

template<UuidIdentifiable T>
const UuidReference & zrythm::utils::TypedUuidReference< T >::as_untyped ( ) const
inline

Definition at line 89 of file typed_uuid_reference.h.

◆ get()

template<UuidIdentifiable T>
T * zrythm::utils::TypedUuidReference< T >::get ( ) const
inline

Definition at line 59 of file typed_uuid_reference.h.

◆ get_object_as()

template<UuidIdentifiable T>
template<typename DerivedT>
DerivedT * zrythm::utils::TypedUuidReference< T >::get_object_as ( ) const
inline

Definition at line 67 of file typed_uuid_reference.h.

◆ get_object_base()

template<UuidIdentifiable T>
UuidIdentifiableBase * zrythm::utils::TypedUuidReference< T >::get_object_base ( ) const
inline

Definition at line 72 of file typed_uuid_reference.h.

◆ get_or_throw()

template<UuidIdentifiable T>
T * zrythm::utils::TypedUuidReference< T >::get_or_throw ( ) const
inline

Definition at line 74 of file typed_uuid_reference.h.

◆ get_registry()

template<UuidIdentifiable T>
IObjectRegistry & zrythm::utils::TypedUuidReference< T >::get_registry ( ) const
inline

Definition at line 87 of file typed_uuid_reference.h.

◆ has_value()

template<UuidIdentifiable T>
bool zrythm::utils::TypedUuidReference< T >::has_value ( ) const
inline

Definition at line 85 of file typed_uuid_reference.h.

◆ id()

template<UuidIdentifiable T>
UuidType zrythm::utils::TypedUuidReference< T >::id ( ) const
inline

Definition at line 55 of file typed_uuid_reference.h.

◆ set_id()

template<UuidIdentifiable T>
void zrythm::utils::TypedUuidReference< T >::set_id ( const UuidType & id)
inline

Definition at line 57 of file typed_uuid_reference.h.

◆ format_as

template<UuidIdentifiable T>
auto format_as ( const TypedUuidReference< T > & ref)
friend

Definition at line 100 of file typed_uuid_reference.h.

◆ from_json

template<UuidIdentifiable T>
void from_json ( const nlohmann::json & j,
TypedUuidReference< T > & ref )
friend

Definition at line 95 of file typed_uuid_reference.h.

◆ to_json

template<UuidIdentifiable T>
void to_json ( nlohmann::json & j,
const TypedUuidReference< T > & ref )
friend

Definition at line 91 of file typed_uuid_reference.h.


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