Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices

Smart pointer. More...

+ Collaboration diagram for Smart Pointer:

Classes

class  smart_ptr< T >
 Simple, standard smart pointer class. More...
 
class  smart_array_ptr< T >
 Simple, standard smart pointer class that uses the array delete operator. More...
 

Usage Information

Smart pointer.


Class Documentation

class smart_ptr

template<typename T>
class smart_ptr< T >

Simple, standard smart pointer class.

This class only supports the single-owner paradigm.

+ Collaboration diagram for smart_ptr< T >:

Public Types

typedef T data_type
 
typedef T * ptr_type
 
typedef const T * const_ptr_type
 
typedef T & ref_type
 
typedef const T & const_ref_type
 
typedef T data_type
 
typedef T * ptr_type
 
typedef const T * const_ptr_type
 
typedef T & ref_type
 
typedef const T & const_ref_type
 

Public Member Functions

 smart_ptr ()
 Default constuctor. Initialises with no pointer set.
 
 smart_ptr (ptr_type p)
 This constructor takes a pointer to the object to be deleted.
 
virtual ~smart_ptr ()
 
ptr_type get ()
 Return the current pointer value.
 
const_ptr_type get () const
 Return the const form of the current pointer value.
 
void set (ptr_type p)
 
void reset ()
 Dissociates any previously set pointer value without deleting it.
 
void clear ()
 Dissociates a previously set pointer value, deleting it at the same time.
 
virtual void safe_delete ()
 
 smart_ptr ()
 Default constuctor. Initialises with no pointer set.
 
 smart_ptr (ptr_type p)
 This constructor takes a pointer to the object to be deleted.
 
virtual ~smart_ptr ()
 
ptr_type get ()
 Return the current pointer value.
 
const_ptr_type get () const
 Return the const form of the current pointer value.
 
void set (ptr_type p)
 
void reset ()
 Dissociates any previously set pointer value without deleting it.
 
void clear ()
 Dissociates a previously set pointer value, deleting it at the same time.
 
virtual void safe_delete ()
 
Operators
 operator ptr_type ()
 Makes the object transparent as the template type.
 
 operator const_ptr_type () const
 Const version of the pointer operator.
 
 operator ref_type ()
 Makes the object transparent as a reference of the template type.
 
 operator const_ref_type () const
 Const version of the reference operator.
 
 operator bool () const
 Returns a boolean indicating whether the object has a pointer set or not.
 
smart_ptr< T > & operator= (const_ptr_type p)
 To allow setting the pointer directly. Equivalent to a call to set().
 
ptr_type operator-> ()
 Another operator to allow you to treat the object just like a pointer.
 
const_ptr_type operator-> () const
 Another operator to allow you to treat the object just like a pointer.
 
 operator ptr_type ()
 Makes the object transparent as the template type.
 
 operator const_ptr_type () const
 Const version of the pointer operator.
 
 operator ref_type ()
 Makes the object transparent as a reference of the template type.
 
 operator const_ref_type () const
 Const version of the reference operator.
 
 operator bool () const
 Returns a boolean indicating whether the object has a pointer set or not.
 
smart_ptr< T > & operator= (const_ptr_type p)
 To allow setting the pointer directly. Equivalent to a call to set().
 
ptr_type operator-> ()
 Another operator to allow you to treat the object just like a pointer.
 
const_ptr_type operator-> () const
 Another operator to allow you to treat the object just like a pointer.
 

Protected Attributes

ptr_type _p
 The wrapped pointer.
 

Constructor & Destructor Documentation

template<typename T>
virtual smart_ptr< T >::~smart_ptr ( )
inlinevirtual

Destructor. If an object (pointer) has been set, it will be deleted. Deletes the object using safe_delete().

template<typename T>
virtual smart_ptr< T >::~smart_ptr ( )
inlinevirtual

Destructor. If an object (pointer) has been set, it will be deleted. Deletes the object using safe_delete().

Member Function Documentation

template<typename T>
virtual void smart_ptr< T >::safe_delete ( )
inlinevirtual

Forces immediate deletion of the object. If you are planning on using this method, think about just using a normal pointer. It probably makes more sense.

template<typename T>
virtual void smart_ptr< T >::safe_delete ( )
inlinevirtual

Forces immediate deletion of the object. If you are planning on using this method, think about just using a normal pointer. It probably makes more sense.

template<typename T>
void smart_ptr< T >::set ( ptr_type  p)
inline

Change the pointer value, or set if if the default constructor was used. If a pointer had previously been associated with the object, and p is different than that previous pointer, it will be deleted before taking ownership of p. If this is not desired, call reset() beforehand.

template<typename T>
void smart_ptr< T >::set ( ptr_type  p)
inline

Change the pointer value, or set if if the default constructor was used. If a pointer had previously been associated with the object, and p is different than that previous pointer, it will be deleted before taking ownership of p. If this is not desired, call reset() beforehand.

class smart_array_ptr

template<typename T>
class smart_array_ptr< T >

