\hypertarget{classHurricane_1_1Filter}{}\section{Hurricane\+:\+:Filter$<$ Type $>$ Class Template Reference}
\label{classHurricane_1_1Filter}\index{Hurricane\+::\+Filter$<$ Type $>$@{Hurricane\+::\+Filter$<$ Type $>$}}


\mbox{\hyperlink{classHurricane_1_1Filter}{Filter}} description ({\bfseries A\+PI})  




Inheritance diagram for Hurricane\+:\+:Filter$<$ Type $>$\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=320pt]{classHurricane_1_1Filter__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classHurricane_1_1GenericFilter}{Generic\+Filter}}$<$ Type $>$ \mbox{\hyperlink{classHurricane_1_1Filter_a90c1a8c4caf6c6018ff50f5b9754e061}{operator!}} () const
\item 
virtual \mbox{\hyperlink{classHurricane_1_1Filter}{Filter}}$<$ Type $>$ $\ast$ \mbox{\hyperlink{classHurricane_1_1Filter_a596cad421801115efbc5c541f8d29e0b}{get\+Clone}} () const =0
\item 
virtual bool \mbox{\hyperlink{classHurricane_1_1Filter_aeaa771f17950fe05273c471ccfffb7f7}{accept}} (Type type) const =0
\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class Type$>$\newline
class Hurricane\+::\+Filter$<$ Type $>$}

\mbox{\hyperlink{classHurricane_1_1Filter}{Filter}} description ({\bfseries A\+PI}) 

\hypertarget{classHurricane_1_1Filter_secFilterIntro}{}\subsection{Introduction}\label{classHurricane_1_1Filter_secFilterIntro}
A filter is a functional object which, used in conjunction with a collection, allows to get only the elements of this collection which meet some criteria.

This class is an abstract class which must be derived in order to get the appropriate behaviour.

