\doxysection{Units.\+hpp}
\hypertarget{Units_8hpp_source}{}\label{Units_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Units.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Units.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_UNITS\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_UNITS\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{00005\ }
\DoxyCodeLine{00006\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{double}\ M1,\ \textcolor{keywordtype}{double}\ Q1>\ \textcolor{keyword}{class\ }Length}
\DoxyCodeLine{00007\ \{}
\DoxyCodeLine{00008\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00009\ \ \ \ \ Length()\ \{\ \}}
\DoxyCodeLine{00010\ \ \ \ \ \textcolor{keyword}{explicit}\ Length(int32\_t\ i)\ :\ m(i)\ \{\ assert(int32\_t(m)\ ==\ i);\ \}}
\DoxyCodeLine{00011\ \ \ \ \ \textcolor{keyword}{explicit}\ Length(int64\_t\ i)\ :\ m(i)\ \{\ assert(int64\_t(m)\ ==\ i);\ \}}
\DoxyCodeLine{00012\ \ \ \ \ \textcolor{keyword}{explicit}\ Length(T\ v)\ :\ m(v)\ \{\ \}}
\DoxyCodeLine{00013\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keywordtype}{double}\ M2,\ \textcolor{keywordtype}{double}\ Q2>\ Length(\textcolor{keyword}{const}\ Length<T,\ M2,\ Q2>\ \&l)\ \{\ m\ =\ l.value()\ *\ ((M2\ *\ Q1)\ /\ (M1\ *\ Q2));\ \}}
\DoxyCodeLine{00014\ \ \ \ \ T\ value()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ m;\ \}}
\DoxyCodeLine{00015\ \ \ \ \ Length<T,M1,Q1>\ operator+(\textcolor{keyword}{const}\ Length<T,M1,Q1>\ \&l)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Length<T,M1,Q1>(m\ +\ l.m);\ \}}
\DoxyCodeLine{00016\ \ \ \ \ Length<T,M1,Q1>\ operator-\/(\textcolor{keyword}{const}\ Length<T,M1,Q1>\ \&l)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Length<T,M1,Q1>(m\ -\/\ l.m);\ \}}
\DoxyCodeLine{00017\ \ \ \ \ Length<T,M1,Q1>\&\ operator+=(\textcolor{keyword}{const}\ Length<T,M1,Q1>\ \&l)\ \{\ m\ +=\ l.m;\ \textcolor{keywordflow}{return}\ *\textcolor{keyword}{this};\ \}}
\DoxyCodeLine{00018\ \ \ \ \ Length<T,M1,Q1>\&\ operator-\/=(\textcolor{keyword}{const}\ Length<T,M1,Q1>\ \&l)\ \{\ m\ +=\ l.m;\ \textcolor{keywordflow}{return}\ *\textcolor{keyword}{this};\ \}}
\DoxyCodeLine{00019\ \ \ \ \ Length<T,M1,Q1>\ operator*(T\ s)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Length<T,M1,Q1>(m\ *\ s);\ \}}
\DoxyCodeLine{00020\ \ \ \ \ Length<T,M1,Q1>\&\ operator*=(T\ s)\ \{\ m\ *=\ s;\ \textcolor{keywordflow}{return}\ *\textcolor{keyword}{this};\ \}}
\DoxyCodeLine{00021\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keywordtype}{double}\ M2,\ \textcolor{keywordtype}{double}\ Q2>\ \textcolor{keywordtype}{bool}\ operator<\ (\textcolor{keyword}{const}\ Length<T,M2,Q2>\ \&l)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ value()\ *\ (M1\ *\ Q2)\ <\ \ l.value()\ *\ (Q1\ *\ M2);\ \}}
\DoxyCodeLine{00022\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keywordtype}{double}\ M2,\ \textcolor{keywordtype}{double}\ Q2>\ \textcolor{keywordtype}{bool}\ operator<=(\textcolor{keyword}{const}\ Length<T,M2,Q2>\ \&l)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ value()\ *\ (M1\ *\ Q2)\ <=\ l.value()\ *\ (Q1\ *\ M2);\ \}}
\DoxyCodeLine{00023\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keywordtype}{double}\ M2,\ \textcolor{keywordtype}{double}\ Q2>\ \textcolor{keywordtype}{bool}\ operator==(\textcolor{keyword}{const}\ Length<T,M2,Q2>\ \&l)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ value()\ *\ (M1\ *\ Q2)\ ==\ l.value()\ *\ (Q1\ *\ M2);\ \}}
\DoxyCodeLine{00024\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00025\ \ \ \ \ T\ m;}
\DoxyCodeLine{00026\ \};}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{double}\ M1,\ \textcolor{keywordtype}{double}\ Q1>\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{classLength}{Length<T,M1,Q1>}}\ \&l)}
\DoxyCodeLine{00029\ \{}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Q\ =\ M1\ /\ Q1;}
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *s\ =\ \textcolor{stringliteral}{"{}?"{}};}
\DoxyCodeLine{00032\ \ \ \ \ \textcolor{keywordflow}{if}\ (Q\ ==\ 1e-\/9)\ s\ =\ \textcolor{stringliteral}{"{}nm"{}};}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (Q\ ==\ 1e-\/6)\ s\ =\ \textcolor{stringliteral}{"{}µm"{}};}
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (Q\ ==\ 1)\ s\ =\ \textcolor{stringliteral}{"{}m"{}};}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ l.value()\ <<\ \textcolor{charliteral}{'\ '}\ <<\ s;}
\DoxyCodeLine{00036\ \}}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{keyword}{using\ }Meters\ \ \ \ \ \ \ =\ \mbox{\hyperlink{classLength}{Length}}<double,\ 1.0,\ 1.0>;}
\DoxyCodeLine{00039\ \textcolor{keyword}{using\ }Micrometers\ \ =\ \mbox{\hyperlink{classLength}{Length}}<double,\ 1.0,\ 1000000.0>;}
\DoxyCodeLine{00040\ \textcolor{keyword}{using\ }FMicrometers\ =\ \mbox{\hyperlink{classLength}{Length}}<float,\ \ 1.0,\ 1000000.0>;}
\DoxyCodeLine{00041\ \textcolor{keyword}{using\ }Nanometers\ \ \ =\ \mbox{\hyperlink{classLength}{Length}}<double,\ 1.0,\ 1000000000.0>;}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_UNITS\_H}}

\end{DoxyCode}
