#include <ptr.h>
Public Member Functions | |
Ptr () | |
Ptr (T *ptr) | |
Ptr (T *ptr, bool ref) | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
T * | PeekPointer (const Ptr< T > &p) |
template<typename T > | |
T * | GetPointer (const Ptr< T > &p) |
This smart-pointer class assumes that the underlying type provides a pair of Ref and Unref methods which are expected to increment and decrement the internal refcount of the object instance.
This implementation allows you to manipulate the smart pointer as if it was a normal pointer: you can compare it with zero, compare it against other pointers, assign zero to it, etc.
It is possible to extract the raw pointer from this smart pointer with the GetPointer and PeekPointer methods.
If you want to store a newed object into a smart pointer, we recommend you to use the Create template functions to create the object and store it in a smart pointer to avoid memory leaks. These functions are really small conveniance functions and their goal is just is save you a small bit of typing.
ptr | raw pointer to manage |
ptr | raw pointer to manage | |
ref | if set to true, this method calls Ref, otherwise, it does not call Ref. |
T * GetPointer | ( | const Ptr< T > & | p | ) | [related] |
References ns3::Ptr< T >::Acquire(), and ns3::Ptr< T >::m_ptr.
T * PeekPointer | ( | const Ptr< T > & | p | ) | [related] |
References ns3::Ptr< T >::m_ptr.