00001
00002 #ifndef EVENT_LCRELATIONNAVIGATORIMPL_H
00003 #define EVENT_LCRELATIONNAVIGATORIMPL_H 1
00004
00005 #include <vector>
00006 #include <map>
00007 #include "EVENT/LCObject.h"
00008 #include "EVENT/LCCollection.h"
00009 #include "LCIOSTLTypes.h"
00010
00011
00012 namespace UTIL {
00013
00023 class LCRelationNavigator {
00024
00025 typedef std::map< EVENT::LCObject* , std::pair< EVENT::LCObjectVec , EVENT::FloatVec > > RelMap ;
00026
00027 public:
00028
00029
00032 LCRelationNavigator(const std::string &fromType, const std::string &toType) :
00033 _from( fromType ),
00034 _to( toType ) { ; }
00035
00038 LCRelationNavigator( const EVENT::LCCollection* col ) ;
00039
00041 virtual ~LCRelationNavigator() { ; }
00042
00045 virtual const std::string & getFromType() const ;
00046
00049 virtual const std::string & getToType() const ;
00050
00054 virtual const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject * from) const ;
00055
00059 virtual const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject * to) const ;
00060
00064 virtual const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject * from) const ;
00065
00069 virtual const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject * to) const ;
00070
00074 virtual void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight = 1.0) ;
00075
00078 virtual void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to) ;
00079
00083 virtual EVENT::LCCollection * createLCCollection() ;
00084
00085 protected:
00086
00087 LCRelationNavigator() ;
00088
00089 virtual void initialize( const EVENT::LCCollection* col ) ;
00090
00091 void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to, RelMap& map ) ;
00092 void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight, RelMap& map) ;
00093
00094 mutable RelMap _map{} ;
00095 mutable RelMap _rMap{} ;
00096 std::string _from ;
00097 std::string _to ;
00098
00099
00100 };
00101 }
00102 #endif