\hypertarget{classDispatcher}{
\section{Dispatcher Class Reference}
\label{classDispatcher}\index{Dispatcher@{Dispatcher}}
}


Link between elements and operations.  




{\ttfamily \#include $<$dispatcher.hh$>$}

\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{classDispatcher_1_1OpNotFound}{OpNotFound}
\begin{DoxyCompactList}\small\item\em Exception thrown if no operation is found for given arguments. \item\end{DoxyCompactList}\item 
union \hyperlink{unionDispatcher_1_1Value}{Value}
\end{DoxyCompactItemize}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDispatcher_a99bac838d7f6c1ad4ca977cf8f6d9f2e}{
typedef vector$<$ const \hyperlink{classElement}{Element} $\ast$ $>$ {\bfseries ArgList}}
\label{classDispatcher_a99bac838d7f6c1ad4ca977cf8f6d9f2e}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$class L , class R , Element $\ast$($\ast$)(const L \&, const R \&) funct$>$ }\\void \hyperlink{classDispatcher_a1021d5cb4250a09005ceb8fa8c6bb5a1}{add} (const \hyperlink{classBinOper}{BinOper} \&op)
\begin{DoxyCompactList}\small\item\em Method to register a binary operation callback with dispatcher. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$class T , Element $\ast$($\ast$)(const T \&) funct$>$ }\\void \hyperlink{classDispatcher_adebead5d69a63b17a6ae6f5dd7d99e1e}{add} (const \hyperlink{classUnOper}{UnOper} \&op)
\begin{DoxyCompactList}\small\item\em Method to register a unary operation callback with dispatcher. \item\end{DoxyCompactList}\item 
\hyperlink{classElement}{Element} $\ast$ \hyperlink{classDispatcher_a66bbd93d5ce4b2ca14c3d18b19386dd0}{run} (const \hyperlink{classOper}{Oper} \&op, unsigned argc, const \hyperlink{classElement}{Element} $\ast$$\ast$argv) const 
\begin{DoxyCompactList}\small\item\em Execute an n-\/ary operation. \item\end{DoxyCompactList}\item 
\hyperlink{classElement}{Element} $\ast$ \hyperlink{classDispatcher_ac0d40e4b36e8c882ba149765bc722878}{run} (const \hyperlink{classUnOper}{UnOper} \&op, const \hyperlink{classElement}{Element} \&arg) const 
\begin{DoxyCompactList}\small\item\em Execute an unary operation. \item\end{DoxyCompactList}\item 
\hyperlink{classElement}{Element} $\ast$ \hyperlink{classDispatcher_ae388de4022547819dbafd898e646285e}{run} (const \hyperlink{classBinOper}{BinOper} \&op, const \hyperlink{classElement}{Element} \&left, const \hyperlink{classElement}{Element} \&right) const 
\begin{DoxyCompactList}\small\item\em Execute a binary operation. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDispatcher_ac26b2373abe194a1c0b3121c2229f788}{
typedef \hyperlink{classElement}{Element} $\ast$($\ast$ {\bfseries CB\_\-bin} )(const \hyperlink{classElement}{Element} \&, const \hyperlink{classElement}{Element} \&)}
\label{classDispatcher_ac26b2373abe194a1c0b3121c2229f788}

\item 
\hypertarget{classDispatcher_aa073965f192d6e4f9731c0904090059d}{
typedef \hyperlink{classElement}{Element} $\ast$($\ast$ {\bfseries CB\_\-un} )(const \hyperlink{classElement}{Element} \&)}
\label{classDispatcher_aa073965f192d6e4f9731c0904090059d}

\item 
\hypertarget{classDispatcher_a88f64efa21abfbb22bad46107b85b33d}{
typedef unsigned {\bfseries Key}}
\label{classDispatcher_a88f64efa21abfbb22bad46107b85b33d}

\item 
\hypertarget{classDispatcher_ac4c6efc018e2caa94b5b9c25dafdb9c6}{
typedef map$<$ Key, \hyperlink{unionDispatcher_1_1Value}{Value} $>$ {\bfseries Map}}
\label{classDispatcher_ac4c6efc018e2caa94b5b9c25dafdb9c6}

