template <class T_CppObject>
class Glib::RefPtr< T_CppObject >
RefPtr<> is a reference-counting shared smartpointer.
Some objects in gtkmm are obtained from a shared store. Consequently you cannot instantiate them yourself. Instead they return a RefPtr which behaves much like an ordinary pointer in that members can be reached with the usual object_ptr->member notation. Unlike most other smart pointers, RefPtr doesn't support dereferencing through * object_ptr.
Reference counting means that a shared reference count is incremented each time a RefPtr is copied, and decremented each time a RefPtr is destroyed, for instance when it leaves its scope. When the reference count reaches zero, the contained object is deleted, meaning you don't need to remember to delete the object.
RefPtr<> can store any class that has reference() and unreference() methods. In gtkmm, that is anything derived from Glib::ObjectBase, such as Gdk::Pixmap.
See the "Memory Management" section in the "Programming with gtkmm" book for further information.
Constructor & Destructor Documentation
template <class T_CppObject>
Glib::RefPtr<T_CppObject>::RefPtr
(
)
[inline]
Default constructor.
Afterwards is_null() will return true and use of -> will cause a segmentation fault.
template <class T_CppObject>
Glib::RefPtr<T_CppObject>::~RefPtr
(
)
[inline]
Destructor - decrements reference count.
template <class T_CppObject>
Glib::RefPtr<T_CppObject>::RefPtr
(
T_CppObject*
pCppObject
)
[inline, explicit]
For use only by the ::create() methods.
template <class T_CppObject>
Glib::RefPtr<T_CppObject>::RefPtr
(
const RefPtr<T_CppObject>&
src
)
[inline]
Copy constructor.
This increments the shared reference count.
template <class T_CppObject>
template <class T_CastFrom>
Glib::RefPtr<T_CppObject>::RefPtr
(
const RefPtr<T_CastFrom>&
src
)
[inline]
Copy constructor (from different, but castable type).
Tests whether the RefPtr<> point to the same underlying instance.
template <class T_CppObject>
void Glib::RefPtr<T_CppObject>::swap
(
RefPtr<T_CppObject>&
other
)
[inline]
Swap the contents of two RefPtr<>.
This method swaps the internal pointers to T_CppObject. This can be done safely without involving a reference/unreference cycle and is therefore highly efficient.
Friends And Related Function Documentation
template <class T_CppObject>
void swap
(
RefPtr<T_CppObject>&
lhs,
RefPtr<T_CppObject>&
rhs
)
[related]
The documentation for this class was generated from the following file: