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

AssociationManager.h

Go to the documentation of this file.
00001 // ================================================
00002 // This file contains:
00003 //
00004 //              AssociationManager class
00005 //
00006 // ================================================
00007 //
00008 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00009 //
00010 //
00011 // Namespace: Atlfast::
00012 //
00013 // class: AssociationManager
00014 //
00029 // ................................................................
00030 //
00031 #ifndef ATLFAST_ASSOCIATIONMANAGER_H
00032 #define ATLFAST_ASSOCIATIONMANAGER_H
00033 
00034 //#include <iostream>
00035 
00036 // Athena 
00037 #include "GaudiKernel/ContainedObject.h"
00038 #include "GaudiKernel/SmartRefVector.h"
00039 
00040 
00041 //======================================
00042 
00043 namespace Atlfast {
00060   class AssociationManager {
00061     
00062   protected:
00063     
00070     SmartRefVector<ContainedObject> m_associations ;
00071   
00072   public:
00073     
00074     
00075     //....................................
00084     void associate( const ContainedObject* otherEntity ) {
00085       m_associations.push_back( otherEntity ) ;
00086       
00087     } 
00088     void associate( const SmartRef<ContainedObject>* otherEntity ) {
00089       m_associations.push_back( *otherEntity ) ;
00090     }
00091     
00096     SmartRefVector<ContainedObject> associations( ) const {
00097       //Be dumb for now : make a copy of the list of associations  
00098       SmartRefVector<ContainedObject> results ;
00099       SmartRefVector<ContainedObject>::const_iterator assoc = 
00100         m_associations.begin(); 
00101       for(; assoc != m_associations.end(); ++assoc ) {
00102       results.push_back( *assoc ) ; 
00103       }
00104       return results ;
00105     }
00106     
00107 
00108     // ...............................................
00115     template< class T >
00116       SmartRefVector<T> associations( T ) const {
00117       
00118       SmartRefVector<T> results ;
00119       
00120       T targetType ;
00121       SmartRefVector<ContainedObject>::const_iterator assoc = 
00122         m_associations.begin(); 
00123       for( ; assoc != m_associations.end(); ++assoc ) {   
00124         if( targetType.clID() == (*assoc)->clID() ) {
00125           
00126           // Found an associated object of the correct type
00127           // Cast the contained object into required type and add to 
00128           // the results
00129           const ContainedObject* temp =  *assoc  ; 
00130           T* temp2 = (T*) temp ;
00131           results.push_back( temp2 ) ; 
00132         }
00133       }
00134       return results ;
00135     }
00136     
00137     
00138     // ..................................
00142     bool unAssociated() const { return m_associations.size() == 0 ; }
00143     void reset() { m_associations.erase(m_associations.begin(),
00144                                         m_associations.end());}
00145   };
00146   
00147 } //end of namespace bracket
00148 #endif
00149 
00150 
00151 
00152 

Generated on Mon Feb 4 15:54:22 2002 for Atlfast by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001