Guiliani  Version 2.5 revision 7293 (documentation build 13)
CSafeGUIObjectPtr Class Reference

Smart pointer to a CGUIObject which will automatically be set to NULL if the corresponding GUIObject gets destructed. More...

#include <SafeGUIObjectPtr.h>

Public Member Functions

 CSafeGUIObjectPtr ()
 
 CSafeGUIObjectPtr (CGUIObject *ptr)
 
 CSafeGUIObjectPtr (const CSafeGUIObjectPtr &ptr)
 
 ~CSafeGUIObjectPtr ()
 
CGUIObjectget () const
 
 operator CGUIObject * () const
 
CGUIObjectoperator* () const
 
CGUIObjectoperator-> () const
 
CSafeGUIObjectPtroperator= (CGUIObject *pkSource)
 
CSafeGUIObjectPtroperator= (const CSafeGUIObjectPtr &kSource)
 
void Register ()
 
void Reset ()
 Helper function to reset internal pointer.
 

Friends

class CGUIObject
 

Detailed Description

Smart pointer to a CGUIObject which will automatically be set to NULL if the corresponding GUIObject gets destructed.

This class is useful if you are accessing an object which is not under your sole control, i.e. it could be deleted by other code, rendering your local pointer invalid.

Warning: You shall not instantiate objects of this class as members of static classes, since CSafeGUIObjectPtr requires the framework to be fully initialized!

Performance note: Compared to a plain GUIObject* this class will impose a performance overhead, so use it sparingly and stick with simple CGUIObject-pointers when possible!

Example:

// Create test container
CGUICompositeObject* pContainer = new CGUICompositeObject(&GETGUI, 0,0,100,100);
// Create test object and store pointer in CSafeGUIObjectPtr
CSafeGUIObjectPtr pTest = new CGUIObject(pContainer, 0,0,10,10);
// delete container (and thus also the contained object)
delete pContainer;
// pTest will now automatically point to NULL
if (pTest)
{
// Do something with pTest...
}
This is the Guiliani base class for all composite objects.
Definition: GUICompositeObject.h:70
Smart pointer to a CGUIObject which will automatically be set to NULL if the corresponding GUIObject ...
Definition: SafeGUIObjectPtr.h:44
friend class CGUIObject
Definition: SafeGUIObjectPtr.h:141

Constructor & Destructor Documentation

◆ CSafeGUIObjectPtr() [1/3]

CSafeGUIObjectPtr::CSafeGUIObjectPtr ( )
inline

Default constructor

◆ CSafeGUIObjectPtr() [2/3]

CSafeGUIObjectPtr::CSafeGUIObjectPtr ( CGUIObject ptr)
inline

Constructor

Parameters
ptrSource pointer

◆ CSafeGUIObjectPtr() [3/3]

CSafeGUIObjectPtr::CSafeGUIObjectPtr ( const CSafeGUIObjectPtr ptr)
inline

Constructor

Parameters
ptrSource pointer

◆ ~CSafeGUIObjectPtr()

CSafeGUIObjectPtr::~CSafeGUIObjectPtr ( )
inline

Destructor

Member Function Documentation

◆ get()

CGUIObject * CSafeGUIObjectPtr::get ( ) const
inline

Extract pointer

Returns
Internal pointer

◆ operator CGUIObject *()

CSafeGUIObjectPtr::operator CGUIObject * ( ) const
inline

Cast operator to CGUIObject*

Returns
Internal pointer cast to CGUIObject*

◆ operator*()

CGUIObject & CSafeGUIObjectPtr::operator* ( ) const
inline

Dereference operator

Returns
Internal pointer

◆ operator->()

CGUIObject * CSafeGUIObjectPtr::operator-> ( ) const
inline

Arrow operator

Returns
Internal pointer

◆ operator=() [1/2]

CSafeGUIObjectPtr & CSafeGUIObjectPtr::operator= ( CGUIObject pkSource)
inline

Assignment operator

Parameters
pkSourceSource of assignment as a CGUIObject*
Returns
Destination of assignment

◆ operator=() [2/2]

CSafeGUIObjectPtr & CSafeGUIObjectPtr::operator= ( const CSafeGUIObjectPtr kSource)
inline

Assignment operator

Parameters
kSourceSource of assignment as a CSafeGUIObjectPtr
Returns
Destination of assignment

◆ Register()

void CSafeGUIObjectPtr::Register ( )
inline

Registers this CSafeGUIObjectPtr for being notified if its referenced object gets destructed. This is automatically done during CSafeGUIObjectPtr's construction and only needs to be done manually in case an object of CSafeGUIObjectPtr could not successfully register itself upon construction.

Friends And Related Function Documentation

◆ CGUIObject

friend class CGUIObject
friend

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