\hypertarget{classref__ptr}{
\section{ref\_\-ptr$<$ \_\-Tp $>$ Class Template Reference}
\label{classref__ptr}\index{ref\_\-ptr@{ref\_\-ptr}}
}


Reference Counted Pointer Class.  




{\ttfamily \#include $<$ref\_\-ptr.hh$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classref__ptr_acf8a9a0b0124afbd9f12da43a1a49bbc}{ref\_\-ptr} (\_\-Tp $\ast$\_\-\_\-p=0)
\begin{DoxyCompactList}\small\item\em Construct a reference pointer for object. \item\end{DoxyCompactList}\item 
\hyperlink{classref__ptr_a35e3644e7b6beb3e7cf1971b5560225c}{ref\_\-ptr} (const \hyperlink{classref__ptr}{ref\_\-ptr} \&\_\-\_\-r)
\begin{DoxyCompactList}\small\item\em Copy Constructor. \item\end{DoxyCompactList}\item 
\hyperlink{classref__ptr}{ref\_\-ptr} \& \hyperlink{classref__ptr_a260dfcbdbb49a3628ebcfdb222c24037}{operator=} (const \hyperlink{classref__ptr}{ref\_\-ptr} \&\_\-\_\-r)
\begin{DoxyCompactList}\small\item\em Assignment Operator. \item\end{DoxyCompactList}\item 
\hyperlink{classref__ptr_af2c2205d1f491bec47662f01148f5aff}{$\sim$ref\_\-ptr} ()
\begin{DoxyCompactList}\small\item\em Destruct reference pointer instance and lower reference count on object being tracked. \item\end{DoxyCompactList}\item 
\_\-Tp \& \hyperlink{classref__ptr_ab1bc83471cb587dded067b92b2166335}{operator$\ast$} () const 
\begin{DoxyCompactList}\small\item\em Dereference reference counted object. \item\end{DoxyCompactList}\item 
\_\-Tp $\ast$ \hyperlink{classref__ptr_af653930ebd392101648e6711fe1fe86d}{operator-\/$>$} () const 
\begin{DoxyCompactList}\small\item\em Dereference pointer to reference counted object. \item\end{DoxyCompactList}\item 
\_\-Tp $\ast$ \hyperlink{classref__ptr_a547a9fc6819cf59c53361d963bc70b8d}{get} () const 
\begin{DoxyCompactList}\small\item\em Dereference pointer to reference counted object. \item\end{DoxyCompactList}\item 
bool \hyperlink{classref__ptr_a9beb243feffb249246f511433d99a555}{operator==} (const \hyperlink{classref__ptr}{ref\_\-ptr} \&rp) const 
\begin{DoxyCompactList}\small\item\em Equality Operator. \item\end{DoxyCompactList}\item 
bool \hyperlink{classref__ptr_ae31dea27b8165ef639e24c633dfb1b1b}{is\_\-empty} () const 
\begin{DoxyCompactList}\small\item\em Check if reference pointer refers to an object or whether it has been assigned a null object. \item\end{DoxyCompactList}\item 
bool \hyperlink{classref__ptr_ac22971682eabb8789351bc1ad663fc26}{is\_\-only} () const 
\item 
bool \hyperlink{classref__ptr_a27fe807c697ff2ebdf1a4ef1ac2c84c7}{at\_\-least} (int32\_\-t n) const 
\item 
void \hyperlink{classref__ptr_a7bb058812cbf4211d50178ab18f9ff5e}{release} () const 
\begin{DoxyCompactList}\small\item\em Release reference on object. \item\end{DoxyCompactList}\item 
\hypertarget{classref__ptr_a5a4ce43802aee247dff7db9704f1afe1}{
void {\bfseries reset} () const }
\label{classref__ptr_a5a4ce43802aee247dff7db9704f1afe1}

\item 
\hypertarget{classref__ptr_a586a5912b22448421ee5818b629c9550}{
{\bfseries ref\_\-ptr} (\_\-Tp $\ast$data, int32\_\-t index)}
\label{classref__ptr_a586a5912b22448421ee5818b629c9550}

\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classref__ptr_a3dbe9d0bf479d291205aefc2b6616ece}{
void \hyperlink{classref__ptr_a3dbe9d0bf479d291205aefc2b6616ece}{ref} (const \hyperlink{classref__ptr}{ref\_\-ptr} $\ast$\_\-\_\-r) const }
\label{classref__ptr_a3dbe9d0bf479d291205aefc2b6616ece}

\begin{DoxyCompactList}\small\item\em Add reference. \item\end{DoxyCompactList}\item 
\hypertarget{classref__ptr_a89f178acf8555e32ab1f23fc79685490}{
void \hyperlink{classref__ptr_a89f178acf8555e32ab1f23fc79685490}{unref} () const }
\label{classref__ptr_a89f178acf8555e32ab1f23fc79685490}

