OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OpenAB::SmartPtr< __C > Class Template Reference

Smart pointer implementation for safely passing around dynamically created data. Smart pointers are reference counted, data that they are managing is automatically freed when no other references to it exist. More...

#include <SmartPtr.hpp>

Public Member Functions

 SmartPtr ()
 Default constructor. More...
 
 SmartPtr (__C *p)
 Constructor. Creates new SmartPtr from given pointer. More...
 
 SmartPtr (const SmartPtr &other)
 Copy constructor. Creates new SmartPtr from other instance of SmartPtr increasing its reference count. More...
 
 ~SmartPtr ()
 Destructor. Decrements reference count, if it drops to 0 frees managed data. More...
 
SmartPtroperator= (const SmartPtr &other)
 Assignment operator Creates new SmartPtr from other instance of SmartPtr increasing its reference count. Decreases reference count of previous data, and it is needed frees it. More...
 
bool operator== (const SmartPtr &other) const
 
bool operator!= (const SmartPtr &other) const
 
bool operator< (const SmartPtr &other) const
 
__C * operator-> () const
 
__C & operator* () const
 
__C * getPointer () const
 
 operator __C * () const
 
 operator const __C * () const
 

Detailed Description

template<typename __C>
class OpenAB::SmartPtr< __C >

Smart pointer implementation for safely passing around dynamically created data. Smart pointers are reference counted, data that they are managing is automatically freed when no other references to it exist.

Note
it is not advised to operate directly on pointers managed by SmartPtr.
Todo:
check if other comparison operators also need to be overloaded

Constructor & Destructor Documentation

template<typename __C>
OpenAB::SmartPtr< __C >::SmartPtr ( )
inline

Default constructor.

template<typename __C>
OpenAB::SmartPtr< __C >::SmartPtr ( __C *  p)
inline

Constructor. Creates new SmartPtr from given pointer.

Parameters
[in]ppointer to be managed by new SmartPtr
template<typename __C>
OpenAB::SmartPtr< __C >::SmartPtr ( const SmartPtr< __C > &  other)
inline

Copy constructor. Creates new SmartPtr from other instance of SmartPtr increasing its reference count.

Parameters
[in]otherinstance of SmartPtr to be copied.
template<typename __C>
OpenAB::SmartPtr< __C >::~SmartPtr ( )
inline

Destructor. Decrements reference count, if it drops to 0 frees managed data.

Member Function Documentation

template<typename __C>
__C* OpenAB::SmartPtr< __C >::getPointer ( ) const
inline
template<typename __C>
OpenAB::SmartPtr< __C >::operator __C * ( ) const
inline
template<typename __C>
OpenAB::SmartPtr< __C >::operator const __C * ( ) const
inline
template<typename __C>
bool OpenAB::SmartPtr< __C >::operator!= ( const SmartPtr< __C > &  other) const
inline
template<typename __C>
__C& OpenAB::SmartPtr< __C >::operator* ( ) const
inline
template<typename __C>
__C* OpenAB::SmartPtr< __C >::operator-> ( ) const
inline
template<typename __C>
bool OpenAB::SmartPtr< __C >::operator< ( const SmartPtr< __C > &  other) const
inline
template<typename __C>
SmartPtr& OpenAB::SmartPtr< __C >::operator= ( const SmartPtr< __C > &  other)
inline

Assignment operator Creates new SmartPtr from other instance of SmartPtr increasing its reference count. Decreases reference count of previous data, and it is needed frees it.

template<typename __C>
bool OpenAB::SmartPtr< __C >::operator== ( const SmartPtr< __C > &  other) const
inline

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