You will have also to define the default constructor, the copy constructor, the assignment operator and overload the two following member functions \+:\hypertarget{classHurricane_1_1Filter_secFilterSimpleExample}{}\subsection{Simple Example}\label{classHurricane_1_1Filter_secFilterSimpleExample}
Definition of the filter selecting external nets of a cell \+: 
\begin{DoxyCode}
\textcolor{keyword}{class }IsExternal : \textcolor{keyword}{public} Filter<Net*> \{
\textcolor{comment}{// ***********************************}
 
   \textcolor{keyword}{public}:
 
      IsExternal() \{\};
 
      IsExternal(\textcolor{keyword}{const} IsExternal& isExternal) \{\};
 
      IsExternal& operator=(\textcolor{keyword}{const} IsExternal& isExternal) \{\textcolor{keywordflow}{return} *\textcolor{keyword}{this};\};
 
      \textcolor{keyword}{virtual} Filter<Net*>* \mbox{\hyperlink{classHurricane_1_1Filter_a596cad421801115efbc5c541f8d29e0b}{getClone}}()\textcolor{keyword}{ const }\{\textcolor{keywordflow}{return} \textcolor{keyword}{new} IsExternal(*\textcolor{keyword}{this});\};
 
      \textcolor{keyword}{virtual} \textcolor{keywordtype}{bool} \mbox{\hyperlink{classHurricane_1_1Filter_aeaa771f17950fe05273c471ccfffb7f7}{accept}}(Net* net)\textcolor{keyword}{ const }\{\textcolor{keywordflow}{return} net->isExternal();\};
 
\};
\end{DoxyCode}
 Implementation of the accessor {\bfseries get\+External\+Nets} for the cells \+: 
\begin{DoxyCode}
\mbox{\hyperlink{namespaceHurricane_a3404a8b17130a1824f4a281704b04df7}{Nets}} Cell::getExternalNet() const
\textcolor{comment}{// ******************************}
\{
   \textcolor{keywordflow}{return} getNets().getSubSet(IsExternal());
\}
\end{DoxyCode}
 Similarly, the accessor {\bfseries get\+Internal\+Nets} can be implemented using the {\bfseries !} operator \+: 
\begin{DoxyCode}
\mbox{\hyperlink{namespaceHurricane_a3404a8b17130a1824f4a281704b04df7}{Nets}} \mbox{\hyperlink{classHurricane_1_1Cell_a0da980d28ad60334da94a3966338f873}{Cell::getInternalNets}}() const
\textcolor{comment}{// *******************************}
\{
   \textcolor{keywordflow}{return} getNets().\mbox{\hyperlink{classHurricane_1_1Collection_aa32ea7249d57ee05e3c71dcde8106832}{getSubSet}}(!IsExternal());
\}
\end{DoxyCode}
\hypertarget{classHurricane_1_1Filter_secFilterComplexExample}{}\subsection{Complex Example}\label{classHurricane_1_1Filter_secFilterComplexExample}
In order to implement previous examples we could have used filter with a simpler interface. Now the filters as they are defined open the door to much more complex processing.

As a matter of fact the function {\bfseries accept} receives only one argument which represents the element of the collection to be accepted or rejected.

Sometimes the filter must take into account other criteria. For example to print the external nets of a cell whose name start with a given character. Those additional criteria will then become attributes of the filter as shown in the following example \+:

\mbox{\hyperlink{classHurricane_1_1Filter}{Filter}} definition \+: 
\begin{DoxyCode}
\textcolor{keyword}{class }MyFilter : \textcolor{keyword}{public} Filter<Net*> \{
\textcolor{comment}{// *********************************}
 
   \textcolor{keyword}{public}:
 
      \textcolor{keywordtype}{char} \_c;
 
      MyFilter(\textcolor{keywordtype}{char} c) : \_c(c) \{\};
 
      MyFilter(\textcolor{keyword}{const} MyFilter& myFilter) : \_c(myFilter.\_c) \{\};
 
      MyFilter& operator=(\textcolor{keyword}{const} MyFilter& myFilter)
      \{
         \_c = myFilter.\_c;
         \textcolor{keywordflow}{return} *\textcolor{keyword}{this};
      \};
 
      \textcolor{keyword}{virtual} Filter<Net*>* \mbox{\hyperlink{classHurricane_1_1Filter_a596cad421801115efbc5c541f8d29e0b}{getClone}}()\textcolor{keyword}{ const }\{\textcolor{keywordflow}{return} \textcolor{keyword}{new} MyFilter(*\textcolor{keyword}{this});\};
 
      \textcolor{keyword}{virtual} \textcolor{keywordtype}{bool} \mbox{\hyperlink{classHurricane_1_1Filter_aeaa771f17950fe05273c471ccfffb7f7}{accept}}(Net* net)\textcolor{keyword}{ const}
\textcolor{keyword}{      }\{
         \textcolor{keywordflow}{return} net->isExternal() && (net->getName()[0] == \_c);
      \};
 
\};
\end{DoxyCode}
 Afterwards do 
\begin{DoxyCode}
forEach(Net*, inet, cell->getNets().getSubSet(MyFilter(\textcolor{charliteral}{'k'}))) \{
   assert(inet->isExternal());
   assert(inet->getName()[0] == \textcolor{charliteral}{'k'});
   cerr << \textcolor{stringliteral}{"net: "} << (*inet) << endl;
\}
\end{DoxyCode}
 Although this example is not of great interest, it illustrates the way to proceed to create a complex filter. 

\subsection{Member Function Documentation}
\mbox{\Hypertarget{classHurricane_1_1Filter_a90c1a8c4caf6c6018ff50f5b9754e061}\label{classHurricane_1_1Filter_a90c1a8c4caf6c6018ff50f5b9754e061}} 
\index{Hurricane\+::\+Filter@{Hurricane\+::\+Filter}!operator"!@{operator"!}}
\index{operator"!@{operator"!}!Hurricane\+::\+Filter@{Hurricane\+::\+Filter}}
\subsubsection{\texorpdfstring{operator"!()}{operator!()}}
{\footnotesize\ttfamily template$<$class Type$>$ \\
\mbox{\hyperlink{classHurricane_1_1GenericFilter}{Generic\+Filter}}$<$ Type $>$ \mbox{\hyperlink{classHurricane_1_1Filter}{Hurricane\+::\+Filter}}$<$ Type $>$\+::operator! (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

{\bfseries Returns\+:} the inverse filter of the filter {\ttfamily $<$this$>$} (accepted elements are those rejected and conversely). \mbox{\Hypertarget{classHurricane_1_1Filter_a596cad421801115efbc5c541f8d29e0b}\label{classHurricane_1_1Filter_a596cad421801115efbc5c541f8d29e0b}} 
\index{Hurricane\+::\+Filter@{Hurricane\+::\+Filter}!get\+Clone@{get\+Clone}}
\index{get\+Clone@{get\+Clone}!Hurricane\+::\+Filter@{Hurricane\+::\+Filter}}
\subsubsection{\texorpdfstring{get\+Clone()}{getClone()}}
{\footnotesize\ttfamily template$<$class Type$>$ \\
\mbox{\hyperlink{classHurricane_1_1Filter}{Filter}}$<$ Type $>$ $\ast$ \mbox{\hyperlink{classHurricane_1_1Filter}{Hurricane\+::\+Filter}}$<$ Type $>$\+::get\+Clone (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [pure virtual]}}

\hypertarget{classHurricane_1_1Filter_secFilterRemarks}{}\subsection{Remarks}\label{classHurricane_1_1Filter_secFilterRemarks}
It is wise to use filters only when it is trully necessary, that is to produce useful collections to be used extensively.

Indeed, for the previous example, preferably write it like this \+: 
\begin{DoxyCode}
forEach(Net*, inet, cell->getNets()) \{
   \textcolor{keywordflow}{if} (inet->isExternal() && (inet->getName()[0] == \textcolor{charliteral}{'k'}))
      cerr << \textcolor{stringliteral}{"net: "} << *net << endl;
\}
\end{DoxyCode}
 or more simply \+: 
\begin{DoxyCode}
forEach(Net*, net, cell->getExternalNets()) \{
   \textcolor{keywordflow}{if} (inet->getName()[0] == \textcolor{charliteral}{'k'})
      cerr << \textcolor{stringliteral}{"net: "} << *inet << endl;
\}
\end{DoxyCode}
 Filters are objects like any other \+: they can be passed as function arguments as shown below \+: 
\begin{DoxyCode}
\mbox{\hyperlink{namespaceHurricane_a3404a8b17130a1824f4a281704b04df7}{Nets}} \mbox{\hyperlink{classHurricane_1_1Cell_a8b4728abe83e9ec21d7bee1154218279}{Cell::getNets}}(\textcolor{keyword}{const} GenericFilter<Net*>& filter) \textcolor{keyword}{const}
\textcolor{comment}{// ********************************************************}
\{
   \textcolor{keywordflow}{return} getNets().\mbox{\hyperlink{classHurricane_1_1Collection_aa32ea7249d57ee05e3c71dcde8106832}{getSubSet}}(filter);
\}
\end{DoxyCode}
 As far as the type {\bfseries Net\+Filter} is defined as being a {\bfseries \mbox{\hyperlink{classHurricane_1_1GenericFilter}{Generic\+Filter}}$<$Net$\ast$$>$} the previous function can be written like this \+: 
\begin{DoxyCode}
\mbox{\hyperlink{namespaceHurricane_a3404a8b17130a1824f4a281704b04df7}{Nets}} \mbox{\hyperlink{classHurricane_1_1Cell_a8b4728abe83e9ec21d7bee1154218279}{Cell::getNets}}(\textcolor{keyword}{const} \mbox{\hyperlink{namespaceHurricane_a0dfd2c5b40325a919d139091312732e9}{NetFilter}}& filter) \textcolor{keyword}{const}
\textcolor{comment}{// **********************************************}
\{
   \textcolor{keywordflow}{return} getNets().\mbox{\hyperlink{classHurricane_1_1Collection_aa32ea7249d57ee05e3c71dcde8106832}{getSubSet}}(filter);
\}
\end{DoxyCode}


{\bfseries Returns\+:} a filter copy. \mbox{\Hypertarget{classHurricane_1_1Filter_aeaa771f17950fe05273c471ccfffb7f7}\label{classHurricane_1_1Filter_aeaa771f17950fe05273c471ccfffb7f7}} 
\index{Hurricane\+::\+Filter@{Hurricane\+::\+Filter}!accept@{accept}}
\index{accept@{accept}!Hurricane\+::\+Filter@{Hurricane\+::\+Filter}}
\subsubsection{\texorpdfstring{accept()}{accept()}}
{\footnotesize\ttfamily template$<$class Type$>$ \\
bool \mbox{\hyperlink{classHurricane_1_1Filter}{Hurricane\+::\+Filter}}$<$ Type $>$\+::accept (\begin{DoxyParamCaption}\item[{Type}]{element }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [pure virtual]}}

This member function returns {\bfseries true} if the filter accepts the element else {\bfseries false}. 

The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
Filter.\+h\item 
Filter.\+dox\end{DoxyCompactItemize}
