\hypertarget{classDependency}{
\section{Dependency$<$ T $>$ Class Template Reference}
\label{classDependency}\index{Dependency@{Dependency}}
}


A class which relates objects and handles dependencies between them.  




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

Inheritance diagram for Dependency$<$ T $>$:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classDependency}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{classDependency_1_1DependencyError}{DependencyError}
\begin{DoxyCompactList}\small\item\em Exception thrown if an illegal action is requested. \item\end{DoxyCompactList}\item 
struct \hyperlink{structDependency_1_1ObjPair}{ObjPair}
\end{DoxyCompactItemize}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDependency_a860c148e389000dd87fc5a33602775d8}{
typedef list$<$ string $>$ {\bfseries DependencyList}}
\label{classDependency_a860c148e389000dd87fc5a33602775d8}

\item 
\hypertarget{classDependency_afd95bcf0d18f88cc453e870cdc96ec9d}{
typedef pair$<$ T $\ast$, DependencyList $>$ {\bfseries Pair}}
\label{classDependency_afd95bcf0d18f88cc453e870cdc96ec9d}

\item 
\hypertarget{classDependency_a8e20cca1a44566256737f28cad58c392}{
typedef map$<$ string, Pair $\ast$ $>$ {\bfseries Map}}
\label{classDependency_a8e20cca1a44566256737f28cad58c392}

\item 
\hypertarget{classDependency_afbf7302be4322d318b9d3e841951842d}{
typedef set$<$ string $>$ {\bfseries KEYS}}
\label{classDependency_afbf7302be4322d318b9d3e841951842d}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDependency_ab880e87e7187dc199008d4949ccccc8e}{
void {\bfseries clear} ()}
\label{classDependency_ab880e87e7187dc199008d4949ccccc8e}

\item 
bool \hyperlink{classDependency_ac9b4b86a9e6779bfe38a174e714bff5a}{exists} (const string \&objectname) const 
\begin{DoxyCompactList}\small\item\em Checks if an object is present in \hyperlink{protocolthe-p}{the} container. \item\end{DoxyCompactList}\item 
bool \hyperlink{classDependency_a9bf5579b65776065226b3d01b3dea1ae}{create} (const string \&objectname, T $\ast$object)
\begin{DoxyCompactList}\small\item\em Attempts to create an object. \item\end{DoxyCompactList}\item 
void \hyperlink{classDependency_a97372c4a29c7ddef46634a5d2ba32714}{remove} (const string \&objectname)
\begin{DoxyCompactList}\small\item\em Tries to remove and delete an object. \item\end{DoxyCompactList}\item 
void \hyperlink{classDependency_a2a6462f75c9bc860b11b4592bc259e98}{add\_\-dependency} (const string \&objectname, const string \&dep)
\begin{DoxyCompactList}\small\item\em Adds dependencies to this object. \item\end{DoxyCompactList}\item 
void \hyperlink{classDependency_a21865228456fd8574b604c28c4a05bc8}{del\_\-dependency} (const string \&objectname, const string \&dep)
\begin{DoxyCompactList}\small\item\em Deletes a dependency on an object. \item\end{DoxyCompactList}\item 
T \& \hyperlink{classDependency_aee68e3511394a0e8fdf801acff13897c}{find} (const string \&objectname) const 
\begin{DoxyCompactList}\small\item\em Returns \hyperlink{protocolthe-p}{the} object being searched for. \item\end{DoxyCompactList}\item 
T $\ast$ \hyperlink{classDependency_a4188f8607ff75bfb14e9671fa6d276ba}{find\_\-ptr} (const string \&objectname) const 
\begin{DoxyCompactList}\small\item\em Returns a pointer \hyperlink{protocolthe-p}{the} object being searched for. \item\end{DoxyCompactList}\item 
void \hyperlink{classDependency_ac8068775602245411ec7796223ed788e}{get\_\-deps} (const string \&objectname, set$<$ string $>$ \&deps) const 
\begin{DoxyCompactList}\small\item\em Obtains \hyperlink{protocolthe-p}{the} dependency list for an object. \item\end{DoxyCompactList}\item 
void \hyperlink{classDependency_a077e040af92926b1f7978c756614c166}{update\_\-object} (const string \&objectname, T $\ast$obj)
\begin{DoxyCompactList}\small\item\em Replaces an object. \item\end{DoxyCompactList}\item 
Map::const\_\-iterator \hyperlink{classDependency_ac496bcb6de6b1239406f8e02b2e9ec8b}{get\_\-iterator} () const 
\begin{DoxyCompactList}\small\item\em Obtain an iterator for this container. \item\end{DoxyCompactList}\item 
bool \hyperlink{classDependency_a3106ed537ac0fc44607c699851a969d3}{has\_\-next} (const typename Map::const\_\-iterator \&i) const 
\begin{DoxyCompactList}\small\item\em Checks if more objects are available with this iterator. \item\end{DoxyCompactList}\item 
\hyperlink{structDependency_1_1ObjPair}{ObjPair} \hyperlink{classDependency_a45ac91e32a4e870821d4a2e15a29fc2e}{next} (typename Map::const\_\-iterator \&i) const 
\begin{DoxyCompactList}\small\item\em Returns \hyperlink{protocolthe-p}{the} next object pair and increments \hyperlink{protocolthe-p}{the} iterator. \item\end{DoxyCompactList}\item 
\hypertarget{classDependency_aac96ddbcb6c9c0a237b32197e8f9db78}{
void {\bfseries keys} (KEYS \&out) const }
\label{classDependency_aac96ddbcb6c9c0a237b32197e8f9db78}

