Louvre
v2.12.0-1
C++ library for Wayland compositors
|
Weak reference to an LObject. More...
Public Types | |
using | OnDestroyCallback = std::function< void(T *)> |
Public Member Functions | |
LWeak () noexcept=default | |
Creates an empty LWeak. More... | |
LWeak (T *object) noexcept | |
Creates a reference for the given LObject, or initializes an empty LWeak if nullptr is passed. More... | |
~LWeak () noexcept | |
Destructor, removes the LWeak from the LObject references. More... | |
LWeak (const LWeak< T > &other) noexcept | |
Copy constructor, assigns the LObject of another LWeak. More... | |
LWeak< T > & | operator= (const LWeak< T > &other) noexcept |
Assignment operator, assigns the LObject of another LWeak. More... | |
T * | get () const noexcept |
Gets a pointer to the LObject or nullptr if not set or the object has been destroyed. More... | |
operator T* () const noexcept | |
Implicit conversion to raw pointer. More... | |
T * | operator-> () const noexcept |
Access underlying object via pointer semantics. More... | |
UInt64 | count () const noexcept |
Return the number of existing references to the current LObject. More... | |
void | reset (T *object=nullptr) noexcept |
Replace the reference with another object. More... | |
void | setOnDestroyCallback (const OnDestroyCallback &callback) noexcept |
Set the onDestroy callback function. More... | |
Weak reference to an LObject.
The LWeak class template provides a mechanism for creating weak pointer references to subclasses of LObject.
It is conceptually similar to std::weak_ptr
but is specifically tailored for LObject subclasses, avoiding the pointer indirection and associated performance overhead of the std::weak_ptr
thread-safe mechanisms.
When the object being referenced is destroyed, an optional on destroy callback event is emitted, and get() returns nullptr
.
using OnDestroyCallback = std::function<void(T*)> |
Callback function type used to handle the OnDestroy()
event.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Implicit conversion to raw pointer.
Provides access to the underlying raw pointer through an implicit conversion.
|
inlinenoexcept |
Access underlying object via pointer semantics.
Allows accessing members of the underlying object using pointer semantics.
|
inlinenoexcept |
|
inlinenoexcept |
Replace the reference with another object.
object | The LObject to set as the new reference, or nullptr to unset the reference. |
|
inlinenoexcept |
Set the onDestroy callback function.
callback | The callback function to be called when the referenced object is destroyed. Passing nullptr disables the callback. |