Event::RelTable< T1, T2 > Class Template Reference

#include <RelTable.h>

List of all members.

Public Member Functions

 RelTable ()
 RelTable (ObjectList< Relation< T1, T2 > > *rels)
void init ()
 Initialize the internal pointer to an ObjectList of relations.
void addDupRel (Relation< T1, T2 > *rel)
bool addRelation (Relation< T1, T2 > *rel)
std::vector< Relation< T1,
T2 > * > 
getRelByFirst (const T1 *pobj) const
std::vector< Relation< T1,
T2 > * > 
getRelBySecond (const T2 *pobj) const
void erase (Relation< T1, T2 > *rel)
void changeFirst (Relation< T1, T2 > *rel, T1 *pobj)
void changeSecond (Relation< T1, T2 > *rel, T2 *pobj)
unsigned long size () const
 This method returns the number of relations in the table.
ObjectList< Relation< T1,
T2 > > * 
getAllRelations () const
 Returns the pointer to the collection of relations.

Private Member Functions

void bindRelationFirst (Relation< T1, T2 > *rel)
void bindRelationSecond (Relation< T1, T2 > *rel)
void removeFirst (Relation< T1, T2 > *rel)
void removeSecond (Relation< T1, T2 > *rel)
Relation< T1, T2 > * findDup (Relation< T1, T2 > *rel1, Relation< T1, T2 > *rel2)
bool bindRelationNoDup (Relation< T1, T2 > *rel)

Private Attributes

ObjectList< Relation< T1,
T2 > > * 
m_relations
 Pointer to a collection of relations.


Detailed Description

template<class T1, class T2>
class Event::RelTable< T1, T2 >

Definition at line 29 of file RelTable.h.


Constructor & Destructor Documentation

template<class T1, class T2>
Event::RelTable< T1, T2 >::RelTable (  )  [inline]

Definition at line 33 of file RelTable.h.

00033 {}

template<class T1, class T2>
RelTable::RelTable ( ObjectList< Relation< T1, T2 > > *  rels  )  [inline]

Definition at line 124 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

00124                                                                          {
00125     
00126     m_relations = rels;
00127     
00128   }


Member Function Documentation

template<class T1, class T2>
void RelTable::addDupRel ( Relation< T1, T2 > *  rel  ) 

The following method add a new Relation to the table, even if there is already a relation with the same two objects (they could have different infos vector)

Definition at line 131 of file RelTable.h.

References Event::RelTable< T1, T2 >::bindRelationFirst(), Event::RelTable< T1, T2 >::bindRelationSecond(), and Event::RelTable< T1, T2 >::m_relations.

00131                                                         {
00132     // Purpose and Method:  This routine add a new relation to the collection, even
00133     // if there is a already a relation between the same two objects
00134     // Inputs:  rel is a pointer to the relation to be added.
00135     
00136     bindRelationFirst(rel);
00137     bindRelationSecond(rel);
00138     m_relations->push_back(rel);
00139   }

template<class T1, class T2>
bool RelTable::addRelation ( Relation< T1, T2 > *  rel  ) 

The following method add a Relation to the table if it doesn't contain a relation between the same two objects, otherwise it appends the info vector to the exsisting relation

Parameters:
rel is a pointer to a relation between two objects
Returns:
true if the relation has been added and false if it is a duplicate and has not been added (in this case the user has to delete it)

Definition at line 143 of file RelTable.h.

References Event::RelTable< T1, T2 >::bindRelationNoDup(), Event::RelTable< T1, T2 >::bindRelationSecond(), and Event::RelTable< T1, T2 >::m_relations.

Referenced by Event::RelTable< T1, T2 >::changeFirst(), Event::RelTable< T1, T2 >::changeSecond(), and MucRecTrkExt::execute().

