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 bool operator!=(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:613
GobjHandle & operator=(const GobjHandle &gobj)
Definition: gobj_handle.h:244
This is a handle for managing the reference count of GObjects.
Definition: gobj_handle.h:148
GobjWeakHandle & operator=(const GobjHandle< T > &gobj) noexcept
Definition: gobj_handle.h:502
T & operator*() const noexcept
Definition: gobj_handle.h:298
~GobjHandle()
Definition: gobj_handle.h:319
void reset(T *ptr=0)
Definition: gobj_handle.h:194
GobjHandle(T *ptr=0) noexcept
Definition: gobj_handle.h:170
GobjHandle(GobjHandle &&gobj) noexcept
Definition: gobj_handle.h:220
bool valid() const noexcept
Definition: gobj_handle.h:534
Definition: gobj_handle.h:422
bool operator==(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:600
A specialization of std::hash for Cgu::Callback::FunctorArg, Cgu::Callback::SafeFunctorArg, Cgu::GobjHandle, Cgu::GvarHandle, Cgu::IntrusivePtr, Cgu::SharedHandle, Cgu::SharedLockHandle, Cgu::SharedPtr and Cgu::SharedLockPtr so that such objects may be keys of unordered associative containers.
virtual const char * what() const
Definition: gobj_handle.h:423
GobjWeakHandle(T *ptr=0) noexcept
Definition: gobj_handle.h:436
GobjWeakHandle(const GobjWeakHandle &gobj) noexcept
Definition: gobj_handle.h:463
GobjWeakHandle & operator=(const GobjWeakHandle &gobj) noexcept
Definition: gobj_handle.h:489
T * operator->() const
Definition: gobj_handle.h:567
Definition: application.h:44
~GobjWeakHandle()
Definition: gobj_handle.h:583
T & operator*() const
Definition: gobj_handle.h:556
GobjHandle & operator=(GobjHandle &&gobj)
Definition: gobj_handle.h:272
GobjHandle(const GobjHandle &gobj) noexcept
Definition: gobj_handle.h:211
This is a handle for managing weak references to GObjects.
Definition: gobj_handle.h:426
void reset(T *ptr=0) noexcept
Definition: gobj_handle.h:448
GobjWeakHandle(const GobjHandle< T > &gobj) noexcept
Definition: gobj_handle.h:475
T * operator->() const noexcept
Definition: gobj_handle.h:305