\section{lcrtrel\-:\-:L\-C\-R\-T\-Relations Class Reference}
\label{classlcrtrel_1_1LCRTRelations}\index{lcrtrel\-::\-L\-C\-R\-T\-Relations@{lcrtrel\-::\-L\-C\-R\-T\-Relations}}


Base class that provides run time (user) extensions and relation between objects.  




{\ttfamily \#include $<$L\-C\-R\-T\-Relations.\-h$>$}

Inheritance diagram for lcrtrel\-:\-:L\-C\-R\-T\-Relations\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=12.000000cm]{classlcrtrel_1_1LCRTRelations}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$class V $>$ }\\V\-::ext\-\_\-type {\bf ext} ()\label{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808}

\begin{DoxyCompactList}\small\item\em Provides access to an extension object -\/ the type and ownership is defined by the class V which should be a subtype of \doxyref{L\-C\-Extension}{p.}{structlcrtrel_1_1LCExtension}, \doxyref{L\-C\-Owned\-Extension}{p.}{classlcrtrel_1_1LCOwnedExtension}, \doxyref{L\-C\-Extension\-Vector}{p.}{classlcrtrel_1_1LCExtensionVector}, \doxyref{L\-C\-Extension\-List}{p.}{classlcrtrel_1_1LCExtensionList},... \end{DoxyCompactList}\item 
{\footnotesize template$<$class V $>$ }\\const V\-::ext\-\_\-type {\bfseries ext} () const \label{classlcrtrel_1_1LCRTRelations_a083dcfac448d838e2dc13e636ddb8eb9}

\item 
{\footnotesize template$<$class V $>$ }\\V\-::rel\-\_\-type {\bf rel} ()\label{classlcrtrel_1_1LCRTRelations_a84ce135758f05cfa2844c221014ceae2}

\begin{DoxyCompactList}\small\item\em Provides read access to relations -\/ the object types and their connectivity are defined by the class V which has to be a subtype of either \doxyref{L\-C1\-To1\-Relation}{p.}{structlcrtrel_1_1LC1To1Relation}, \doxyref{L\-C1\-To\-N\-Relation}{p.}{structlcrtrel_1_1LC1ToNRelation} or \doxyref{L\-C\-N\-To\-N\-Relation}{p.}{structlcrtrel_1_1LCNToNRelation}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$class V $>$ }\\V\-::ptr \& {\bf ptr} () const \label{classlcrtrel_1_1LCRTRelations_a09571e8cf6eb0d9e2cb91e54c870c1ff}

\begin{DoxyCompactList}\small\item\em Returns the reference to the pointer to the extension/relation object. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$class R $>$ }\\void {\bf set\-\_\-relation} (typename R\-::from\-::obj\-\_\-ptr f, typename R\-::to\-::obj\-\_\-ptr t)
\begin{DoxyCompactList}\small\item\em Set the 1-\/to-\/1 relation between two objects -\/ prexisting inconsistent relations involving the two objects are deleted to enforce a consistent set of from-\/to relations. \end{DoxyCompactList}\item 
{\footnotesize template$<$class R $>$ }\\void {\bf unset\-\_\-relation} (typename R\-::from\-::obj\-\_\-ptr f)\label{classlcrtrel_1_1LCRTRelations_a3c659b6607079c9c541ae256c095436c}

\begin{DoxyCompactList}\small\item\em Unset the 1-\/to-\/1 relation from f. \end{DoxyCompactList}\item 
{\footnotesize template$<$class R $>$ }\\void {\bf add\-\_\-relation} (typename R\-::from\-::obj\-\_\-ptr f, typename R\-::to\-::obj\-\_\-ptr t)\label{classlcrtrel_1_1LCRTRelations_ab60918c35104b81a1eecb61531af0a16}

\begin{DoxyCompactList}\small\item\em Add a link from f to t to an N-\/to-\/\-N relation ship. \end{DoxyCompactList}\item 
{\footnotesize template$<$class R $>$ }\\void {\bf remove\-\_\-relation} (typename R\-::from\-::obj\-\_\-ptr f, typename R\-::to\-::obj\-\_\-ptr t)\label{classlcrtrel_1_1LCRTRelations_ad16d453cd9415bcf5b1524f2af1da631}

\begin{DoxyCompactList}\small\item\em Remove the link from from f to t from the N-\/to-\/\-N relation ship. \end{DoxyCompactList}\item 
{\footnotesize template$<$class R $>$ }\\void {\bf remove\-\_\-relations} (typename R\-::from\-::obj\-\_\-ptr f)\label{classlcrtrel_1_1LCRTRelations_a711ea8e37e4990e6588b2ab608daa072}