00143                                                           {
00144     // Purpose and Method:  This routine add a relation to the table if it doesn't 
00145     // contain a relation between the same two objects, otherwise it appends the info
00146     // vector to the exsisting relation
00147     // Inputs:  rel is a pointer to the relation to be added.
00148     // Outputs: a boolean value which is true if the realtion has been added to the
00149     //          table and false it it is a duplicate and thus has not been added.
00150     //          In the latter case the user has to delete the relation
00151     
00152     if (bindRelationNoDup(rel))
00153       {
00154         bindRelationSecond(rel);
00155         m_relations->push_back(rel);
00156         return true;
00157       }
00158     return false;
00159   }

template<class T1, class T2>
void RelTable::bindRelationFirst ( Relation< T1, T2 > *  rel  )  [inline, private]

Definition at line 272 of file RelTable.h.

References Event::Relation< T1, T2 >::getFirst(), Event::Relation< T1, T2 >::m_first, Event::RelTable< T1, T2 >::m_relations, Event::RelKey< T1, T2, T3 >::setPrev(), Event::RelKey< T1, T2, T3 >::setSame(), and subSeperate::temp.

Referenced by Event::RelTable< T1, T2 >::addDupRel().

00272                                                                        {
00273     
00274     Relation<T1,T2>* temp;
00275 
00276     if (m_relations->size())
00277     {
00278       SmartRef< Relation<T1,T2> > r = m_relations->front();
00279       while ((r->getFirst() != rel->getFirst()))
00280       {
00281         if (r->m_first.getFirst())
00282         {
00283           r = r->m_first.getFirst();
00284         }
00285         else
00286         {
00287           break;
00288         }
00289       }
00290       
00291       if (r->getFirst() != rel->getFirst())
00292       {
00293         r->m_first.setFirst(rel);
00294         rel->m_first.setPrev(r);
00295       }
00296       else
00297       {
00298         temp = r->m_first.getSame();
00299         rel->m_first.setSame(temp);
00300         if (temp)
00301           temp->m_first.setPrev(rel);
00302         r->m_first.setSame(rel);
00303         rel->m_first.setPrev(r);
00304       }
00305     }
00306   }

template<class T1, class T2>
bool RelTable::bindRelationNoDup ( Relation< T1, T2 > *  rel  )  [inline, private]

Definition at line 363 of file RelTable.h.

References eformat::write::copy(), Event::RelTable< T1, T2 >::findDup(), Event::Relation< T1, T2 >::getFirst(), Event::Relation< T1, T2 >::m_first, Event::Relation< T1, T2 >::m_infos, Event::RelTable< T1, T2 >::m_relations, Event::RelKey< T1, T2, T3 >::setPrev(), Event::RelKey< T1, T2, T3 >::setSame(), and subSeperate::temp.

Referenced by Event::RelTable< T1, T2 >::addRelation().

00363                                                                        {
00364     
00365     Relation<T1,T2>* temp;
00366 
00367     if (m_relations->size())
00368     {
00369       SmartRef< Relation<T1,T2> > r = m_relations->front();
00370       while ((r->getFirst() != rel->getFirst()))
00371       {
00372         if (r->m_first.getFirst())
00373         {
00374           r = r->m_first.getFirst();
00375         }
00376         else
00377         {
00378           break;
00379         }
00380       }
00381       
00382       if (r->getFirst() != rel->getFirst())
00383       {
00384         r->m_first.setFirst(rel);
00385         rel->m_first.setPrev(r);
00386         return true;
00387       }
00388       else
00389       {
00390         temp = findDup(r,rel);
00391         if (!temp)
00392           {
00393             temp = r->m_first.getSame();
00394             rel->m_first.setSame(temp);
00395             if (temp)
00396               temp->m_first.setPrev(rel);
00397             r->m_first.setSame(rel);
00398             rel->m_first.setPrev(r);
00399             return true;
00400           }
00401         else
00402           {
00403             std::copy(rel->m_infos.begin(),rel->m_infos.end(),std::back_inserter(temp->m_infos));
00404             return false;
00405           }
00406       }
00407     }
00408     return true;
00409   }

template<class T1, class T2>
void RelTable::bindRelationSecond ( Relation< T1, T2 > *  rel  )  [inline, private]

Definition at line 310 of file RelTable.h.

