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

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 //
00015 
00016 // ................................................................
00017 //
00018 #ifndef ATLFAST_ASSOCIATIONMANAGER_H
00019 #define ATLFAST_ASSOCIATIONMANAGER_H
00020 
00021 //#include <iostream>
00022 
00023 // Athena 
00024 #include "GaudiKernel/ContainedObject.h"
00025 #include "GaudiKernel/SmartRefVector.h"
00026 
00027 
00028 //======================================
00029 
00030 namespace Atlfast {
00047   class AssociationManager {
00048     
00049   protected:
00050     
00058     SmartRefVector<ContainedObject> m_associations ;
00059   
00060   public:
00061     
00062     
00063     //....................................
00072     void associate( const ContainedObject* otherEntity ) {
00073       m_associations.push_back( otherEntity ) ;
00074       
00075     } 
00076     void associate( const SmartRef<ContainedObject>* otherEntity ) {
00077       m_associations.push_back( *otherEntity ) ;
00078     }
00079     
00084     SmartRefVector<ContainedObject> associations( ) const {
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     }
00094     
00095 
00096     // ...............................................
00103     template< class T >
00104       SmartRefVector<T> associations( T ) const {
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     }
00124     
00125     
00126     // ..................................
00130     bool unAssociated() const { return m_associations.size() == 0 ; }
00131     void reset() { m_associations.erase(m_associations.begin(),
00132                                         m_associations.end());}
00133   };
00134   
00135 } //end of namespace bracket
00136 #endif
00137 
00138 
00139 
00140 

Generated on Fri Nov 29 12:55:11 2002 by doxygen1.3-rc1