Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SPtr< T > Class Template Reference

#include <SmartPtr.h>

+ Collaboration diagram for SPtr< T >:

Public Member Functions

 SPtr ()
 Default constructor.
 SPtr (T *something)
 constructor
 SPtr (Ptr *voidptr)
 SPtr (const SPtr &ref)
 ~SPtr ()
const T * get () const
PtrgetPtr ()
 operator bool () const
T & operator* () const
 This template is used to dereference an object from SmartPtr.
T * operator-> () const
 This template is used to access an object using SmartPtr.
SPtroperator= (const SPtr &old)
int refCount ()
void reset ()
 Resets a pointer (essentially assign NULL value)
void reset (T *obj)
 re-sets the pointer to point to the new object
template<class to >
SPtr< toSPtr_cast ()
 Attempts to dynamic cast to SmartPtr<to>

Private Member Functions

void decrease_reference ()

Private Attributes

Ptrptr

Constructor & Destructor Documentation

template<class T >
SPtr< T >::SPtr ( )

Default constructor.

Creates a null smart pointer

template<class T>
SPtr< T >::SPtr ( T *  something)

constructor

Example usage: SPtr<foo> = new foo();

Template Parameters
Tclass name
Parameters
somethingpointer to the new object
template<class T>
SPtr< T >::SPtr ( Ptr voidptr)
inline
template<class T>
SPtr< T >::SPtr ( const SPtr< T > &  ref)
template<class T >
SPtr< T >::~SPtr ( )

Member Function Documentation

template<class T >
void SPtr< T >::decrease_reference ( )
private
template<class T>
const T* SPtr< T >::get ( ) const
template<class T>
Ptr* SPtr< T >::getPtr ( )
inline
template<class T>
SPtr< T >::operator bool ( ) const
inline
template<class T >
T & SPtr< T >::operator* ( ) const

This template is used to dereference an object from SmartPtr.

Example usage:

SPtr<TDUID> duid1 = new TDUID("1234567890abcdef"); SPtr<TDUID> duid2 = new TDUID("12:34:56:78:90:ab:cd:ef"); EXPECT_TRUE(*duid1 == *duid2);

Todo:
: throw here if: ptr is NULL ptr->ptr is NULL
template<class T >
T * SPtr< T >::operator-> ( ) const

This template is used to access an object using SmartPtr.

Example usage:

SPtr<TDUID> duid1 = new TDUID("1234567890abcdef"); ASSERT_EQ(8u, duid1->getLen());

template<class T >
SPtr< T > & SPtr< T >::operator= ( const SPtr< T > &  old)
template<class T >
int SPtr< T >::refCount ( )
template<class T>
void SPtr< T >::reset ( )
inline

Resets a pointer (essentially assign NULL value)

template<class T>
void SPtr< T >::reset ( T *  obj)
inline

re-sets the pointer to point to the new object

Parameters
objpointer to the new object (may be NULL)
template<class T>
template<class to >
SPtr<to> SPtr< T >::SPtr_cast ( )
inline

Attempts to dynamic cast to SmartPtr<to>

Template Parameters
toderived class
Returns
SmartPtr to the derived class (or NULL if cast failed)

Member Data Documentation

template<class T>
Ptr* SPtr< T >::ptr
private

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