\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
Key \hyperlink{classDispatcher_a5af31ee5fad703cea5516d4754ac7cfb}{makeKey} (const \hyperlink{classOper}{Oper} \&op, unsigned argc, const \hyperlink{classElement}{Element} $\ast$$\ast$argv) const 
\begin{DoxyCompactList}\small\item\em Create a key for \hyperlink{protocolthe-p}{the} callback table based on operation and arguments. \item\end{DoxyCompactList}\item 
\hyperlink{unionDispatcher_1_1Value}{Value} \hyperlink{classDispatcher_aa7c7c4edbd35298f70d5dd0910cf15f0}{lookup} (const \hyperlink{classOper}{Oper} \&op, unsigned argc, const \hyperlink{classElement}{Element} $\ast$$\ast$argv) const 
\begin{DoxyCompactList}\small\item\em Lookup a callback for \hyperlink{protocolthe-p}{the} requested operation and elements. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDispatcher_afe837a43ac563af968ea040bf0b8b22b}{
static \hyperlink{unionDispatcher_1_1Value}{Value} {\bfseries \_\-map} \mbox{[}32768\mbox{]}}
\label{classDispatcher_afe837a43ac563af968ea040bf0b8b22b}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Link between elements and operations. Executes operations on elments.

Implementation of multimethods. Insipred/copied from Alexandrescu \mbox{[}Modern C++ Design\mbox{]}.

By taking base element arguments and an operation, it will execute \hyperlink{protocolthe-p}{the} correct operation based on \hyperlink{protocolthe-p}{the} concrete type of \hyperlink{protocolthe-p}{the} arguments.

Similar to an \hyperlink{classElementFactory}{ElementFactory}. 

\subsection{Member Function Documentation}
\hypertarget{classDispatcher_a1021d5cb4250a09005ceb8fa8c6bb5a1}{
\index{Dispatcher@{Dispatcher}!add@{add}}
\index{add@{add}!Dispatcher@{Dispatcher}}
\subsubsection[{add}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class L , class R , Element $\ast$($\ast$)(const L \&, const R \&) funct$>$ void Dispatcher::add (
\begin{DoxyParamCaption}
\item[{const {\bf BinOper} \&}]{op}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classDispatcher_a1021d5cb4250a09005ceb8fa8c6bb5a1}


Method to register a binary operation callback with dispatcher. 


\begin{DoxyParams}{Parameters}
{\em L} & concrete class of first argument \\
\hline
{\em R} & concrete class of second argument \\
\hline
{\em funct} & function to be called to perform operation. \\
\hline
{\em op} & binary operation to be registered. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_adebead5d69a63b17a6ae6f5dd7d99e1e}{
\index{Dispatcher@{Dispatcher}!add@{add}}
\index{add@{add}!Dispatcher@{Dispatcher}}
\subsubsection[{add}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T , Element $\ast$($\ast$)(const T \&) funct$>$ void Dispatcher::add (
\begin{DoxyParamCaption}
\item[{const {\bf UnOper} \&}]{op}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classDispatcher_adebead5d69a63b17a6ae6f5dd7d99e1e}


Method to register a unary operation callback with dispatcher. 


\begin{DoxyParams}{Parameters}
{\em T} & concrete class of argument \\
\hline
{\em funct} & function to be called to perform operation. \\
\hline
{\em op} & unary operation to be registered. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_aa7c7c4edbd35298f70d5dd0910cf15f0}{
\index{Dispatcher@{Dispatcher}!lookup@{lookup}}
\index{lookup@{lookup}!Dispatcher@{Dispatcher}}
\subsubsection[{lookup}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Dispatcher::lookup (
\begin{DoxyParamCaption}
\item[{const {\bf Oper} \&}]{op, }
\item[{unsigned}]{argc, }
\item[{const {\bf Element} $\ast$$\ast$}]{argv}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, private\mbox{]}}}}
\label{classDispatcher_aa7c7c4edbd35298f70d5dd0910cf15f0}


Lookup a callback for \hyperlink{protocolthe-p}{the} requested operation and elements. 

Throws exception if none is found.

\begin{DoxyReturn}{Returns}
callback which will perform requested operation. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em op} & operation to perform. \\
\hline
{\em args} & \hyperlink{protocolthe-p}{the} arguments of \hyperlink{protocolthe-p}{the} operation. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_a5af31ee5fad703cea5516d4754ac7cfb}{
\index{Dispatcher@{Dispatcher}!makeKey@{makeKey}}
\index{makeKey@{makeKey}!Dispatcher@{Dispatcher}}
\subsubsection[{makeKey}]{\setlength{\rightskip}{0pt plus 5cm}Key Dispatcher::makeKey (
\begin{DoxyParamCaption}
\item[{const {\bf Oper} \&}]{op, }
\item[{unsigned}]{argc, }
\item[{const {\bf Element} $\ast$$\ast$}]{argv}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, private\mbox{]}}}}
\label{classDispatcher_a5af31ee5fad703cea5516d4754ac7cfb}