References Event::Relation< T1, T2 >::getSecond(), Event::RelTable< T1, T2 >::m_relations, Event::Relation< T1, T2 >::m_second, Event::RelKey< T1, T2, T3 >::setPrev(), Event::RelKey< T1, T2, T3 >::setSame(), and subSeperate::temp.

Referenced by Event::RelTable< T1, T2 >::addDupRel(), and Event::RelTable< T1, T2 >::addRelation().

00310                                                                         {
00311     Relation<T1,T2>* temp;
00312 
00313     if (m_relations->size())
00314     {
00315       SmartRef< Relation<T1,T2> > r = m_relations->front();
00316 
00317       while ((r->getSecond() != rel->getSecond()))
00318       {
00319         if (r->m_second.getFirst())
00320         {
00321           r = r->m_second.getFirst();
00322         }
00323         else
00324         {
00325           break;
00326         }
00327       }
00328       
00329       if (r->getSecond() != rel->getSecond())
00330       {
00331         r->m_second.setFirst(rel);
00332         rel->m_second.setPrev(r);
00333       }
00334       else
00335       {
00336         temp = r->m_second.getSame();
00337         rel->m_second.setSame(temp);
00338         if (temp) 
00339           temp->m_second.setPrev(rel);
00340         r->m_second.setSame(rel);
00341         rel->m_second.setPrev(r);
00342       }
00343     }    
00344   }

template<class T1, class T2>
void RelTable::changeFirst ( Relation< T1, T2 > *  rel,
T1 *  pobj 
)

This method change the first data pointer of a given relation contained into the table.

Parameters:
rel it's a pointer to the relation to be modified
pobj is the new data value provided by the user

Definition at line 230 of file RelTable.h.

References Event::RelTable< T1, T2 >::addRelation(), Event::RelTable< T1, T2 >::m_relations, Event::RelTable< T1, T2 >::removeFirst(), Event::RelTable< T1, T2 >::removeSecond(), and Event::Relation< T1, T2 >::setFirst().

00230                                                                     {
00231     // Purpose: This method change the first data pointer of a relation with the
00232     // one given by the user
00233 
00234     removeFirst(rel);
00235     removeSecond(rel);
00236     m_relations->remove(rel);
00237     rel->setFirst(pobj);
00238     addRelation(rel);
00239   }

template<class T1, class T2>
void RelTable::changeSecond ( Relation< T1, T2 > *  rel,
T2 *  pobj 
)

This method change the second data pointer of a given relation contained into the table.

Parameters:
rel it's a pointer to the relation to be modified
pobj is the new data value provided by the user

Definition at line 243 of file RelTable.h.

References Event::RelTable< T1, T2 >::addRelation(), Event::RelTable< T1, T2 >::m_relations, Event::RelTable< T1, T2 >::removeFirst(), Event::RelTable< T1, T2 >::removeSecond(), and Event::Relation< T1, T2 >::setSecond().

00243                                                                      {
00244     // Purpose: This method change the second data pointer of a relation with the
00245     // one given by the user
00246 
00247     removeFirst(rel);
00248     removeSecond(rel);
00249     m_relations->remove(rel);
00250     rel->setSecond(pobj);
00251     addRelation(rel);
00252   }

template<class T1, class T2>
void RelTable::erase ( Relation< T1, T2 > *  rel  ) 

This method erase a particular relation from the table (keeping the integrity).

Parameters:
rel it's a pointer to the relation to be erased

Definition at line 218 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations, Event::RelTable< T1, T2 >::removeFirst(), and Event::RelTable< T1, T2 >::removeSecond().

00218                                                     {
00219     // Purpose: This method remove the given relation from the table
00220 
00221     removeFirst(rel);
00222     removeSecond(rel);
00223 
00224     m_relations->remove(rel);
00225     delete rel;
00226   }

template<class T1, class T2>
Relation< T1, T2 > * RelTable::findDup ( Relation< T1, T2 > *  rel1,
Relation< T1, T2 > *  rel2 
) [inline, private]

Definition at line 349 of file RelTable.h.