\begin{DoxyCompactList}\small\item\em Remove reference. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classref__ptr_a86c1d40488ded4c7187bcbb84ac82ba8}{
\_\-Tp $\ast$ {\bfseries \_\-M\_\-ptr}}
\label{classref__ptr_a86c1d40488ded4c7187bcbb84ac82ba8}

\item 
\hypertarget{classref__ptr_abe542d0be2068e98198b68a89754ee56}{
int32\_\-t {\bfseries \_\-M\_\-index}}
\label{classref__ptr_abe542d0be2068e98198b68a89754ee56}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class \_\-Tp$>$ class ref\_\-ptr$<$ \_\-Tp $>$}

Reference Counted Pointer Class. The \hyperlink{classref__ptr}{ref\_\-ptr} class is a strong reference class. It maintains a count of how many references to an object exist and releases \hyperlink{protocolthe-p}{the} memory associated with \hyperlink{protocolthe-p}{the} object when \hyperlink{protocolthe-p}{the} reference count reaches zero. The reference pointer can be dereferenced like an ordinary pointer to call methods on \hyperlink{protocolthe-p}{the} reference counted object.

At \hyperlink{protocolthe-p}{the} time of writing \hyperlink{protocolthe-p}{the} only supported memory management is through \hyperlink{protocolthe-p}{the} new and delete operators. At a future date, this class should support \hyperlink{protocolthe-p}{the} STL allocator classes or an equivalent to provide greater flexibility. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classref__ptr_acf8a9a0b0124afbd9f12da43a1a49bbc}{
\index{ref\_\-ptr@{ref\_\-ptr}!ref\_\-ptr@{ref\_\-ptr}}
\index{ref\_\-ptr@{ref\_\-ptr}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{ref\_\-ptr}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ {\bf ref\_\-ptr}$<$ \_\-Tp $>$::{\bf ref\_\-ptr} (
\begin{DoxyParamCaption}
\item[{\_\-Tp $\ast$}]{\_\-\_\-p = {\ttfamily 0}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_acf8a9a0b0124afbd9f12da43a1a49bbc}


Construct a reference pointer for object. 


\begin{DoxyParams}{Parameters}
{\em p} & pointer to object to be reference counted. p must be allocated using operator new as it will be destructed using delete when \hyperlink{protocolthe-p}{the} reference count reaches zero. \\
\hline
\end{DoxyParams}
\hypertarget{classref__ptr_a35e3644e7b6beb3e7cf1971b5560225c}{
\index{ref\_\-ptr@{ref\_\-ptr}!ref\_\-ptr@{ref\_\-ptr}}
\index{ref\_\-ptr@{ref\_\-ptr}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{ref\_\-ptr}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ {\bf ref\_\-ptr}$<$ \_\-Tp $>$::{\bf ref\_\-ptr} (
\begin{DoxyParamCaption}
\item[{const {\bf ref\_\-ptr}$<$ \_\-Tp $>$ \&}]{\_\-\_\-r}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a35e3644e7b6beb3e7cf1971b5560225c}


Copy Constructor. 

Constructs a reference pointer for object. Raises reference count associated with object by 1. \hypertarget{classref__ptr_af2c2205d1f491bec47662f01148f5aff}{
\index{ref\_\-ptr@{ref\_\-ptr}!$\sim$ref\_\-ptr@{$\sim$ref\_\-ptr}}
\index{$\sim$ref\_\-ptr@{$\sim$ref\_\-ptr}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{$\sim$ref\_\-ptr}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ {\bf ref\_\-ptr}$<$ \_\-Tp $>$::$\sim${\bf ref\_\-ptr} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_af2c2205d1f491bec47662f01148f5aff}


Destruct reference pointer instance and lower reference count on object being tracked. 

The object being tracked will be deleted if \hyperlink{protocolthe-p}{the} reference count falls to zero because of \hyperlink{protocolthe-p}{the} destruction of \hyperlink{protocolthe-p}{the} reference pointer. 

\subsection{Member Function Documentation}
\hypertarget{classref__ptr_a27fe807c697ff2ebdf1a4ef1ac2c84c7}{
\index{ref\_\-ptr@{ref\_\-ptr}!at\_\-least@{at\_\-least}}
\index{at\_\-least@{at\_\-least}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{at\_\-least}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ bool {\bf ref\_\-ptr}$<$ \_\-Tp $>$::at\_\-least (
\begin{DoxyParamCaption}
\item[{int32\_\-t}]{n}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a27fe807c697ff2ebdf1a4ef1ac2c84c7}

\begin{DoxyParams}{Parameters}
{\em n} & minimum count. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if there are at least n references to object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_a547a9fc6819cf59c53361d963bc70b8d}{
\index{ref\_\-ptr@{ref\_\-ptr}!get@{get}}
\index{get@{get}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{get}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ \_\-Tp$\ast$ {\bf ref\_\-ptr}$<$ \_\-Tp $>$::get (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a547a9fc6819cf59c53361d963bc70b8d}


Dereference pointer to reference counted object. 

\begin{DoxyReturn}{Returns}
pointer to object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_ae31dea27b8165ef639e24c633dfb1b1b}{
\index{ref\_\-ptr@{ref\_\-ptr}!is\_\-empty@{is\_\-empty}}
\index{is\_\-empty@{is\_\-empty}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{is\_\-empty}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ bool {\bf ref\_\-ptr}$<$ \_\-Tp $>$::is\_\-empty (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_ae31dea27b8165ef639e24c633dfb1b1b}


Check if reference pointer refers to an object or whether it has been assigned a null object. 

\begin{DoxyReturn}{Returns}
true if reference pointer refers to a null object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_ac22971682eabb8789351bc1ad663fc26}{
\index{ref\_\-ptr@{ref\_\-ptr}!is\_\-only@{is\_\-only}}
\index{is\_\-only@{is\_\-only}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{is\_\-only}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ bool {\bf ref\_\-ptr}$<$ \_\-Tp $>$::is\_\-only (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_ac22971682eabb8789351bc1ad663fc26}
\begin{DoxyReturn}{Returns}
true if reference pointer represents only reference to object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_ab1bc83471cb587dded067b92b2166335}{
\index{ref\_\-ptr@{ref\_\-ptr}!operator$\ast$@{operator$\ast$}}
\index{operator$\ast$@{operator$\ast$}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{operator$\ast$}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ \_\-Tp\& {\bf ref\_\-ptr}$<$ \_\-Tp $>$::operator$\ast$ (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_ab1bc83471cb587dded067b92b2166335}


Dereference reference counted object. 

\begin{DoxyReturn}{Returns}
reference to object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_af653930ebd392101648e6711fe1fe86d}{
\index{ref\_\-ptr@{ref\_\-ptr}!operator-\/$>$@{operator-\/$>$}}
\index{operator-\/$>$@{operator-\/$>$}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{operator-\/$>$}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ \_\-Tp$\ast$ {\bf ref\_\-ptr}$<$ \_\-Tp $>$::operator-\/$>$ (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_af653930ebd392101648e6711fe1fe86d}


Dereference pointer to reference counted object. 

\begin{DoxyReturn}{Returns}
pointer to object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_a260dfcbdbb49a3628ebcfdb222c24037}{
\index{ref\_\-ptr@{ref\_\-ptr}!operator=@{operator=}}
\index{operator=@{operator=}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{operator=}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ {\bf ref\_\-ptr}\& {\bf ref\_\-ptr}$<$ \_\-Tp $>$::operator= (
\begin{DoxyParamCaption}
\item[{const {\bf ref\_\-ptr}$<$ \_\-Tp $>$ \&}]{\_\-\_\-r}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a260dfcbdbb49a3628ebcfdb222c24037}


Assignment Operator. 

Assigns reference pointer to new object. \hypertarget{classref__ptr_a9beb243feffb249246f511433d99a555}{
\index{ref\_\-ptr@{ref\_\-ptr}!operator==@{operator==}}
\index{operator==@{operator==}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{operator==}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ bool {\bf ref\_\-ptr}$<$ \_\-Tp $>$::operator== (
\begin{DoxyParamCaption}
\item[{const {\bf ref\_\-ptr}$<$ \_\-Tp $>$ \&}]{rp}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a9beb243feffb249246f511433d99a555}


Equality Operator. 

\begin{DoxyReturn}{Returns}
true if reference pointers refer to same object. 
\end{DoxyReturn}
\hypertarget{classref__ptr_a7bb058812cbf4211d50178ab18f9ff5e}{
\index{ref\_\-ptr@{ref\_\-ptr}!release@{release}}
\index{release@{release}!ref_ptr@{ref\_\-ptr}}
\subsubsection[{release}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class \_\-Tp$>$ void {\bf ref\_\-ptr}$<$ \_\-Tp $>$::release (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classref__ptr_a7bb058812cbf4211d50178ab18f9ff5e}


Release reference on object. 

The reference pointers underlying object is set to null, and \hyperlink{protocolthe-p}{the} former object is destructed if necessary. 

The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/ref\_\-ptr.hh\end{DoxyCompactItemize}
