xmppd::pointer< pointed_type > Class Template Reference

#include <jabberdlib.h>

Public Member Functions

 pointer ()
 pointer (pointed_type *pointed_object, bool malloc_allocated=false)
 pointer (const pointer< pointed_type > &src)
 ~pointer ()
void delete_object ()
pointer< pointed_type > & operator= (const pointer< pointed_type > &src)
pointed_type & operator* ()
pointed_type * operator-> () const
bool points_to_NULL () const

Detailed Description

template<class pointed_type>
class xmppd::pointer< pointed_type >

the pointer template class is used as a replacement for real pointers

Instead of real pointers this template class should be used everywhere inside this package. Managed pointers have the advantage, that they track for you if the object pointed to does still exist.


Constructor & Destructor Documentation

template<class pointed_type>
xmppd::pointer< pointed_type >::pointer (  ) 

constructor to create a managed pointer pointing to nothing

template<class pointed_type>
xmppd::pointer< pointed_type >::pointer ( pointed_type *  pointed_object,
bool  malloc_allocated = false 
)

constructor to create a managed pointer for a real pointer

After constructing a managed pointer, the freeing of the pointed_object is done by the managed pointer. Therefore the caller should not free the pointed_object itself.

Parameters:
pointed_object the object a managed pointer should be created for
malloc_allocated if false, the pointed_object is deleted using the delete operator (default); if true, the pointed object is deleted using std::free()
template<class pointed_type>
xmppd::pointer< pointed_type >::pointer ( const pointer< pointed_type > &  src  ) 

copy constructor

Makes a copy of a managed pointer to an object.

Parameters:
src the copy source
template<class pointed_type>
xmppd::pointer< pointed_type >::~pointer (  ) 

destruct a pointer

Destructs a pointer, and if it is the last pointer to the object, it deletes (or frees) the object


Member Function Documentation

template<class pointed_type>
void xmppd::pointer< pointed_type >::delete_object (  ) 

delete the object the pointer points to

This marks all managed pointers pointing to this object as pointing to nothing.

template<class pointed_type>
pointed_type& xmppd::pointer< pointed_type >::operator* (  ) 

dereference operator

Dereferences a managed pointer (i.e. gives access to the object the managed pointer points to)

Returns:
the object the managed pointer points to
template<class pointed_type>
pointed_type* xmppd::pointer< pointed_type >::operator-> (  )  const

pointer operator

Note:
do NOT use this to get back a real pointer to the object. The operator is just there to let you access the object like you are used to do it with real pointers. (i.e. myptr->fieldname)
Returns:
the real pointer to the object
template<class pointed_type>
pointer<pointed_type>& xmppd::pointer< pointed_type >::operator= ( const pointer< pointed_type > &  src  ) 

assignment operator

Assignes the value of another managed pointer to a managed pointer

Parameters:
src the object, that gets assigned to this managed pointer
Returns:
the managed pointer itself
template<class pointed_type>
bool xmppd::pointer< pointed_type >::points_to_NULL (  )  const

check if this pointer points to nothing

Returns:
true if the pointer does not point to anything, else false

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

Generated on Thu Mar 11 06:00:14 2010 for jabberd14 by  doxygen 1.6.1