References Event::RelKey< T1, T2, T3 >::getSame(), Event::Relation< T1, T2 >::getSecond(), and Event::Relation< T1, T2 >::m_first.

Referenced by Event::RelTable< T1, T2 >::bindRelationNoDup().

00350     {
00351       while (rel1)
00352         {
00353           if (rel1->getSecond() == rel2->getSecond())
00354             return rel1;
00355           rel1 = rel1->m_first.getSame();
00356         }
00357       return rel1;
00358     }

template<class T1, class T2>
ObjectList< Relation< T1, T2 > > * RelTable::getAllRelations (  )  const [inline]

Returns the pointer to the collection of relations.

Definition at line 263 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

00263                                                                                  {
00264     
00265     return m_relations;
00266     
00267   }

template<class T1, class T2>
std::vector< Relation< T1, T2 > * > RelTable::getRelByFirst ( const T1 *  pobj  )  const

This method search for all relations having obj in the first field.

Parameters:
obj it's a pointer to the object given by the user
Returns:
A vector of pointers to the relations involving the given object.

Definition at line 163 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

Referenced by MucRecTrkExt::execute().

00163                                                                                      {
00164     // Purpose and Method: This routine finds all relations having pobj in the
00165     // first field.  
00166     // Inputs: pobj is a pointer to the object to be searched in the first field
00167     // Outputs: A pointer to a vector of Relation* including pobj
00168     
00169     std::vector< Relation<T1,T2>* > rels;
00170     if (!m_relations->size()) return rels;
00171     SmartRef< Relation<T1,T2> > r = m_relations->front();
00172     while (pobj != r->getFirst() && r->m_first.getFirst())
00173     {
00174       r = r->m_first.getFirst();
00175     }
00176     
00177     if (pobj == r->getFirst())
00178     {
00179       rels.push_back(r);
00180       while (r->m_first.getSame())
00181       {
00182         rels.push_back(r->m_first.getSame());
00183         r = r->m_first.getSame();
00184       }
00185     }
00186     return rels;
00187   }

template<class T1, class T2>
std::vector< Relation< T1, T2 > * > RelTable::getRelBySecond ( const T2 *  pobj  )  const

This method search for all relations having pobj in the second field.

Parameters:
pobj it's a pointer to the object given by the user
Returns:
A vector of pointers to the relations involving the given object.

Definition at line 191 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

00191                                                                                       {
00192     // Purpose and Method: This routine finds all relations having pobj in the
00193     // second field.  
00194     // Inputs: pobj is a pointer to the object to be searched in the second field
00195     // Outputs: A pointer to a vector of Relation* including pobj
00196     std::vector< Relation<T1,T2>* > rels;
00197     if (!m_relations->size()) return rels;
00198     SmartRef< Relation<T1,T2> > r = m_relations->front();
00199     while (pobj != r->getSecond() && r->m_second.getFirst())
00200     {
00201       r = r->m_second.getFirst();
00202     }
00203     
00204     if (pobj == r->getSecond())
00205     {
00206       rels.push_back(r);
00207       while (r->m_second.getSame())
00208       {
00209         rels.push_back(r->m_second.getSame());
00210         r = r->m_second.getSame();
00211       }
00212     }
00213     return rels;
00214   }

template<class T1, class T2>
void Event::RelTable< T1, T2 >::init (  )  [inline]

Initialize the internal pointer to an ObjectList of relations.

Definition at line 38 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

Referenced by MucRecTrkExt::execute().

00038 { m_relations = new ObjectList< Relation<T1,T2> >;}

template<class T1, class T2>
void RelTable::removeFirst ( Relation< T1, T2 > *  rel  )  [inline, private]

Definition at line 414 of file RelTable.h.

References first, Event::RelKey< T1, T2, T3 >::getFirst(), Event::RelKey< T1, T2, T3 >::getPrev(), Event::RelKey< T1, T2, T3 >::getSame(), Event::Relation< T1, T2 >::m_first, next, EvtCyclic3::prev(), Event::RelKey< T1, T2, T3 >::setFirst(), Event::RelKey< T1, T2, T3 >::setPrev(), and Event::RelKey< T1, T2, T3 >::setSame().

