The LCRelationNavigator makes repeated lookup of relations more conveneient and efficient. More...
#include <UTIL/LCRelationNavigator.h>
Public Member Functions | |
LCRelationNavigator (const std::string &fromType, const std::string &toType) | |
Default constructor. | |
LCRelationNavigator (const EVENT::LCCollection *col) | |
Create the navigator object from an existing collection of relations. | |
virtual | ~LCRelationNavigator () |
Destructor. | |
virtual const std::string & | getFromType () const |
The type of the 'from' objects in this relation. | |
virtual const std::string & | getToType () const |
The type of the 'to' objects in this relation. | |
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. | |
virtual EVENT::LCCollection * | createLCCollection () |
Remove a given relation. More... | |
Protected Member Functions | |
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 |
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.
|
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.
References addRelation().
Referenced by addRelation().
|
virtual |
Remove a given relation.
To reduce the weight of the relationship, call addRelation( from, to, weight ) with weight<0.
References IMPL::LCCollectionVec::addElement(), IMPL::LCFlagImpl::getFlag(), getFromType(), getToType(), IMPL::LCCollectionVec::parameters(), IMPL::LCFlagImpl::setBit(), IMPL::LCCollectionVec::setFlag(), and EVENT::LCParameters::setValue().
|
virtual |
All from-objects related to the given object ( the inverse relationship).
LCObjects are of type getFromType().
|
virtual |
The weights of the relations returned by a call to getRelatedFromObjects(to).
|
virtual |
All objects that the given from-object is related to.
LCObjects are of type getToType().
|
virtual |
The weights of the relations returned by a call to getRelatedToObjects(from).