Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Atlfast::AssociationManager Class Reference

This class has been provided as an interim solution to the association problem. More...

#include <AssociationManager.h>

Inheritance diagram for Atlfast::AssociationManager:

Inheritance graph
[legend]
List of all members.

Public Methods

void associate (const ContainedObject *otherEntity)
 Sets a simple one directional association between this entity and another.

void associate (const SmartRef< ContainedObject > *otherEntity)
SmartRefVector< ContainedObject > associations () const
 Returns a list of all entities associated with this object.

template<class T> SmartRefVector< T > associations (T) const
 Returns a list of all entities of a certain class which have been associated with this object.
T must inherit from ContainedObject.


bool unAssociated () const
 A quick way to find out whether there are any associations at all.

void reset ()

Protected Attributes

SmartRefVector< ContainedObject > m_associations
 This is the record of associations between ContainedObjects.


Detailed Description

This class has been provided as an interim solution to the association problem.


It provides an implemetation of a general templated association\ mechanism which allows any object which inherits from ContainedObject (A special Athena class used for items in the TES) to store a reference to any other such object.
A user can then subsequently retrieve a SmartRefVector containing SmartRefs to all stored associations or to a subset selected by class type. Templates have been used to avoid the user having to cast ContainedObject to specific classes in the latter case.
Every user class which wishes to use this mechanism simply inherits AssociationManager publically.

Definition at line 47 of file AssociationManager.h.


Member Function Documentation

void Atlfast::AssociationManager::associate const SmartRef< ContainedObject > *    otherEntity [inline]
 

Definition at line 76 of file AssociationManager.h.

References m_associations.

00076                                                                    {
00077       m_associations.push_back( *otherEntity ) ;
00078     }

void Atlfast::AssociationManager::associate const ContainedObject *    otherEntity [inline]
 

Sets a simple one directional association between this entity and another.

otherEntity is automatically converted to SmartRef<ContainedObject>(otherEntity)

Definition at line 72 of file AssociationManager.h.

References m_associations.

Referenced by Atlfast::Cluster::Cluster(), and Atlfast::Jet::Jet().

00072                                                          {
00073       m_associations.push_back( otherEntity ) ;
00074       
00075     } 

template<class T>
SmartRefVector<T> Atlfast::AssociationManager::associations   const [inline]
 

Returns a list of all entities of a certain class which have been associated with this object.
T must inherit from ContainedObject.

Definition at line 104 of file AssociationManager.h.

References m_associations.

00104                                                 {
00105       
00106       SmartRefVector<T> results ;
00107       
00108       T targetType ;
00109       SmartRefVector<ContainedObject>::const_iterator assoc = 
00110         m_associations.begin(); 
00111       for( ; assoc != m_associations.end(); ++assoc ) {   
00112         if( targetType.clID() == (*assoc)->clID() ) {
00113           
00114           // Found an associated object of the correct type
00115           // Cast the contained object into required type and add to 
00116           // the results
00117           const ContainedObject* temp =  *assoc  ; 
00118           T* temp2 = (T*) temp ;
00119           results.push_back( temp2 ) ; 
00120         }
00121       }
00122       return results ;
00123     }

SmartRefVector<ContainedObject> Atlfast::AssociationManager::associations   const [inline]
 

Returns a list of all entities associated with this object.

Definition at line 84 of file AssociationManager.h.

References m_associations.

00084                                                           {
00085       //Be dumb for now : make a copy of the list of associations  
00086       SmartRefVector<ContainedObject> results ;
00087       SmartRefVector<ContainedObject>::const_iterator assoc = 
00088         m_associations.begin(); 
00089       for(; assoc != m_associations.end(); ++assoc ) {
00090       results.push_back( *assoc ) ; 
00091       }
00092       return results ;
00093     }

void Atlfast::AssociationManager::reset   [inline]
 

Reimplemented in Atlfast::Cell.

Definition at line 131 of file AssociationManager.h.

References m_associations.

00131                  { m_associations.erase(m_associations.begin(),
00132                                         m_associations.end());}

bool Atlfast::AssociationManager::unAssociated   const [inline]
 

A quick way to find out whether there are any associations at all.

Definition at line 130 of file AssociationManager.h.

References m_associations.

00130 { return m_associations.size() == 0 ; }


Member Data Documentation

SmartRefVector<ContainedObject> Atlfast::AssociationManager::m_associations [protected]
 

This is the record of associations between ContainedObjects.

It is a vector of SmartRef<ContainedObject> pointing polymorphically to other ContainedObjects in the TES.

Todo:
Implement as DataVector to polymorphic class when this is available

Definition at line 58 of file AssociationManager.h.

Referenced by associate(), associations(), reset(), and unAssociated().


The documentation for this class was generated from the following file:
Generated on Fri Nov 29 12:55:18 2002 by doxygen1.3-rc1