H3D::AutoRef< NodeType > Class Template Reference

The AutoRef class is similar to the auto_ptr class, but it requires that the pointer to Node or a subclass of Node. More...

#include <AutoRef.h>

List of all members.

Public Types

typedef NodeType element_type
 The type of the encapsulated Node.

Public Member Functions

 AutoRef (NodeType *n=0) throw ()
 Constructor.
 AutoRef (const AutoRef< NodeType > &ar) throw ()
 Copy constructor.
template<class Y>
 AutoRef (const AutoRef< Y > &ar) throw ()
 Copy constructor from other type of AutoRef.
AutoRef< NodeType > & operator= (const AutoRef< NodeType > &ar) throw ()
 Assignment operator.
template<class Y>
AutoRef< NodeType > & operator= (const AutoRef< Y > &ar) throw ()
 Assignment operator for other type of AutoRef.
NodeType & operator * () const throw ()
 Returns what the encapsulated Node * points to.
NodeType * operator-> () const throw ()
 Returns the encapsulated Node pointer.
NodeType * get () const throw ()
 Returns the encapsulated Node pointer.
void reset (NodeType *p=0) throw ()
 Change the Node pointer that is encapsulated.

Protected Member Functions

virtual void ref (NodeType *n)
 This function is called when a Node * is to be held by the AutoRef.
virtual void unref (NodeType *n)
 This function is called when a Node * is released by the AutoRef.

Protected Attributes

NodeType * node_ptr


Detailed Description

template<class NodeType>
class H3D::AutoRef< NodeType >

The AutoRef class is similar to the auto_ptr class, but it requires that the pointer to Node or a subclass of Node.

It will keep a reference to the Node pointer it encapsulates, i.e. ref() will be called. When destructed the AutoRef does not delete the pointer, but instead unreferences the Node (if this causes the reference count for the Node to go down to 0 then it will be deleted though).


Member Function Documentation

template<class NodeType>
virtual void H3D::AutoRef< NodeType >::ref NodeType *  n  )  [inline, protected, virtual]
 

This function is called when a Node * is to be held by the AutoRef.

It increments the reference counter of the Node by calling the ref() function. Subclasses can override this function in order to get specialized behaviour.

Parameters:
n The node that is to be held by the AutoRef

template<class NodeType>
void H3D::AutoRef< NodeType >::reset NodeType *  p = 0  )  throw () [inline]
 

Change the Node pointer that is encapsulated.

Will cause an unref on the current Node * and a ref on the new.

Parameters:
p The new Node pointer to encapsulate.

template<class NodeType>
virtual void H3D::AutoRef< NodeType >::unref NodeType *  n  )  [inline, protected, virtual]
 

This function is called when a Node * is released by the AutoRef.

It decrements the reference counter of the Node by calling the unref() function. Subclasses can override this function in order to get specialized behaviour.

Parameters:
n The node being released by the AutoRef.


Generated on Thu Aug 24 12:38:49 2006 for H3D API by  doxygen 1.4.5