Simple, standard smart pointer class that uses the array delete operator.

This class only supports the single-owner paradigm.

This is almost entirely a copy of smart_ptr since the final C++ specification does not allow template subclass members to access members of the parent that do not depend on the template parameter.

+ Collaboration diagram for smart_array_ptr< T >:

Public Types

typedef T data_type
 
typedef T * ptr_type
 
typedef const T * const_ptr_type
 
typedef T & ref_type
 
typedef const T & const_ref_type
 
typedef T data_type
 
typedef T * ptr_type
 
typedef const T * const_ptr_type
 
typedef T & ref_type
 
typedef const T & const_ref_type
 

Public Member Functions

 smart_array_ptr ()
 Default constuctor. Initialises with no pointer set.
 
 smart_array_ptr (ptr_type p)
 This constructor takes a pointer to the object to be deleted.
 
virtual ~smart_array_ptr ()
 
ptr_type get ()
 Return the current pointer value.
 
const_ptr_type get () const
 Return the const form of the current pointer value.
 
void set (ptr_type p)
 
void reset ()
 Dissociates any previously set pointer value without deleting it.
 
void clear ()
 Dissociates a previously set pointer value, deleting it at the same time.
 
virtual void safe_delete ()
 
 smart_array_ptr ()
 Default constuctor. Initialises with no pointer set.
 
 smart_array_ptr (ptr_type p)
 This constructor takes a pointer to the object to be deleted.
 
virtual ~smart_array_ptr ()
 
ptr_type get ()
 Return the current pointer value.
 
const_ptr_type get () const
 Return the const form of the current pointer value.
 
void set (ptr_type p)
 
void reset ()
 Dissociates any previously set pointer value without deleting it.
 
void clear ()
 Dissociates a previously set pointer value, deleting it at the same time.
 
virtual void safe_delete ()
 
Operators
 operator ptr_type ()
 Makes the object transparent as the template type.
 
 operator const_ptr_type () const
 Const version of the pointer operator.
 
 operator ref_type ()
 Makes the object transparent as a reference of the template type.
 
 operator const_ref_type () const
 Const version of the reference operator.
 
 operator bool () const
 Returns a boolean indicating whether the object has a pointer set or not.
 
smart_array_ptr< T > & operator= (const_ptr_type p)
 To allow setting the pointer directly. Equivalent to a call to set().
 
ptr_type operator-> ()
 Another operator to allow you to treat the object just like a pointer.
 
const_ptr_type operator-> () const
 Another operator to allow you to treat the object just like a pointer.
 
ref_type operator[] (unsigned index)
 Indexing operator.
 
const_ref_type operator[] (unsigned index) const
 Indexing operator.
 
 operator ptr_type ()
 Makes the object transparent as the template type.
 
 operator const_ptr_type () const
 Const version of the pointer operator.
 
 operator ref_type ()
 Makes the object transparent as a reference of the template type.
 
 operator const_ref_type () const
 Const version of the reference operator.
 
 operator bool () const
 Returns a boolean indicating whether the object has a pointer set or not.
 
smart_array_ptr< T > & operator= (const_ptr_type p)
 To allow setting the pointer directly. Equivalent to a call to set().
 
ptr_type operator-> ()
 Another operator to allow you to treat the object just like a pointer.
 
const_ptr_type operator-> () const
 Another operator to allow you to treat the object just like a pointer.
 
ref_type operator[] (unsigned index)
 Indexing operator.
 
const_ref_type operator[] (unsigned index) const
 Indexing operator.
 

Protected Attributes

ptr_type _p
 The wrapped pointer.
 

Constructor & Destructor Documentation

template<typename T>
virtual smart_array_ptr< T >::~smart_array_ptr ( )
inlinevirtual

Destructor. If an array has been set, it will be deleted. Deletes the array using safe_delete().

template<typename T>
virtual smart_array_ptr< T >::~smart_array_ptr ( )
inlinevirtual

Destructor. If an array has been set, it will be deleted. Deletes the array using safe_delete().

Member Function Documentation

template<typename T>
virtual void smart_array_ptr< T >::safe_delete ( )
inlinevirtual

Forces immediate deletion of the object. If you are planning on using this method, think about just using a normal pointer. It probably makes more sense.

template<typename T>
virtual void smart_array_ptr< T >::safe_delete ( )
inlinevirtual

Forces immediate deletion of the object. If you are planning on using this method, think about just using a normal pointer. It probably makes more sense.

template<typename T>
void smart_array_ptr< T >::set ( ptr_type  p)
inline

Change the pointer value, or set if if the default constructor was used. If a pointer had previously been associated with the object, and p is different than that previous pointer, it will be deleted before taking ownership of p. If this is not desired, call reset() beforehand.

template<typename T>
void smart_array_ptr< T >::set ( ptr_type  p)
inline

Change the pointer value, or set if if the default constructor was used. If a pointer had previously been associated with the object, and p is different than that previous pointer, it will be deleted before taking ownership of p. If this is not desired, call reset() beforehand.