\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDependency_a612ca03e008df6a293b3cd4c476930f2}{
Pair $\ast$ {\bfseries findDepend} (const string \&objectname) const }
\label{classDependency_a612ca03e008df6a293b3cd4c476930f2}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classDependency_a28d3945e12f48825173320b2c99707ce}{
Map {\bfseries \_\-map}}
\label{classDependency_a28d3945e12f48825173320b2c99707ce}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class T$>$ class Dependency$<$ T $>$}

A class which relates objects and handles dependencies between them. This class is a container of objects \mbox{[}pointers\mbox{]}. It relates string object names to \hyperlink{protocolthe-p}{the} actual objects. Also, it has \hyperlink{protocolthe-p}{the} ability to add and remove dependencies to that objects. A dependency is some entity which is using a specific object in \hyperlink{protocolthe-p}{the} \hyperlink{classDependency}{Dependency} container. This entity is string represented.

For example, if a policy x uses set y, Set y will have x added in its dependencies. This means that x depends on y.

Having a consistent dependency list allows objects to be deleted correctly. 

\subsection{Member Function Documentation}
\hypertarget{classDependency_a2a6462f75c9bc860b11b4592bc259e98}{
\index{Dependency@{Dependency}!add\_\-dependency@{add\_\-dependency}}
\index{add\_\-dependency@{add\_\-dependency}!Dependency@{Dependency}}
\subsubsection[{add\_\-dependency}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ void {\bf Dependency}$<$ T $>$::add\_\-dependency (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname, }
\item[{const string \&}]{dep}
\end{DoxyParamCaption}
)}}
\label{classDependency_a2a6462f75c9bc860b11b4592bc259e98}


Adds dependencies to this object. 

A dependency is another object which uses this object.

Throws an exception if object does not exist.


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object to which dependency should be added. \\
\hline
{\em dep} & name of object which depends on objectname. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_a9bf5579b65776065226b3d01b3dea1ae}{
\index{Dependency@{Dependency}!create@{create}}
\index{create@{create}!Dependency@{Dependency}}
\subsubsection[{create}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T$>$ bool {\bf Dependency}$<$ T $>$::create (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname, }
\item[{T $\ast$}]{object}
\end{DoxyParamCaption}
)}}
\label{classDependency_a9bf5579b65776065226b3d01b3dea1ae}


Attempts to create an object. 

