00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00029
00030
00031 #ifndef __Atlfast_association__manager__
00032 #define __Atlfast_association__manager__
00033
00034 #include <iostream>
00035
00036
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
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
00129
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 }
00152 #endif
00153
00154
00155
00156