\begin{DoxyCompactList}\small\item\em Removes all relations from the given object. \end{DoxyCompactList}\item 
{\footnotesize template$<$class R $>$ }\\void {\bf merge\-\_\-relations} (typename R\-::from\-::obj\-\_\-ptr f1, typename R\-::from\-::obj\-\_\-ptr f2)\label{classlcrtrel_1_1LCRTRelations_ae2d546bef410f997133cd3ed99a98067}

\begin{DoxyCompactList}\small\item\em Merge the relations from f2 to f1 -\/ after this call f1 will hold all the relations and f2 will be empty. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Base class that provides run time (user) extensions and relation between objects. 

Every subclass object of \doxyref{L\-C\-R\-T\-Relations}{p.}{classlcrtrel_1_1LCRTRelations} (and thus L\-C\-Obbject) will automatically have the following functionality\-:\par
 
\begin{DoxyItemize}
\item extension of the object with arbitrary (even non-\/\-L\-C\-Object) classes 
\item extension of single objects or vectors, lists of objects 
\item optionally ownership is taken for extension objects (memory management) 
\item relations to other subclasses of \doxyref{L\-C\-R\-T\-Relations}{p.}{classlcrtrel_1_1LCRTRelations}\-: 
\begin{DoxyItemize}
\item one to one 
\item one to many 
\item many to many 
\end{DoxyItemize}
\end{DoxyItemize}

The described functionality is provided through the two templated member functions\-:\par
 \doxyref{ext$<$class V$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808} \par
 \doxyref{rel$<$class V$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a84ce135758f05cfa2844c221014ceae2} \par
 the class V is a user defined so called traits class, that uniquely tags the extension/relationship and defines the types of the objects involved. \par
 For extensions users have to subclass one of the following classes\-:\par
 \doxyref{L\-C\-Extension}{p.}{structlcrtrel_1_1LCExtension}, \doxyref{L\-C\-Owned\-Extension}{p.}{classlcrtrel_1_1LCOwnedExtension}, \doxyref{L\-C\-Int\-Extension}{p.}{structlcrtrel_1_1LCIntExtension}, \doxyref{L\-C\-Float\-Extension}{p.}{structlcrtrel_1_1LCFloatExtension},\par
 \doxyref{L\-C\-Extension\-Vector}{p.}{classlcrtrel_1_1LCExtensionVector}, \doxyref{L\-C\-Extension\-List}{p.}{classlcrtrel_1_1LCExtensionList}, \doxyref{L\-C\-Owned\-Extension\-Vector}{p.}{classlcrtrel_1_1LCOwnedExtensionVector}, \doxyref{L\-C\-Owned\-Extension\-List}{p.}{classlcrtrel_1_1LCOwnedExtensionList}. \par
 For example the following defines a user extension of a vector of strings that are owned by the object (i.\-e. deleted when the object is deleted)\-:\par
 

{\bfseries  struct \doxyref{Particle\-I\-Ds}{p.}{structParticleIDs} \-: L\-C\-Owned\-Extension\-Vector$<$\-Particle\-I\-Ds, std\-::string$>$ \{\};\par
 } ~~~(note\-: the first template parameter has to be the class itself !) 

This extension can then be used anywhere in the following code for all L\-C\-Objects, e.\-g.\-:\par
 

