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. | |
virtual const EVENT::LCObjectVec & | getRelatedFromObjects (EVENT::LCObject *to) const |
All from-objects related to the given object ( the inverse relationship). | |
virtual const EVENT::FloatVec & | getRelatedToWeights (EVENT::LCObject *from) const |
The weights of the relations returned by a call to getRelatedToObjects(from). | |
virtual const EVENT::FloatVec & | getRelatedFromWeights (EVENT::LCObject *to) const |
The weights of the relations returned by a call to getRelatedFromObjects(to). | |
virtual void | addRelation (EVENT::LCObject *from, EVENT::LCObject *to, float weight=1.0) |
Adds a relation. | |
virtual void | removeRelation (EVENT::LCObject *from, EVENT::LCObject *to) |
Remove a given relation. | |
virtual EVENT::LCCollection * | createLCCollection () |
Remove a given relation. | |
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 | |
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.
void UTIL::LCRelationNavigator::addRelation | ( | EVENT::LCObject * | from, | |
EVENT::LCObject * | to, | |||
float | weight = 1.0 | |||
) | [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().
EVENT::LCCollection * UTIL::LCRelationNavigator::createLCCollection | ( | ) | [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().
const EVENT::LCObjectVec & UTIL::LCRelationNavigator::getRelatedFromObjects | ( | EVENT::LCObject * | to | ) | const [virtual] |
All from-objects related to the given object ( the inverse relationship).
LCObjects are of type getFromType().
const EVENT::FloatVec & UTIL::LCRelationNavigator::getRelatedFromWeights | ( | EVENT::LCObject * | to | ) | const [virtual] |
The weights of the relations returned by a call to getRelatedFromObjects(to).
const EVENT::LCObjectVec & UTIL::LCRelationNavigator::getRelatedToObjects | ( | EVENT::LCObject * | from | ) | const [virtual] |
All objects that the given from-object is related to.
LCObjects are of type getToType().
const EVENT::FloatVec & UTIL::LCRelationNavigator::getRelatedToWeights | ( | EVENT::LCObject * | from | ) | const [virtual] |
The weights of the relations returned by a call to getRelatedToObjects(from).