HikoGUI
A low latency retained GUI
|
#include <hikogui/observer/group_ptr.hpp>
Public Types | |
using | notify_proto = T::_enable_group_ptr_notify_proto |
using | element_type = T |
Public Member Functions | |
virtual | ~group_ptr () |
Destroy this group_ptr . | |
group_ptr (group_ptr const &other) noexcept | |
Copy construct from another group_ptr . | |
group_ptr & | operator= (group_ptr const &other) noexcept |
Copy assign from another group_ptr . | |
group_ptr (group_ptr &&other) noexcept | |
Move construct from another group_ptr . | |
group_ptr & | operator= (group_ptr &&other) noexcept |
Move assign from another group_ptr . | |
constexpr | group_ptr () noexcept=default |
Construct an empty group_ptr. | |
constexpr | group_ptr (std::nullptr_t) noexcept |
Construct an empty group_ptr. | |
void | reset () noexcept |
Reset the group_ptr and make it empty. | |
template<forward_of< std::shared_ptr< enable_group_ptr< T, notify_proto > > > Ptr> | |
group_ptr (Ptr &&ptr) noexcept | |
Construct a group_ptr from a shared_ptr. | |
template<forward_of< std::shared_ptr< enable_group_ptr< T, notify_proto > > > Ptr> | |
group_ptr & | operator= (Ptr &&ptr) noexcept |
Construct a group_ptr from a shared_ptr. | |
T * | get () const noexcept |
Get the pointer to the object that this group_ptr owns. | |
T * | operator-> () const noexcept |
Dereference to member of the object that is owned by this group_ptr . | |
T & | operator* () const noexcept |
Dereference the object that is owned by this group_ptr . | |
operator bool () const noexcept | |
Check if this group_ptr is not empty. | |
template<forward_of< notify_proto > Func> | |
void | subscribe (Func &&func) noexcept |
Subscribe a callback function. | |
void | unsubscribe () noexcept |
Unsubscribe the callback function. | |
Friends | |
class | enable_group_ptr< T, notify_proto > |
A smart pointer which manages ownership as a group.
When group_ptr
s are assigned to one another they will act as a group from this point forward. When a std::shared_ptr
is as assigned to a group_ptr
it will now be assigned to each group_ptr
in this group.
You can unlink a group_ptr
from others in the group only by reset()
, assigning an empty std::shared_ptr
, assigning a nullptr or move-assignment/construction.
|
inlinevirtual |
Destroy this group_ptr
.
|
inlinenoexcept |
Copy construct from another group_ptr
.
This function will:
std::shared_ptr
from other.other | The other group_ptr to copy. |
|
inlinenoexcept |
Move construct from another group_ptr
.
This function will:
std::shared_ptr
from other.other | The other group_ptr to copy. |
|
constexprdefaultnoexcept |
Construct an empty group_ptr.
|
inlineconstexprnoexcept |
Construct an empty group_ptr.
|
inlinenoexcept |
Construct a group_ptr from a shared_ptr.
ptr | An object that is convertible to a std::shared_ptr pointing to and object that is compatible with this group_ptr . |
This function will not reset the subscription of a callback.
|
inlinenoexcept |
|
inlineexplicitnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Move assign from another group_ptr
.
If other is non-empty this function will:
If other is empty this function will:
other | The other group_ptr to copy. |
|
inlinenoexcept |
Copy assign from another group_ptr
.
If other is non-empty this function will:
If other is empty this function will:
other | The other group_ptr to copy. |
|
inlinenoexcept |
Construct a group_ptr from a shared_ptr.
ptr | An object that is convertible to a std::shared_ptr pointing to and object that is compatible with this group_ptr . If the shared_ptr is empty it will perform the same function as reset() . |
This function will not reset the subscription of a callback.
|
inlinenoexcept |
|
inlinenoexcept |
Subscribe a callback function.
The subscribed callback function can be called by the notify_group_ptr()
function of the object that is owned by the group_ptr
.
Only a single function can be subscribed. This function will overwrite a previous subscribed function.
func | A function object corresponding to the notify_proto prototype. |
|
inlinenoexcept |
Unsubscribe the callback function.