Create a key for \hyperlink{protocolthe-p}{the} callback table based on operation and arguments. 

\begin{DoxyReturn}{Returns}
key used for callback lookup. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em op} & requested operation. \\
\hline
{\em args} & \hyperlink{protocolthe-p}{the} arguments for \hyperlink{protocolthe-p}{the} operation. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_ac0d40e4b36e8c882ba149765bc722878}{
\index{Dispatcher@{Dispatcher}!run@{run}}
\index{run@{run}!Dispatcher@{Dispatcher}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Element} $\ast$ Dispatcher::run (
\begin{DoxyParamCaption}
\item[{const {\bf UnOper} \&}]{op, }
\item[{const {\bf Element} \&}]{arg}
\end{DoxyParamCaption}
) const}}
\label{classDispatcher_ac0d40e4b36e8c882ba149765bc722878}


Execute an unary operation. 

\begin{DoxyReturn}{Returns}
Result of operation. Caller is responsible for delete. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em op} & Operation to perform. \\
\hline
{\em arg} & Argument of operation. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_a66bbd93d5ce4b2ca14c3d18b19386dd0}{
\index{Dispatcher@{Dispatcher}!run@{run}}
\index{run@{run}!Dispatcher@{Dispatcher}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Element} $\ast$ Dispatcher::run (
\begin{DoxyParamCaption}
\item[{const {\bf Oper} \&}]{op, }
\item[{unsigned}]{argc, }
\item[{const {\bf Element} $\ast$$\ast$}]{argv}
\end{DoxyParamCaption}
) const}}
\label{classDispatcher_a66bbd93d5ce4b2ca14c3d18b19386dd0}


Execute an n-\/ary operation. 

Throws an exception on failure.

\begin{DoxyReturn}{Returns}
result of operation. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em op} & operation to dispatch. \\
\hline
{\em args} & arguments of operation. \\
\hline
\end{DoxyParams}
\hypertarget{classDispatcher_ae388de4022547819dbafd898e646285e}{
\index{Dispatcher@{Dispatcher}!run@{run}}
\index{run@{run}!Dispatcher@{Dispatcher}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Element} $\ast$ Dispatcher::run (
\begin{DoxyParamCaption}
\item[{const {\bf BinOper} \&}]{op, }
\item[{const {\bf Element} \&}]{left, }
\item[{const {\bf Element} \&}]{right}
\end{DoxyParamCaption}
) const}}
\label{classDispatcher_ae388de4022547819dbafd898e646285e}


Execute a binary operation. 

\begin{DoxyReturn}{Returns}
result of operation. Caller is responsible for delete. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em op} & Operation to perform. \\
\hline
{\em left} & first argument. \\
\hline
{\em right} & second argument. \\
\hline
\end{DoxyParams}


The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/policy/common/dispatcher.hh\item 
/home/greearb/git/xorp.ct.github/xorp/policy/common/dispatcher.cc\end{DoxyCompactItemize}
