LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
LCRelationNavigator.h
1 // -*- C++ -*-
2 #ifndef EVENT_LCRELATIONNAVIGATORIMPL_H
3 #define EVENT_LCRELATIONNAVIGATORIMPL_H 1
4 
5 #include <vector>
6 #include <map>
7 #include "EVENT/LCObject.h"
8 #include "EVENT/LCCollection.h"
9 #include "LCIOSTLTypes.h"
10 
11 
12 namespace UTIL {
13 
24 
25  typedef std::map< EVENT::LCObject* , std::pair< EVENT::LCObjectVec , EVENT::FloatVec > > RelMap ;
26 
27  public:
28 
29 
32  LCRelationNavigator(const std::string &fromType, const std::string &toType) :
33  _from( fromType ),
34  _to( toType ) { /* nop */; }
35 
39 
41  virtual ~LCRelationNavigator() { /* nop */; }
42 
45  virtual const std::string & getFromType() const ;
46 
49  virtual const std::string & getToType() const ;
50 
54  virtual const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject * from) const ;
55 
59  virtual const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject * to) const ;
60 
64  virtual const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject * from) const ;
65 
69  virtual const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject * to) const ;
70 
74  virtual void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight = 1.0) ;
75 
78  virtual void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to) ;
79 
84 
85  protected:
86 
88 
89  virtual void initialize( const EVENT::LCCollection* col ) ;
90 
91  void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to, RelMap& map ) ;
92  void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight, RelMap& map) ;
93 
94  mutable RelMap _map ;
95  mutable RelMap _rMap ;
96  std::string _from ;
97  std::string _to ;
98 
99 
100 }; // class
101 } // namespace EVENT
102 #endif /* ifndef EVENT_LCRELATIONNAVIGATOR_H */
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
virtual const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject *from) const
The weights of the relations returned by a call to getRelatedToObjects(from).
Definition: LCRelationNavigator.cc:61
virtual const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject *to) const
All from-objects related to the given object ( the inverse relationship).
Definition: LCRelationNavigator.cc:56
std::vector< LCObject * > LCObjectVec
Vector of (pointers to) LCObjects.
Definition: LCObject.h:17
std::vector< float > FloatVec
Vector of floats.
Definition: LCIOSTLTypes.h:18
LCRelationNavigator(const std::string &fromType, const std::string &toType)
Default constructor.
Definition: LCRelationNavigator.h:32
The LCRelationNavigator makes repeated lookup of relations more conveneient and efficient.
Definition: LCRelationNavigator.h:23
virtual void removeRelation(EVENT::LCObject *from, EVENT::LCObject *to)
Remove a given relation.
Definition: LCRelationNavigator.cc:103
virtual const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject *from) const
All objects that the given from-object is related to.
Definition: LCRelationNavigator.cc:50
virtual ~LCRelationNavigator()
Destructor.
Definition: LCRelationNavigator.h:41
virtual EVENT::LCCollection * createLCCollection()
Remove a given relation.
Definition: LCRelationNavigator.cc:142
virtual const std::string & getFromType() const
The type of the 'from' objects in this relation.
Definition: LCRelationNavigator.cc:46
virtual const std::string & getToType() const
The type of the 'to' objects in this relation.
Definition: LCRelationNavigator.cc:47
The generic collection used in LCIO.
Definition: LCCollection.h:29
virtual void addRelation(EVENT::LCObject *from, EVENT::LCObject *to, float weight=1.0)
Adds a relation.
Definition: LCRelationNavigator.cc:71
virtual const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject *to) const
The weights of the relations returned by a call to getRelatedFromObjects(to).
Definition: LCRelationNavigator.cc:66