Base class of Guit Objects. More...
Public Member Functions | |
virtual void | error (GString const &funname, GString const &message) const |
Prints an error message. More... | |
void | operator delete (void *) |
delete does nothing, see GObject class. | |
void | forgetSmartPointers () |
Forgets all smart pointers pointing this object. More... | |
unsigned int | useCount () const |
Returns the numbers of smart pointers referencing the object. | |
virtual void | removeNotifiers (void *obj) |
[Implementation] Notifies this object that it must no longer refer obj. | |
template<class Subclass > | |
Subclass * | to () |
Class conversions. | |
void | ignoreSmartPointers () |
Checks/sets whether this object can be auto-deleted by smart pointers. More... | |
Base class of Guit Objects.
A GObject can be pointed by one or several gptr<> smart pointers. These pointers take ownership, so that the GObject is auto-deleted (*) when the last gptr pointing to it is unset or destroyed..
Gadget(s) point to their props and children through gptrs, thus props and children are auto-deleted (*) when removed from the last parent containing them, if not pointed by another gptr. gptrs should thus be used when removing objects from their parents if these objects need to be reused.
(*) Objects created in the stack or in static memory are not auto-deleted by gptrs. gptrs can thus point objects allocated in the heap, the stack or in static memory.
Raw C++ pointers and references should only be used as temporary references (e.g. when creating a gadget tree) as they may become pending at some point.
std::shared_ptr, std::weak_ptr, std::unique_ptr CANNOT BE USED.
The delete operator does nothing except issuing a warning. An object pointed by a raw pointer can be deleted as follows (this will delete it only if it is not gptr-referenced elsewhere):
Auto-deletion can be temporarily or permanently disallowed by calling (respectively) forgetSmartPointers() and ignoreSmartPointers().
|
virtual |
Prints an error message.
|
inline |
Checks/sets whether this object can be auto-deleted by smart pointers.
ignoreSmartPointers() has a permanent effect, contrary to forgetSmartPointers(). Objects not created by calling new are never auto-deleted by smart pointers.
|
inline |
Forgets all smart pointers pointing this object.
The smart pointers that are currently pointing to the object won't auto-delete it. forgetSmartPointers() has a temporary effect, contrary to ignoreSmartPointers().