TexGen
Public Member Functions | Private Attributes | List of all members
TexGen::CObjectContainer< T > Class Template Reference

Object container to help handle memory management issues. More...

#include <ObjectContainer.h>

Public Member Functions

 CObjectContainer ()
 
 CObjectContainer (const T &Object)
 
 CObjectContainer (const CObjectContainer< T > &CopyMe)
 
 ~CObjectContainer ()
 
CObjectContaineroperator= (const CObjectContainer< T > &CopyMe)
 
CObjectContaineroperator= (const T &Object)
 
 operator T* ()
 Conversion operator. More...
 
T * operator-> ()
 Pointer overload operator to act as a pointer of type T. More...
 
void Clear ()
 Remove the object contained within the container class. More...
 
 operator const T * () const
 Conversion operator for when the class is defined as const. More...
 
const T * operator-> () const
 Pointer overload operator for the class when it is defined as const. More...
 

Private Attributes

T * m_pObject
 Object contained within the class. More...
 

Detailed Description

template<typename T>
class TexGen::CObjectContainer< T >

Object container to help handle memory management issues.

This class acts as a pointer to an object with a little more functionality. It is automatically initialised to NULL and whenever the object needs to be copied it creates a copy of the object it contains. The difference with a normal pointer is that a normal pointer will not create a copy of the object it points to. It simply creates a copy of the address, which can lead to problems when the object is deleted. The copied pointers will no longer be valid. This problem is avoided by creating a copy of the object it contains. For this to work the object must have a function called "Copy" that creates a copy of itself and returns a pointer to the new copy.

Note: This is NOT a reference counting system.

Definition at line 38 of file ObjectContainer.h.

Constructor & Destructor Documentation

◆ CObjectContainer() [1/3]

template<typename T >
TexGen::CObjectContainer< T >::CObjectContainer ( )
inline

Definition at line 41 of file ObjectContainer.h.

◆ CObjectContainer() [2/3]

template<typename T >
TexGen::CObjectContainer< T >::CObjectContainer ( const T &  Object)
inline

Definition at line 42 of file ObjectContainer.h.

◆ CObjectContainer() [3/3]

template<typename T >
TexGen::CObjectContainer< T >::CObjectContainer ( const CObjectContainer< T > &  CopyMe)
inline

Definition at line 46 of file ObjectContainer.h.

◆ ~CObjectContainer()

template<typename T >
TexGen::CObjectContainer< T >::~CObjectContainer ( )
inline

Definition at line 50 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

Member Function Documentation

◆ Clear()

template<typename T >
void TexGen::CObjectContainer< T >::Clear ( )
inline

Remove the object contained within the container class.

Definition at line 80 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject, and NULL.

◆ operator const T *()

template<typename T >
TexGen::CObjectContainer< T >::operator const T * ( ) const
inline

Conversion operator for when the class is defined as const.

Definition at line 82 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

◆ operator T*()

template<typename T >
TexGen::CObjectContainer< T >::operator T* ( )
inline

Conversion operator.

If the container object is passed to a function that expects to receive an object of type T* then it will be converted automatically. Similarly if the container object is dereferenced an object of type T will be obtained.

Definition at line 76 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

◆ operator->() [1/2]

template<typename T >
T * TexGen::CObjectContainer< T >::operator-> ( )
inline

Pointer overload operator to act as a pointer of type T.

Definition at line 78 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

◆ operator->() [2/2]

template<typename T >
const T * TexGen::CObjectContainer< T >::operator-> ( ) const
inline

Pointer overload operator for the class when it is defined as const.

Definition at line 84 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

◆ operator=() [1/2]

template<typename T >
CObjectContainer & TexGen::CObjectContainer< T >::operator= ( const CObjectContainer< T > &  CopyMe)
inline

Definition at line 54 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject, and NULL.

◆ operator=() [2/2]

template<typename T >
CObjectContainer & TexGen::CObjectContainer< T >::operator= ( const T &  Object)
inline

Definition at line 63 of file ObjectContainer.h.

References TexGen::CObjectContainer< T >::m_pObject.

Member Data Documentation

◆ m_pObject

template<typename T >
T* TexGen::CObjectContainer< T >::m_pObject
private

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