Referenced by Event::RelTable< T1, T2 >::changeFirst(), Event::RelTable< T1, T2 >::changeSecond(), and Event::RelTable< T1, T2 >::erase().

00414                                                                  {
00415 
00416     Relation<T1,T2> *prev, *next, *first;
00417 
00418     prev = rel->m_first.getPrev();
00419     next = rel->m_first.getSame();
00420     if (next)
00421       next->m_first.setPrev(prev);
00422     if (prev)
00423     {
00424       if (prev->m_first.getFirst())
00425         prev->m_first.setFirst(next);
00426       else
00427         prev->m_first.setSame(next);
00428     }
00429     first = rel->m_first.getFirst();
00430     if (first)
00431       first->m_first.setPrev(next);
00432     rel->m_first.setPrev(0);
00433     rel->m_first.setSame(0);
00434     rel->m_first.setFirst(0);
00435   }

template<class T1, class T2>
void RelTable::removeSecond ( Relation< T1, T2 > *  rel  )  [inline, private]

Definition at line 439 of file RelTable.h.

References first, Event::RelKey< T1, T2, T3 >::getFirst(), Event::RelKey< T1, T2, T3 >::getPrev(), Event::RelKey< T1, T2, T3 >::getSame(), Event::Relation< T1, T2 >::m_second, next, EvtCyclic3::prev(), Event::RelKey< T1, T2, T3 >::setFirst(), Event::RelKey< T1, T2, T3 >::setPrev(), and Event::RelKey< T1, T2, T3 >::setSame().

Referenced by Event::RelTable< T1, T2 >::changeFirst(), Event::RelTable< T1, T2 >::changeSecond(), and Event::RelTable< T1, T2 >::erase().

00439                                                                   {
00440 
00441     Relation<T1,T2> *prev, *next, *first;
00442 
00443     prev = rel->m_second.getPrev();
00444     next = rel->m_second.getSame();
00445     if (next)
00446       next->m_second.setPrev(prev);
00447     if (prev)
00448     {
00449       if (prev->m_second.getFirst())
00450         prev->m_second.setFirst(next);
00451       else
00452         prev->m_second.setSame(next);
00453     }
00454     first = rel->m_second.getFirst();
00455     if (first)
00456       first->m_second.setPrev(next);
00457     rel->m_second.setPrev(0);
00458     rel->m_second.setSame(0);
00459     rel->m_second.setFirst(0);
00460   }

template<class T1, class T2>
unsigned long RelTable::size (  )  const [inline]

This method returns the number of relations in the table.

Definition at line 256 of file RelTable.h.

References Event::RelTable< T1, T2 >::m_relations.

Referenced by MucRecTrkExt::execute().

00256                                                      {
00257     // Purpose: This method returns the total number of relations contained in the
00258     // collection
00259     return m_relations->size();
00260   }


Member Data Documentation

template<class T1, class T2>
ObjectList< Relation<T1,T2> >* Event::RelTable< T1, T2 >::m_relations [private]

Pointer to a collection of relations.

Definition at line 105 of file RelTable.h.

Referenced by Event::RelTable< T1, T2 >::addDupRel(), Event::RelTable< T1, T2 >::addRelation(), Event::RelTable< T1, T2 >::bindRelationFirst(), Event::RelTable< T1, T2 >::bindRelationNoDup(), Event::RelTable< T1, T2 >::bindRelationSecond(), Event::RelTable< T1, T2 >::changeFirst(), Event::RelTable< T1, T2 >::changeSecond(), Event::RelTable< T1, T2 >::erase(), Event::RelTable< T1, T2 >::getAllRelations(), Event::RelTable< T1, T2 >::getRelByFirst(), Event::RelTable< T1, T2 >::getRelBySecond(), Event::RelTable< T1, T2 >::init(), Event::RelTable< T1, T2 >::RelTable(), and Event::RelTable< T1, T2 >::size().


Generated on Tue Nov 29 23:36:33 2016 for BOSS_7.0.2 by  doxygen 1.4.7