LCIO
02.17
|
The LCRelationNavigator makes repeated lookup of relations more conveneient and efficient. More...
#include <LCRelationNavigator.h>
Public Member Functions | |
LCRelationNavigator (const std::string &fromType, const std::string &toType) | |
Default constructor. More... | |
LCRelationNavigator (const EVENT::LCCollection *col) | |
Create the navigator object from an existing collection of relations. More... | |
virtual | ~LCRelationNavigator () |
Destructor. More... | |
virtual const std::string & | getFromType () const |
The type of the 'from' objects in this relation. More... | |
virtual const std::string & | getToType () const |
The type of the 'to' objects in this relation. More... | |
virtual const EVENT::LCObjectVec & | getRelatedToObjects (EVENT::LCObject *from) const |
All objects that the given from-object is related to. More... | |
virtual const EVENT::LCObjectVec & | getRelatedFromObjects (EVENT::LCObject *to) const |
All from-objects related to the given object ( the inverse relationship). More... | |
virtual const EVENT::FloatVec & | getRelatedToWeights (EVENT::LCObject *from) const |
The weights of the relations returned by a call to getRelatedToObjects(from). More... | |
virtual const EVENT::FloatVec & | getRelatedFromWeights (EVENT::LCObject *to) const |
The weights of the relations returned by a call to getRelatedFromObjects(to). More... | |
virtual void | addRelation (EVENT::LCObject *from, EVENT::LCObject *to, float weight=1.0) |
Adds a relation. More... | |
virtual void | removeRelation (EVENT::LCObject *from, EVENT::LCObject *to) |
Remove a given relation. More... | |
virtual EVENT::LCCollection * | createLCCollection () |
Remove a given relation. More... | |
Protected Member Functions | |
LCRelationNavigator () | |
virtual void | initialize (const EVENT::LCCollection *col) |
void | removeRelation (EVENT::LCObject *from, EVENT::LCObject *to, RelMap &map) |
void | addRelation (EVENT::LCObject *from, EVENT::LCObject *to, float weight, RelMap &map) |
Protected Attributes | |
RelMap | _map {} |
RelMap | _rMap {} |
std::string | _from |
std::string | _to |
Private Types | |
typedef std::map < EVENT::LCObject *, std::pair < EVENT::LCObjectVec, EVENT::FloatVec > > | RelMap |
The LCRelationNavigator makes repeated lookup of relations more conveneient and efficient.
The relations are treated symmetrical, i.e. lookup of relations is equally efficient and fast for either direction (from-to and to-from) at the price of a slower (by a factor of ~2) modification speed.
Definition at line 23 of file LCRelationNavigator.h.
|
private |
Definition at line 25 of file LCRelationNavigator.h.
|
inline |
Default constructor.
Definition at line 32 of file LCRelationNavigator.h.
UTIL::LCRelationNavigator::LCRelationNavigator | ( | const EVENT::LCCollection * | col | ) |
Create the navigator object from an existing collection of relations.
Definition at line 19 of file LCRelationNavigator.cc.
References initialize().
|
inlinevirtual |
Destructor.
Definition at line 41 of file LCRelationNavigator.h.
|
protected |
|
virtual |
Adds a relation.
If there is already an existing relation between the two given objects the weight (or default weight 1.0) is added to that relationship's weight.
Definition at line 71 of file LCRelationNavigator.cc.
References _map, _rMap, and addRelation().
Referenced by addRelation(), and initialize().
|
protected |
Definition at line 78 of file LCRelationNavigator.cc.
References std::vector< T >::push_back(), and std::vector< T >::size().
|
virtual |
Remove a given relation.
To reduce the weight of the relationship, call addRelation( from, to, weight ) with weight<0.
Definition at line 142 of file LCRelationNavigator.cc.
References _map, IMPL::LCCollectionVec::addElement(), std::map< K, T >::begin(), std::map< K, T >::end(), IMPL::LCFlagImpl::getFlag(), getFromType(), getToType(), IMPL::LCCollectionVec::parameters(), RELATIONFROMTYPESTR, RELATIONTOTYPESTR, IMPL::LCFlagImpl::setBit(), IMPL::LCCollectionVec::setFlag(), EVENT::LCParameters::setValue(), and std::vector< T >::size().
|
virtual |
The type of the 'from' objects in this relation.
Definition at line 46 of file LCRelationNavigator.cc.
References _from.
Referenced by createLCCollection().
|
virtual |
All from-objects related to the given object ( the inverse relationship).
LCObjects are of type getFromType().
Definition at line 56 of file LCRelationNavigator.cc.
References _rMap.
|
virtual |
The weights of the relations returned by a call to getRelatedFromObjects(to).
Definition at line 66 of file LCRelationNavigator.cc.
References _rMap.
|
virtual |
All objects that the given from-object is related to.
LCObjects are of type getToType().
Definition at line 50 of file LCRelationNavigator.cc.
References _map.
|
virtual |
The weights of the relations returned by a call to getRelatedToObjects(from).
Definition at line 61 of file LCRelationNavigator.cc.
References _map.
|
virtual |
The type of the 'to' objects in this relation.
Definition at line 47 of file LCRelationNavigator.cc.
References _to.
Referenced by createLCCollection().
|
protectedvirtual |
Definition at line 27 of file LCRelationNavigator.cc.
References addRelation(), EVENT::LCCollection::getElementAt(), EVENT::LCRelation::getFrom(), EVENT::LCCollection::getNumberOfElements(), EVENT::LCRelation::getTo(), EVENT::LCCollection::getTypeName(), and EVENT::LCRelation::getWeight().
Referenced by LCRelationNavigator().
|
virtual |
Remove a given relation.
Definition at line 103 of file LCRelationNavigator.cc.
|
protected |
Definition at line 110 of file LCRelationNavigator.cc.
References std::vector< T >::begin(), std::vector< T >::empty(), std::vector< T >::end(), std::map< K, T >::end(), std::map< K, T >::erase(), std::vector< T >::erase(), and std::map< K, T >::find().
|
protected |
Definition at line 96 of file LCRelationNavigator.h.
Referenced by getFromType().
|
mutableprotected |
Definition at line 94 of file LCRelationNavigator.h.
Referenced by addRelation(), createLCCollection(), getRelatedToObjects(), getRelatedToWeights(), and removeRelation().
|
mutableprotected |
Definition at line 95 of file LCRelationNavigator.h.
Referenced by addRelation(), getRelatedFromObjects(), getRelatedFromWeights(), and removeRelation().
|
protected |
Definition at line 97 of file LCRelationNavigator.h.
Referenced by getToType().