c++-gtk-utils
gobj_handle.h
Go to the documentation of this file.
1 /* Copyright (C) 2005 to 2013 Chris Vine
2 
3 The library comprised in this file or of which this file is part is
4 distributed by Chris Vine under the GNU Lesser General Public
5 License as follows:
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public License
9  as published by the Free Software Foundation; either version 2.1 of
10  the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License, version 2.1, for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License, version 2.1, along with this library (see the file LGPL.TXT
19  which came with this source code package in the c++-gtk-utils
20  sub-directory); if not, write to the Free Software Foundation, Inc.,
21  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 
23 However, it is not intended that the object code of a program whose
24 source code instantiates a template from this file or uses macros or
25 inline functions (of any length) should by reason only of that
26 instantiation or use be subject to the restrictions of use in the GNU
27 Lesser General Public License. With that in mind, the words "and
28 macros, inline functions and instantiations of templates (of any
29 length)" shall be treated as substituted for the words "and small
30 macros and small inline functions (ten lines or less in length)" in
31 the fourth paragraph of section 5 of that licence. This does not
32 affect any other reason why object code may be subject to the
33 restrictions in that licence (nor for the avoidance of doubt does it
34 affect the application of section 2 of that licence to modifications
35 of the source code in this file).
36 
37 */
38 
39 #ifndef CGU_GOBJ_HANDLE_H
40 #define CGU_GOBJ_HANDLE_H
41 
42 #include <exception>
43 #include <functional> // for std::less
44 
45 #include <glib-object.h>
46 
48 
49 /**
50  * @addtogroup handles handles and smart pointers
51  */
52 
53 namespace Cgu {
54 
55 /**
56  * @class GobjHandle gobj_handle.h c++-gtk-utils/gobj_handle.h
57  * @brief This is a handle for managing the reference count of
58  * GObjects.
59  * @ingroup handles
60  * @sa MainWidgetBase GobjWeakHandle
61  *
62  * This is a class which manages the reference count of GObjects. It
63  * does not maintain its own reference count, but interfaces with that
64  * kept by the glib object system.
65  *
66  * GobjHandles are most useful to manage GObjects which are not also
67  * GtkWidgets or GInitiallyUnowned objects - GtkWidgets and
68  * GInitiallyUnowned objects have initial floating references which
69  * will result in them being automatically managed by the container in
70  * which they are held. Nonetheless, GobjHandles can be used to hold
71  * GtkWidgets and GInitiallyUnowned objects, as the constructor of a
72  * GobjHandle which takes a pointer will automatically take ownership
73  * of a newly created GtkWidget or GInitiallyUnowned object, by
74  * calling g_object_ref_sink(). Plain GObjects do not need to be sunk
75  * to be owned by the GobjHandle.
76  *
77  * Note that g_object_ref_sink() is not called by the constructor
78  * taking a pointer if the floating reference has already been sunk,
79  * so if that constructor is passed an object already owned by a GTK+
80  * container it will be necessary to call g_object_ref() on it
81  * explicitly. This behaviour will ensure that the handle behaves the
82  * same whether it is holding a plain GObject, or it is holding a
83  * GInitiallyUnowned/GtkWidget object. Generally however, where an
84  * object is already owned by a container, the object should be passed
85  * by another handle - ie by the copy constructor (or by the
86  * assignment operator), as those always increment the reference count
87  * automatically.
88  *
89  * In other words, invoke the constructor taking a pointer only with a
90  * newly created object (whether a GObject, GInitiallyUnowned or
91  * GtkWidget object), and everything else will take care of itself. In
92  * this respect, GobjHandles work the same way as conventional shared
93  * pointer implementations managing objects allocated on free store.
94  * The same applies to the reset() method. (Care is required however
95  * if initializing a Cgu::GobjHandle with a widget or GObject object
96  * obtained from GtkBuilder, since these are not "newly created" in
97  * this sense. It is necessary to call g_object_ref() by hand in that
98  * case, since GtkBuilder does not by itself pass ownership of any
99  * objects it creates.)
100  *
101  * Because any GTK+ containers themselves increment the reference
102  * count of a GObject or GtkWidget where they need to take ownership,
103  * an already-managed object held by a GobjHandle can safely be passed
104  * by pointer to a GTK+ container, and that is one of the intended
105  * usages. For that purpose, although the class has operator*() and
106  * operator->() dereferencing operators, and so has normal smart
107  * pointer functionality, as it is intended for use with the normal C
108  * GObject/pango/GTK+ interfaces, ordinary use would involve passing
109  * the handle to a function taking a pointer by means of the
110  * operatorT*() type conversion operator (which returns the underlying
111  * pointer), or by explicitly calling the get() method to obtain the
112  * underlying pointer.
113  *
114  * The principal intended usage of GobjHandle is to automatically
115  * handle GObject reference counts and therefore to make GObjects
116  * exception-safe, but they also permit GObjects/GtkWidgets to be kept
117  * in standard C++ containers.
118  *
119  * As of glib-2.8, g_object_ref() and g_object_unref() are thread
120  * safe, so with glib-2.8 or greater there can be different GobjHandle
121  * instances in different threads referencing the same GObject object.
122  * Of course, if that is done, this does not affect the need (or
123  * otherwise) in the particular use in question to lock anything other
124  * than the reference count - say when accessing the referenced object
125  * itself in different threads.
126  *
127  * From version 1.2.12, the library provides ==, != and < comparison
128  * operators for GobjHandles, but only if the library is compiled with
129  * the \--with-smart-ptr-comp option, or if the user code defines the
130  * symbol CGU_USE_SMART_PTR_COMPARISON before gobj_handle.h is first
131  * parsed. This is because, if user code has provided such operators
132  * for these smart pointers itself, a duplicated function definition
133  * would arise.
134  *
135  * Typical usage might be, for example, as follows:
136  *
137  * @code
138  * using namespace Cgu;
139  * GobjHandle<GtkListStore> store(gtk_list_store_new(1, G_TYPE_STRING));
140  *
141  * [ ... fill the list store ... ]
142  *
143  * GobjHandle<GtkWidget> view(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store.get()));
144  * // 'view' will take sole ownership of the list store when 'store' goes out of scope, or
145  * // 'store' could be kept alive so that the list store will survive removal from the view
146  *
147  * [ ... set up an interface including a GtkVBox 'vbox' which will hold the tree view ... ]
148  *
149  * gtk_container_add(GTK_CONTAINER(vbox), view);
150  * // 'vbox' will take sole ownership of the tree view when 'view' goes out of scope, or
151  * // 'view' could be kept alive so that the tree view will survive removal from the vbox
152  * @endcode
153  */
154 
155 template <class T> class GobjHandle {
156 
157  T* obj_p;
158 
159  void unreference() {
160  if (obj_p) g_object_unref(obj_p);
161  }
162 
163  void reference() {
164  if (obj_p) g_object_ref(obj_p);
165  }
166 
167 public:
168 
169  /**
170  * The constructor does not throw. g_object_ref_sink() is called if
171  * the managed object has a floating reference.
172  * @param ptr The object which the GobjHandle is to manage (if any).
173  * @note The object passed should not normally be already owned by a
174  * GTK+ container or managed by any other GobjHandle object. If it
175  * is, g_object_ref() must be called explicitly by the user code.
176  */
177  explicit GobjHandle(T* ptr = 0) {
178  obj_p = ptr;
179 
180  // if an object with a floating reference has been passed to this constructor,
181  // take ownership of it
182  if (ptr && g_object_is_floating(ptr)) {
183  g_object_ref_sink(ptr);
184  }
185  }
186 
187  /**
188  * Causes the handle to cease to manage its managed object (if any)
189  * and decrements its reference count, so destroying it if the
190  * reference count thereby becomes 0. If the argument passed is not
191  * NULL, the handle will manage the new object passed and
192  * g_object_ref_sink() is called if the new object has a floating
193  * reference. This method does not throw (unless this method
194  * destroys a sub-classed GObject which has a member object whose
195  * destructor throws).
196  * @param ptr NULL (the default), or a new object to manage.
197  * @note The new object passed should not normally be already owned
198  * by a GTK+ container or managed by any other GobjHandle object. If
199  * it is, g_object_ref() must be called explicitly by the user code.
200  */
201  void reset(T* ptr = 0) {
202 
203  unreference();
204  obj_p = ptr;
205 
206  // if an object with a floating reference has been passed to this method,
207  // take ownership of it
208  if (ptr && g_object_is_floating(ptr)) {
209  g_object_ref_sink(ptr);
210  }
211  }
212 
213  /**
214  * The copy constructor does not throw. It increments the reference
215  * count of the managed object.
216  * @param gobj The handle to be copied.
217  */
218  GobjHandle(const GobjHandle& gobj) {
219  obj_p = gobj.obj_p;
220  reference();
221  }
222 
223  // We don't have a constructor for GobjHandle taking a GobjWeakHandle
224  // object. If we did that, we would have to remove the GobjWeakHandle
225  // constructor taking a pointer so we know that its tracked object
226  // always has an owner when initialising a new GobjHandle with the
227  // GobjWeakHandle, so we can in turn know we can increase the reference
228  // count when initialising the GobjHandle. However, removing that
229  // constructor would be inconsistent with one of the purposes of having
230  // a GobjWeakHandle class. For the same reason, we don't have an
231  // assignment operator for GobjHandle taking such an object.
232  /**
233  * This method decrements the reference count of the former managed
234  * object (if any), so destroying it if the reference count thereby
235  * becomes 0, and increments the reference count of the new managed
236  * object. This method does not throw (unless this method destroys a
237  * sub-classed GObject which has a member object whose destructor
238  * throws).
239  * @param gobj The assignor.
240  * @return The GobjHandle object after assignment.
241  */
243 
244  // check whether we are already referencing this object -
245  // if so make this a null op. This will also deal with
246  // self-assignment
247  if (obj_p != gobj.obj_p) {
248 
249  // first unreference any object referenced by this handle
250  unreference();
251 
252  // now inherit the GObject from the assigning handle
253  // and reference it
254  obj_p = gobj.obj_p;
255  reference();
256  }
257  return *this;
258  }
259 
260  /**
261  * This method does not throw.
262  * @return A pointer to the handled GObject (or NULL if none is
263  * handled).
264  */
265  T* get() const {return obj_p;}
266 
267  /**
268  * This method does not throw.
269  * @return A reference to the handled GObject.
270  */
271  T& operator*() const {return *obj_p;}
272 
273  /**
274  * This method does not throw.
275  * @return A pointer to the handled GObject (or NULL if none is
276  * handled).
277  */
278  T* operator->() const {return obj_p;}
279 
280  /**
281  * This method does not throw.
282  * @return A pointer to the handled GObject (or NULL if none is
283  * handled).
284  */
285  operator T*() const {return obj_p;}
286 
287  /**
288  * The destructor does not throw. It decrements the reference count
289  * of the managed object (if any), so destroying it if the reference
290  * count thereby becomes 0.
291  */
292  ~GobjHandle() {unreference();}
293 };
294 
295 /**
296  * @class GobjWeakHandle gobj_handle.h c++-gtk-utils/gobj_handle.h
297  * @brief This is a handle for managing weak references to GObjects.
298  * @ingroup handles
299  * @sa GobjHandle
300  *
301  * This class tracks a GObject, so that if that GObject no longer
302  * exists then operator bool() or the valid() method will return
303  * false, but does not take a strong reference by incrementing the
304  * reference count to the GObject and so take ownership of it. It has
305  * two main use areas: first, in order to break reference cycles that
306  * may otherwise arise if two classes would otherwise hold strong
307  * references to each other. Secondly, to manage a pointer to a
308  * GObject returned by a GTK+ getter function where ownership is not
309  * passed (that is, where the user is not expected to call
310  * g_object_unref() when finished with the return value). A typical
311  * example of this is the GtkTreeSelection object returned by
312  * gtk_tree_view_get_selection(). The GtkTreeSelection object is part
313  * of the GtkTreeView's implemention and will become invalid as soon
314  * as the GtkTreeView object is finalized.
315  *
316  * As in the case of the GobjHandle class, although this class has
317  * operator*() and operator->() dereferencing operators, and so has
318  * normal smart pointer functionality, as it is intended for use with
319  * the normal C GObject/pango/GTK+ interfaces, ordinary use would
320  * involve passing the handle to a function taking a pointer by means
321  * of the operatorT*() type conversion operator (which returns the
322  * underlying pointer), or by explicitly calling the get() method to
323  * obtain the underlying pointer.
324  *
325  * Typical usage is as follows:
326  *
327  * @code
328  * using namespace Cgu;
329  * GobjWeakHandle<GtkTreeSelection> s(gtk_tree_view_get_selection(tree_view));
330  * gtk_tree_selection_set_mode(s, GTK_SELECTION_SINGLE);
331  * ...
332  *
333  * [some code blocks later]
334  * if (s) { // check that the GtkTreeSelection object still exists.
335  * GtkTreeIter iter;
336  * GtkTreeModel* model = 0;
337  * gtk_tree_selection_get_selected(s, &model, &iter);
338  * ...
339  * }
340  * else [report error];
341  * @endcode
342  *
343  * Or instead of an 'if' block, GobjWeakHandleError could be caught:
344  *
345  * @code
346  * using namespace Cgu;
347  * GobjWeakHandle<GtkTreeSelection> s(gtk_tree_view_get_selection(tree_view));
348  * gtk_tree_selection_set_mode(s, GTK_SELECTION_SINGLE);
349  * ...
350  *
351  * [some code blocks later]
352  * GtkTreeIter iter;
353  * GtkTreeModel* model = 0;
354  * try {
355  * gtk_tree_selection_get_selected(s, &model, &iter);
356  * ...
357  * }
358  * catch (GobjWeakHandleError&) {[report error]}
359  * @endcode
360  *
361  * @b Thread-safe @b use
362  *
363  * This class wraps
364  * g_object_add_weak_pointer()/g_object_remove_weak_pointer(), and as
365  * those GObject functions have practical limitations concerning
366  * thread-safe use, this class has the same practical limitations. As
367  * shown above, typical usage for a weak pointer 's' would be 'if (s)
368  * do_it(s)', but if the thread calling that sequence (thread A) were
369  * not the thread controlling the lifetime of the referenced GObject
370  * (thread B), then thread B may have destroyed the GObject between
371  * thread A testing 's' and then calling the referenced object. The
372  * same applies to the test leading to GobjWeakHandleError being
373  * thrown.
374  *
375  * In other words, in the GtkTreeSelection code example above, if the
376  * thread calling gtk_tree_selection_get_selected() were not the main
377  * GUI thread (which would anyway require the use of
378  * gdk_threads_enter()/gdk_threads_leave()), then the calling thread
379  * must ensure that the main GUI thread does not destroy the relevant
380  * tree view, and so the GtkTreeSelection object, from the beginning
381  * of the 'if' test to the end of the 'if' block, or for the duration
382  * of the try block. (This cannot be done just by incrementing the
383  * reference count of the tree view or the tree selection in the
384  * calling thread before the 'if' test or the try block is entered,
385  * because by the time the reference is incremented and the weak
386  * pointer tested, the tree view and tree selection may already be in
387  * their dispose functions but the tree selection's dispose function
388  * may not yet have reached the point of dispatching the callback
389  * NULLing the weak pointer. As a general design issue, it is usually
390  * best only to call GTK+ functions in one thread, and in order to
391  * make that straightforward, this library contains a number of
392  * classes and functions for inter-thread communication.)
393  */
394 
395 struct GobjWeakHandleError: public std::exception {
396  virtual const char* what() const throw() {return "GobjWeakHandleError\n";}
397 };
398 
399 template <class T> class GobjWeakHandle {
400 
401  T* obj_p;
402 
403 public:
404 
405  /**
406  * This constructor does not throw.
407  * @param ptr The object which the GobjWeakHandle is to track (if any).
408  *
409  * Since 1.2.1
410  */
411  explicit GobjWeakHandle(T* ptr = 0) {
412  obj_p = ptr;
413  if (ptr) g_object_add_weak_pointer((GObject*)ptr,
414  (void**)&obj_p);
415  }
416 
417  /**
418  * Causes the handle to cease to track its tracked object (if any).
419  * If the argument passed is not NULL, the handle will track the new
420  * object passed. This method does not throw.
421  * @param ptr NULL (the default), or a new object to track.
422  *
423  * Since 1.2.1
424  */
425  void reset(T* ptr = 0) {
426 
427  if (obj_p) g_object_remove_weak_pointer((GObject*)obj_p,
428  (void**)&obj_p);
429  obj_p = ptr;
430  if (ptr) g_object_add_weak_pointer((GObject*)ptr,
431  (void**)&obj_p);
432  }
433 
434  /**
435  * The copy constructor does not throw. It constructs a new weak
436  * pointer tracking the same GObject as that tracked by the existing
437  * weak pointer.
438  * @param gobj The handle to be copied.
439  *
440  * Since 1.2.1
441  */
443  obj_p = gobj.obj_p;
444  if (obj_p) g_object_add_weak_pointer((GObject*)obj_p,
445  (void**)&obj_p);
446  }
447 
448  /**
449  * This constructor constructs a weak pointer for a GObject managed
450  * by a GobjHandle handle. It does not throw.
451  * @param gobj The GobjHandle managing the GObject which the
452  * GobjWeakHandle is to track.
453  *
454  * Since 1.2.1
455  */
457  obj_p = gobj.get();
458  if (obj_p) g_object_add_weak_pointer((GObject*)obj_p,
459  (void**)&obj_p);
460  }
461 
462  /**
463  * This method does not throw. It causes the handle to cease to
464  * track its tracked object (if any), and begin tracking the same
465  * GObject as that tracked by the assignor. This method does not
466  * throw.
467  * @param gobj The assignor.
468  * @return The GobjWeakHandle object after assignment.
469  *
470  * Since 1.2.1
471  */
473  // self assignment takes care of itself
474  reset(gobj.obj_p);
475  return *this;
476  }
477 
478  /**
479  * This method does not throw. It causes the handle to cease to
480  * track its tracked object (if any), and begin tracking the GObject
481  * managed by the GobjHandle argument. This method does not throw.
482  * @param gobj The assignor GobjHandle.
483  * @return The GobjWeakHandle object after assignment.
484  *
485  * Since 1.2.1
486  */
488  reset(gobj.get());
489  return *this;
490  }
491 
492  /**
493  * This method does not throw.
494  * @return True if the tracked GObject still exists, or false if it
495  * does not or no GObject is being tracked.
496  * @note The valid() method is a synonym for this method.
497  *
498  * Since 1.2.1
499  */
500  operator bool() const {return obj_p;}
501 
502 #ifndef DOXYGEN_PARSING
503  /*
504  * DEPRECATED: Do not use this method as it is only retained for
505  * source compatibility. Its semantics are the wrong way around:
506  * expired() returns true if the GObject still exists, instead of
507  * false. Use operator bool() or the valid() method instead, which
508  * have the correct semantics. This method does not throw.
509  *
510  * Since 1.2.1
511  */
512  bool expired() const {return obj_p;}
513 #endif
514 
515  /**
516  * This method does not throw.
517  * @return True if the tracked GObject still exists, or false if it
518  * does not or no GObject is being tracked.
519  * @note operator bool() is a synonym for this method.
520  *
521  * Since 1.2.19
522  */
523  bool valid() const {return obj_p;}
524 
525  /**
526  * This method does not throw.
527  * @return A pointer to the tracked GObject.
528  * @exception GobjWeakHandleError This method will throw
529  * GobjWeakHandleError if the tracked object no longer exists or none
530  * is being tracked. There is no need to check for this exception if
531  * the status of the tracked object has been established with
532  * operator bool() or valid().
533  *
534  * Since 1.2.1
535  */
536  T* get() const {if (!obj_p) throw GobjWeakHandleError(); return obj_p;}
537 
538  /**
539  * This method does not throw.
540  * @return A reference to the tracked GObject.
541  * @exception GobjWeakHandleError This method will throw
542  * GobjWeakHandleError if the tracked object no longer exists or none
543  * is being tracked. There is no need to check for this exception if
544  * the status of the tracked object has been established with
545  * operator bool() or valid().
546  *
547  * Since 1.2.1
548  */
549  T& operator*() const {if (!obj_p) throw GobjWeakHandleError(); return *obj_p;}
550 
551  /**
552  * This method does not throw.
553  * @return A pointer to the tracked GObject.
554  * @exception GobjWeakHandleError This method will throw
555  * GobjWeakHandleError if the tracked object no longer exists or none
556  * is being tracked. There is no need to check for this exception if
557  * the status of the tracked object has been established with
558  * operator bool() or valid().
559  *
560  * Since 1.2.1
561  */
562  T* operator->() const {if (!obj_p) throw GobjWeakHandleError(); return obj_p;}
563 
564  /**
565  * This method does not throw.
566  * @return A pointer to the tracked GObject.
567  * @exception GobjWeakHandleError This method will throw
568  * GobjWeakHandleError if the tracked object no longer exists or none
569  * is being tracked. There is no need to check for this exception if
570  * the status of the tracked object has been established with
571  * operator bool() or valid().
572  *
573  * Since 1.2.1
574  */
575  operator T*() const {if (!obj_p) throw GobjWeakHandleError(); return obj_p;}
576 
577  /**
578  * The destructor does not throw.
579  *
580  * Since 1.2.1
581  */
582  ~GobjWeakHandle() {if (obj_p) g_object_remove_weak_pointer((GObject*)obj_p,
583  (void**)&obj_p);}
584 };
585 
586 #if defined(CGU_USE_SMART_PTR_COMPARISON) || defined(DOXYGEN_PARSING)
587 
588 // we can use built-in operator == when comparing pointers referencing
589 // different objects of the same type
590 /**
591  * @ingroup handles
592  *
593  * This comparison operator does not throw. It compares the addresses
594  * of the managed objects. This function is only available if the
595  * library is compiled with the \--with-smart-ptr-comp option, or if
596  * the user code defines the symbol CGU_USE_SMART_PTR_COMPARISON
597  * before gobj_handle.h is first parsed.
598  *
599  * Since 1.2.12
600  */
601 template <class T>
602 bool operator==(const GobjHandle<T>& h1, const GobjHandle<T>& h2) {
603  return (h1.get() == h2.get());
604 }
605 
606 /**
607  * @ingroup handles
608  *
609  * This comparison operator does not throw. It compares the addresses
610  * of the managed objects. This function is only available if the
611  * library is compiled with the \--with-smart-ptr-comp option, or if
612  * the user code defines the symbol CGU_USE_SMART_PTR_COMPARISON
613  * before gobj_handle.h is first parsed.
614  *
615  * Since 1.2.12
616  */
617 template <class T>
618 bool operator!=(const GobjHandle<T>& h1, const GobjHandle<T>& h2) {
619  return !(h1 == h2);
620 }
621 
622 // we must use std::less rather than the < built-in operator for
623 // pointers to objects not within the same array or object: "For
624 // templates greater, less, greater_equal, and less_equal, the
625 // specializations for any pointer type yield a total order, even if
626 // the built-in operators <, >, <=, >= do not." (para 20.3.3/8).
627 /**
628  * @ingroup handles
629  *
630  * This comparison operator does not throw unless std::less applied to
631  * pointer types throws (which it would not do with any sane
632  * implementation). It compares the addresses of the managed objects.
633  * This function is only available if the library is compiled with the
634  * \--with-smart-ptr-comp option, or if the user code defines the
635  * symbol CGU_USE_SMART_PTR_COMPARISON before gobj_handle.h is first
636  * parsed.
637  *
638  * Since 1.2.12
639  */
640 template <class T>
641 bool operator<(const GobjHandle<T>& h1, const GobjHandle<T>& h2) {
642  return std::less<T*>()(h1.get(), h2.get());
643 }
644 
645 #endif // CGU_USE_SMART_PTR_COMPARISON
646 
647 } // namespace Cgu
648 
649 #endif
Cgu::GobjWeakHandle::operator*
T & operator*() const
Definition: gobj_handle.h:549
Cgu
Definition: application.h:45
Cgu::GobjHandle
This is a handle for managing the reference count of GObjects.
Definition: gobj_handle.h:155
Cgu::operator!=
bool operator!=(const GobjHandle< T > &h1, const GobjHandle< T > &h2)
Definition: gobj_handle.h:618
Cgu::GobjHandle::operator->
T * operator->() const
Definition: gobj_handle.h:278
Cgu::GobjWeakHandle::get
T * get() const
Definition: gobj_handle.h:536
Cgu::GobjWeakHandleError
Definition: gobj_handle.h:395
Cgu::GobjHandle::reset
void reset(T *ptr=0)
Definition: gobj_handle.h:201
Cgu::operator<
bool operator<(const GobjHandle< T > &h1, const GobjHandle< T > &h2)
Definition: gobj_handle.h:641
Cgu::GobjHandle::operator*
T & operator*() const
Definition: gobj_handle.h:271
Cgu::GobjWeakHandle::GobjWeakHandle
GobjWeakHandle(const GobjHandle< T > &gobj)
Definition: gobj_handle.h:456
Cgu::GobjWeakHandle::reset
void reset(T *ptr=0)
Definition: gobj_handle.h:425
Cgu::GobjWeakHandle::operator=
GobjWeakHandle & operator=(const GobjHandle< T > &gobj)
Definition: gobj_handle.h:487
Cgu::GobjWeakHandle::~GobjWeakHandle
~GobjWeakHandle()
Definition: gobj_handle.h:582
Cgu::GobjWeakHandle::GobjWeakHandle
GobjWeakHandle(const GobjWeakHandle &gobj)
Definition: gobj_handle.h:442
Cgu::GobjHandle::GobjHandle
GobjHandle(const GobjHandle &gobj)
Definition: gobj_handle.h:218
Cgu::GobjHandle::get
T * get() const
Definition: gobj_handle.h:265
Cgu::GobjWeakHandle
This is a handle for managing weak references to GObjects.
Definition: gobj_handle.h:399
Cgu::operator==
bool operator==(const GobjHandle< T > &h1, const GobjHandle< T > &h2)
Definition: gobj_handle.h:602
Cgu::GobjWeakHandle::valid
bool valid() const
Definition: gobj_handle.h:523
Cgu::GobjWeakHandle::GobjWeakHandle
GobjWeakHandle(T *ptr=0)
Definition: gobj_handle.h:411
Cgu::GobjWeakHandle::operator->
T * operator->() const
Definition: gobj_handle.h:562
Cgu::GobjHandle::operator=
GobjHandle & operator=(const GobjHandle &gobj)
Definition: gobj_handle.h:242
cgu_config.h
Cgu::GobjHandle::GobjHandle
GobjHandle(T *ptr=0)
Definition: gobj_handle.h:177
Cgu::GobjWeakHandle::operator=
GobjWeakHandle & operator=(const GobjWeakHandle &gobj)
Definition: gobj_handle.h:472
Cgu::GobjWeakHandleError::what
virtual const char * what() const
Definition: gobj_handle.h:396
Cgu::GobjHandle::~GobjHandle
~GobjHandle()
Definition: gobj_handle.h:292