{\bfseries  M\-C\-Particle$\ast$ mcp = dynamic\-\_\-cast$<$\-M\-C\-Particle$\ast$$>$( mcpcol-\/$>$get\-Element\-At(i) ) ;\par
 mcp-\/$>$\doxyref{ext$<$\-Particle\-I\-Ds$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808}-\/$>$push\-\_\-back( new std\-::string(\char`\"{}charged\char`\"{}) ) ;\par
 mcp-\/$>$\doxyref{ext$<$\-Particle\-I\-Ds$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808}-\/$>$push\-\_\-back( new std\-::string(\char`\"{}hadron\char`\"{}) ) ;\par
 mcp-\/$>$\doxyref{ext$<$\-Particle\-I\-Ds$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808}-\/$>$push\-\_\-back( new std\-::string(\char`\"{}pion\char`\"{}) ) ;\par
 }

and be read out again\-: \par
 

{\bfseries  Particle\-I\-Ds\-::ext\-\_\-type pidv = mcp-\/$>$\doxyref{ext$<$\-Particle\-I\-Ds$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a20a5e2444a329a7da6a3a87536792808} ;\par
 for( Particle\-I\-Ds\-::const\-\_\-iterator ipid = pidv-\/$>$begin() ; ipid != pidv-\/$>$end(); ++ipid)\{\par
 ~~ std\-::cout $<$$<$ $\ast$$\ast$ipid $<$$<$ \char`\"{}, \char`\"{} ;\par
 \}\par
 }

Similarily the following defines a one to many relationship between Tracks and Clusters\-:\par
 

{\bfseries  struct \doxyref{Trk\-Clu\-Link}{p.}{structTrkCluLink} \-: L\-C1\-To\-N\-Relation$<$\-Trk\-Clu\-Link,\-Track,\-Cluster$>$ \{\} ; \par
 }

Relations are allways biderectional, i.\-e. there is a {\bfseries from} and a {\bfseries to} side. They can then be set and modified with the following functions\-:\par
 \doxyref{set\-\_\-relation()}{p.}{classlcrtrel_1_1LCRTRelations_aa78d1ff4ef2e64ff1f00908d98d67123}, \doxyref{unset\-\_\-relation()}{p.}{classlcrtrel_1_1LCRTRelations_a3c659b6607079c9c541ae256c095436c}, \doxyref{add\-\_\-relation()}{p.}{classlcrtrel_1_1LCRTRelations_ab60918c35104b81a1eecb61531af0a16}, \par
 \doxyref{remove\-\_\-relation()}{p.}{classlcrtrel_1_1LCRTRelations_ad16d453cd9415bcf5b1524f2af1da631}, \doxyref{remove\-\_\-relations()}{p.}{classlcrtrel_1_1LCRTRelations_a711ea8e37e4990e6588b2ab608daa072}, \doxyref{merge\-\_\-relations()}{p.}{classlcrtrel_1_1LCRTRelations_ae2d546bef410f997133cd3ed99a98067}. \par
 For example\-:\par
 

{\bfseries  Track$\ast$ trk = dynamic\-\_\-cast$<$\-Track$\ast$$>$ ( trkcol-\/$>$get\-Element\-At(j) ) ; \par
 //... \par
 Cluster$\ast$ clu = dynamic\-\_\-cast$<$\-Cluster$\ast$$>$ ( clucol-\/$>$get\-Element\-At(k) ) ; \par
 add\-\_\-relation$<$\-Trk\-Clu\-Link$>$( trk ,clu ); \par
 }

The many side can then be read out with a const\-\_\-iterator and the one side with a normal pointer\-:\par
 

{\bfseries  Track$\ast$ trk = clu-\/$>$\doxyref{rel$<$\-Trk\-Clu\-Link\-::from$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a84ce135758f05cfa2844c221014ceae2} ; \par
 //...\par
 Trk\-Clu\-Link\-::to\-::rel\-\_\-type clulist = trk-\/$>$\doxyref{rel$<$\-Trk\-Clu\-Link\-::to$>$()}{p.}{classlcrtrel_1_1LCRTRelations_a84ce135758f05cfa2844c221014ceae2} ; \par
 for( Trk\-Clu\-Link\-::to\-::const\-\_\-iterator iclu = clulist-\/$>$begin() ; iclu != clulist-\/$>$end() ; ++iclu )\{ \par
 ~~Cluster$\ast$ clu = $\ast$iclu ; // iterator is of type pointer to container element \par
 ~~std\-::cout $<$$<$ \char`\"{}   assigned cluster with E = \char`\"{} $<$$<$ clu-\/$>$get\-Energy() $<$$<$ std\-::endl ; \par
 \} } 

More examples can be found in {\bfseries \$\-L\-C\-I\-O/src/cpp/src/\-E\-X\-A\-M\-P\-L\-E\-S/lcrtrelations.cc}. 

\subsection{Friends And Related Function Documentation}
\index{lcrtrel\-::\-L\-C\-R\-T\-Relations@{lcrtrel\-::\-L\-C\-R\-T\-Relations}!set\-\_\-relation@{set\-\_\-relation}}
\index{set\-\_\-relation@{set\-\_\-relation}!lcrtrel::LCRTRelations@{lcrtrel\-::\-L\-C\-R\-T\-Relations}}
\subsubsection[{set\-\_\-relation}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class R $>$ void set\-\_\-relation (
\begin{DoxyParamCaption}
\item[{typename R\-::from\-::obj\-\_\-ptr}]{f, }
\item[{typename R\-::to\-::obj\-\_\-ptr}]{t}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [friend]}}\label{classlcrtrel_1_1LCRTRelations_aa78d1ff4ef2e64ff1f00908d98d67123}


Set the 1-\/to-\/1 relation between two objects -\/ prexisting inconsistent relations involving the two objects are deleted to enforce a consistent set of from-\/to relations. 



The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
L\-C\-R\-T\-Relations.\-h\end{DoxyCompactItemize}
