Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
A registry that owns and manages objects identified by a UUID. More...
#include <src/utils/uuid_identifiable_object.h>
Public Types | |
using | UuidType = typename UuidIdentifiableObject<BaseT>::Uuid |
using | VariantType = VariantT |
using | BaseType = BaseT |
Public Member Functions | |
OwningObjectRegistry (QObject *parent=nullptr) | |
template<typename CreateType, typename... Args> requires std::derived_from<CreateType, BaseT> | |
auto | create_object (Args &&... args) -> UuidReference< OwningObjectRegistry > |
template<typename CreateType, typename... Args> requires std::derived_from<CreateType, BaseT> | |
auto | clone_object (const CreateType &other, Args &&... args) -> UuidReference< OwningObjectRegistry > |
auto | get_iterator_for_id (const UuidType &id) const |
auto | get_iterator_for_id (const UuidType &id) |
std::optional< std::reference_wrapper< const VariantT > > | find_by_id (const UuidType &id) const |
Returns an object by id. | |
auto & | find_by_id_or_throw (const UuidType &id) const |
bool | contains (const UuidType &id) const |
void | register_object (VariantT obj_ptr) |
Registers an object. | |
template<typename ObjectT> requires std::derived_from<ObjectT, BaseT> | |
void | register_object (ObjectT &obj) |
void | acquire_reference (const UuidType &id) |
void | release_reference (const UuidType &id) |
auto & | get_hash_map () const |
auto | get_uuids () const |
Returns a list of all UUIDs of the objects in the registry. | |
size_t | size () const |
Friends | |
void | to_json (nlohmann::json &j, const OwningObjectRegistry &obj) |
template<ObjectBuilder BuilderT> | |
void | from_json_with_builder (const nlohmann::json &j, OwningObjectRegistry &obj, const BuilderT &builder) |
A registry that owns and manages objects identified by a UUID.
This class provides methods to register, unregister, and find objects by their UUID. When an object is registered, this class takes ownership of it and sets the parent to this
. When an object is unregistered, the ownership is released and the caller is responsible for deleting the object.
Intended to be used with variants of pointers to QObjects.
VariantT | A variant of raw pointers to QObject-derived classes. |
BaseT | The common base class of the objects in the variant. |
Definition at line 276 of file uuid_identifiable_object.h.
using zrythm::utils::OwningObjectRegistry< VariantT, BaseT >::BaseType = BaseT |
Definition at line 281 of file uuid_identifiable_object.h.
using zrythm::utils::OwningObjectRegistry< VariantT, BaseT >::UuidType = typename UuidIdentifiableObject<BaseT>::Uuid |
Definition at line 279 of file uuid_identifiable_object.h.
using zrythm::utils::OwningObjectRegistry< VariantT, BaseT >::VariantType = VariantT |
Definition at line 280 of file uuid_identifiable_object.h.
|
inline |
Definition at line 283 of file uuid_identifiable_object.h.
|
inline |
Definition at line 393 of file uuid_identifiable_object.h.
|
inline |
Definition at line 310 of file uuid_identifiable_object.h.
|
inline |
Definition at line 359 of file uuid_identifiable_object.h.
|
inline |
Definition at line 287 of file uuid_identifiable_object.h.
|
inline |
Returns an object by id.
Definition at line 338 of file uuid_identifiable_object.h.
|
inline |
Definition at line 348 of file uuid_identifiable_object.h.
|
inline |
Definition at line 408 of file uuid_identifiable_object.h.
|
inline |
Definition at line 326 of file uuid_identifiable_object.h.
|
inline |
Definition at line 320 of file uuid_identifiable_object.h.
|
inline |
Returns a list of all UUIDs of the objects in the registry.
Definition at line 413 of file uuid_identifiable_object.h.
|
inline |
Definition at line 387 of file uuid_identifiable_object.h.
|
inline |
Registers an object.
This takes ownership of the object.
Definition at line 370 of file uuid_identifiable_object.h.
|
inline |
Definition at line 399 of file uuid_identifiable_object.h.
|
inline |
Definition at line 421 of file uuid_identifiable_object.h.
|
friend |
Definition at line 433 of file uuid_identifiable_object.h.
|
friend |
Definition at line 423 of file uuid_identifiable_object.h.