guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
Public Member Functions | List of all members
guit::GObject Class Referenceabstract

Base class of Guit Objects. More...

Inheritance diagram for guit::GObject:
guit::Gadget guit::GadgetStyle guit::GProp guit::GSocket guit::GSocketChannel guit::GStateTransition guit::GTheme guit::GBox guit::GItem guit::GAnim guit::GCond guit::GCursor guit::GExpr guit::GHotkey guit::GItems guit::GModes guit::GValue guit::GVarProp

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...
 

Detailed Description

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):

MyClass* p = new MyClass();
// etc.
gptr<GObject> p2 = p;
p2.reset(); // or p2 = nullptr;

Auto-deletion can be temporarily or permanently disallowed by calling (respectively) forgetSmartPointers() and ignoreSmartPointers().

See Also
gptr.

Member Function Documentation

void guit::GObject::error ( GString const &  funname,
GString const &  message 
) const
virtual

Prints an error message.

See Also
GApp::onError() to change error management.
void guit::GObject::ignoreSmartPointers ( )
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.

void guit::GObject::forgetSmartPointers ( )
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().


The documentation for this class was generated from the following files: