Go to the documentation of this file.
39 #ifndef CGU_GOBJ_HANDLE_H
40 #define CGU_GOBJ_HANDLE_H
46 #include <glib-object.h>
153 if (obj_p) g_object_unref(obj_p);
156 void reference() noexcept {
157 if (obj_p) g_object_ref(obj_p);
175 if (ptr && g_object_is_floating(ptr)) {
176 g_object_ref_sink(ptr);
201 if (ptr && g_object_is_floating(ptr)) {
202 g_object_ref_sink(ptr);
249 if (obj_p != gobj.obj_p) {
292 T*
get() const noexcept {
return obj_p;}
312 operator T*()
const noexcept {
return obj_p;}
423 virtual const char*
what()
const throw() {
return "GobjWeakHandleError\n";}
438 if (ptr) g_object_add_weak_pointer((GObject*)ptr,
450 if (obj_p) g_object_remove_weak_pointer((GObject*)obj_p,
453 if (ptr) g_object_add_weak_pointer((GObject*)ptr,
465 if (obj_p) g_object_add_weak_pointer((GObject*)obj_p,
477 if (obj_p) g_object_add_weak_pointer((GObject*)obj_p,
513 operator bool() const noexcept {
return obj_p;}
515 #ifndef DOXYGEN_PARSING
523 bool expired() const noexcept {
return obj_p;}
534 bool valid() const noexcept {
return obj_p;}
587 #if defined(CGU_USE_SMART_PTR_COMPARISON) || defined(DOXYGEN_PARSING)
601 return (h1.get() == h2.get());
633 return std::less<T*>()(h1.
get(), h2.
get());
636 #endif // CGU_USE_SMART_PTR_COMPARISON
643 #if defined(CGU_USE_SMART_PTR_COMPARISON) && !defined(DOXYGEN_PARSING)
648 struct hash<
Cgu::GobjHandle<T>> {
649 typedef std::size_t result_type;
651 result_type operator()(
const argument_type& h)
const {
659 #endif // CGU_USE_SMART_PTR_COMPARISON
T & operator*() const
Definition: gobj_handle.h:556
Definition: application.h:44
T & operator*() const noexcept
Definition: gobj_handle.h:298
This is a handle for managing the reference count of GObjects.
Definition: gobj_handle.h:148
T * get() const
Definition: gobj_handle.h:545
GobjWeakHandle & operator=(const GobjHandle< T > &gobj) noexcept
Definition: gobj_handle.h:502
GobjWeakHandle(const GobjHandle< T > &gobj) noexcept
Definition: gobj_handle.h:475
Definition: gobj_handle.h:422
void reset(T *ptr=0)
Definition: gobj_handle.h:194
GobjHandle(T *ptr=0) noexcept
Definition: gobj_handle.h:170
bool valid() const noexcept
Definition: gobj_handle.h:534
bool operator<(const GobjHandle< T > &h1, const GobjHandle< T > &h2)
Definition: gobj_handle.h:632
bool operator!=(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:613
GobjHandle(GobjHandle &&gobj) noexcept
Definition: gobj_handle.h:220
GobjWeakHandle(T *ptr=0) noexcept
Definition: gobj_handle.h:436
bool operator==(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:600
GobjWeakHandle(const GobjWeakHandle &gobj) noexcept
Definition: gobj_handle.h:463
~GobjWeakHandle()
Definition: gobj_handle.h:583
void reset(T *ptr=0) noexcept
Definition: gobj_handle.h:448
A specialization of std::hash for Cgu::Callback::FunctorArg, Cgu::Callback::SafeFunctorArg,...
GobjWeakHandle & operator=(const GobjWeakHandle &gobj) noexcept
Definition: gobj_handle.h:489
GobjHandle & operator=(GobjHandle &&gobj)
Definition: gobj_handle.h:272
This is a handle for managing weak references to GObjects.
Definition: gobj_handle.h:426
GobjHandle(const GobjHandle &gobj) noexcept
Definition: gobj_handle.h:211
T * operator->() const noexcept
Definition: gobj_handle.h:305
T * operator->() const
Definition: gobj_handle.h:567
GobjHandle & operator=(const GobjHandle &gobj)
Definition: gobj_handle.h:244
T * get() const noexcept
Definition: gobj_handle.h:292
virtual const char * what() const
Definition: gobj_handle.h:423
~GobjHandle()
Definition: gobj_handle.h:319