If creation is successfull, \hyperlink{protocolthe-p}{the} object ownership is transfered to this container. The caller should not modify / delete \hyperlink{protocolthe-p}{the} object any more.

If object exists, creation fails.

\begin{DoxyReturn}{Returns}
true if creation was successful. False otherwise. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em objectname} & name of \hyperlink{protocolthe-p}{the} object. \\
\hline
{\em object} & \hyperlink{protocolthe-p}{the} actual object. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_a21865228456fd8574b604c28c4a05bc8}{
\index{Dependency@{Dependency}!del\_\-dependency@{del\_\-dependency}}
\index{del\_\-dependency@{del\_\-dependency}!Dependency@{Dependency}}
\subsubsection[{del\_\-dependency}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ void {\bf Dependency}$<$ T $>$::del\_\-dependency (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname, }
\item[{const string \&}]{dep}
\end{DoxyParamCaption}
)}}
\label{classDependency_a21865228456fd8574b604c28c4a05bc8}


Deletes a dependency on an object. 

Throws an exception if object does not exist.


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object to which dependency should be removed. \\
\hline
{\em dep} & name of dependency to remove. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_ac9b4b86a9e6779bfe38a174e714bff5a}{
\index{Dependency@{Dependency}!exists@{exists}}
\index{exists@{exists}!Dependency@{Dependency}}
\subsubsection[{exists}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ bool {\bf Dependency}$<$ T $>$::exists (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname}
\end{DoxyParamCaption}
) const}}
\label{classDependency_ac9b4b86a9e6779bfe38a174e714bff5a}


Checks if an object is present in \hyperlink{protocolthe-p}{the} container. 

\begin{DoxyReturn}{Returns}
true if object is contained. False otherwise. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em objectname} & name of \hyperlink{protocolthe-p}{the} object. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_aee68e3511394a0e8fdf801acff13897c}{
\index{Dependency@{Dependency}!find@{find}}
\index{find@{find}!Dependency@{Dependency}}
\subsubsection[{find}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ T \& {\bf Dependency}$<$ T $>$::find (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname}
\end{DoxyParamCaption}
) const}}
\label{classDependency_aee68e3511394a0e8fdf801acff13897c}


Returns \hyperlink{protocolthe-p}{the} object being searched for. 


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object to return. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
object requested. 
\end{DoxyReturn}
\hypertarget{classDependency_a4188f8607ff75bfb14e9671fa6d276ba}{
\index{Dependency@{Dependency}!find\_\-ptr@{find\_\-ptr}}
\index{find\_\-ptr@{find\_\-ptr}!Dependency@{Dependency}}
\subsubsection[{find\_\-ptr}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ T $\ast$ {\bf Dependency}$<$ T $>$::find\_\-ptr (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname}
\end{DoxyParamCaption}
) const}}
\label{classDependency_a4188f8607ff75bfb14e9671fa6d276ba}


Returns a pointer \hyperlink{protocolthe-p}{the} object being searched for. 


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object to return. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to \hyperlink{protocolthe-p}{the} object requested if found, otherwise NULL. 
\end{DoxyReturn}
\hypertarget{classDependency_ac8068775602245411ec7796223ed788e}{
\index{Dependency@{Dependency}!get\_\-deps@{get\_\-deps}}
\index{get\_\-deps@{get\_\-deps}!Dependency@{Dependency}}
\subsubsection[{get\_\-deps}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ void {\bf Dependency}$<$ T $>$::get\_\-deps (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname, }
\item[{set$<$ string $>$ \&}]{deps}
\end{DoxyParamCaption}
) const}}
\label{classDependency_ac8068775602245411ec7796223ed788e}


Obtains \hyperlink{protocolthe-p}{the} dependency list for an object. 

