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_association__manager__
00032 #define __Atlfast_association__manager__
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 
00063   protected:
00064 
00071    SmartRefVector<ContainedObject> m_associations ;
00072 
00073    public:
00074 
00075 
00076    //....................................
00085    void associate( const ContainedObject* otherEntity ) {
00086       m_associations.push_back( otherEntity ) ;
00087 
00088    } 
00089    void associate( const SmartRef<ContainedObject>* otherEntity ) {
00090      m_associations.push_back( *otherEntity ) ;
00091    }
00092 
00097    SmartRefVector<ContainedObject> associations( ) const {
00098      //Be dumb for now : make a copy of the list of associations  
00099      SmartRefVector<ContainedObject> results ;
00100      for( SmartRefVector<ContainedObject>::const_iterator assoc = m_associations.begin(); 
00101           assoc != m_associations.end(); ++assoc ) 
00102        {
00103          results.push_back( *assoc ) ; 
00104        }
00105      return results ;
00106    }
00107 
00108 
00109    // ...............................................
00116    template< class T >
00117    SmartRefVector<T> associations( T ) const {
00118 
00119       SmartRefVector<T> results ;
00120       
00121       T targetType ;
00122 
00123       for( SmartRefVector<ContainedObject>::const_iterator assoc = m_associations.begin(); 
00124            assoc != m_associations.end(); ++assoc ) 
00125         {   
00126           if( targetType.clID() == (*assoc)->clID() ) {
00127 
00128             // Found an associated object of the correct type
00129             // Cast the contained object into required type and add to the results
00130             const ContainedObject* temp =  *assoc  ; 
00131             T* temp2 = (T*) temp ;
00132             results.push_back( temp2 ) ; 
00133 
00134           }
00135         }
00136       return results ;
00137    }
00138       
00139 
00140    // ..................................
00144    bool unAssociated() const { return m_associations.size() == 0 ; }
00145    void reset() { m_associations.erase(m_associations.begin(),
00146                                        m_associations.end());}
00147 
00148 
00149 };
00150 
00151 } //end of namespace bracket
00152 #endif
00153 
00154 
00155 
00156 

Generated on Wed Jan 23 12:58:31 2002 for Atlfast by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001