Duplicates are removed, as it is a set.


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object for which dependency list is requested. \\
\hline
{\em deps} & set of strings filled with dependency list. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_ac496bcb6de6b1239406f8e02b2e9ec8b}{
\index{Dependency@{Dependency}!get\_\-iterator@{get\_\-iterator}}
\index{get\_\-iterator@{get\_\-iterator}!Dependency@{Dependency}}
\subsubsection[{get\_\-iterator}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ {\bf Dependency}$<$ T $>$::Map::const\_\-iterator {\bf Dependency}$<$ T $>$::get\_\-iterator (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}
\label{classDependency_ac496bcb6de6b1239406f8e02b2e9ec8b}


Obtain an iterator for this container. 

\begin{DoxyReturn}{Returns}
iterator for \hyperlink{classDependency}{Dependency} container. 
\end{DoxyReturn}
\hypertarget{classDependency_a3106ed537ac0fc44607c699851a969d3}{
\index{Dependency@{Dependency}!has\_\-next@{has\_\-next}}
\index{has\_\-next@{has\_\-next}!Dependency@{Dependency}}
\subsubsection[{has\_\-next}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ bool {\bf Dependency}$<$ T $>$::has\_\-next (
\begin{DoxyParamCaption}
\item[{const typename Map::const\_\-iterator \&}]{i}
\end{DoxyParamCaption}
) const}}
\label{classDependency_a3106ed537ac0fc44607c699851a969d3}


Checks if more objects are available with this iterator. 

\begin{DoxyReturn}{Returns}
true if more objects are available. False otherwise. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em i} & iterator to use. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_a45ac91e32a4e870821d4a2e15a29fc2e}{
\index{Dependency@{Dependency}!next@{next}}
\index{next@{next}!Dependency@{Dependency}}
\subsubsection[{next}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ {\bf Dependency}$<$ T $>$::{\bf ObjPair} {\bf Dependency}$<$ T $>$::next (
\begin{DoxyParamCaption}
\item[{typename Map::const\_\-iterator \&}]{i}
\end{DoxyParamCaption}
) const}}
\label{classDependency_a45ac91e32a4e870821d4a2e15a29fc2e}


Returns \hyperlink{protocolthe-p}{the} next object pair and increments \hyperlink{protocolthe-p}{the} iterator. 

An object pair consists of \hyperlink{protocolthe-p}{the} object name, and \hyperlink{protocolthe-p}{the} actual object.

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} object pair associated with \hyperlink{protocolthe-p}{the} iterator. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em i} & iterator that points to object. Iterator is then incremented. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_a97372c4a29c7ddef46634a5d2ba32714}{
\index{Dependency@{Dependency}!remove@{remove}}
\index{remove@{remove}!Dependency@{Dependency}}
\subsubsection[{remove}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T $>$ void {\bf Dependency}$<$ T $>$::remove (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname}
\end{DoxyParamCaption}
)}}
\label{classDependency_a97372c4a29c7ddef46634a5d2ba32714}


Tries to remove and delete an object. 

Checks if object is in use \mbox{[}non empty dependency list\mbox{]}.

Throws an exception on failure.


\begin{DoxyParams}{Parameters}
{\em objectname} & object to remove and delete. \\
\hline
\end{DoxyParams}
\hypertarget{classDependency_a077e040af92926b1f7978c756614c166}{
\index{Dependency@{Dependency}!update\_\-object@{update\_\-object}}
\index{update\_\-object@{update\_\-object}!Dependency@{Dependency}}
\subsubsection[{update\_\-object}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T$>$ void {\bf Dependency}$<$ T $>$::update\_\-object (
\begin{DoxyParamCaption}
\item[{const string \&}]{objectname, }
\item[{T $\ast$}]{obj}
\end{DoxyParamCaption}
)}}
\label{classDependency_a077e040af92926b1f7978c756614c166}


Replaces an object. 

The previous one is deleted. Caller does not own object. Should not modify or delete it.

Throws an exception if object does not exist.


\begin{DoxyParams}{Parameters}
{\em objectname} & name of object to replace. \\
\hline
{\em obj} & \hyperlink{protocolthe-p}{the} new object. \\
\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/dependency.hh\item 
/home/greearb/git/xorp.ct.github/xorp/policy/dependency.cc\end{DoxyCompactItemize}
