LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
UTIL::LCRelationNavigator Class Reference

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::stringgetFromType () const
 The type of the 'from' objects in this relation. More...
 
virtual const std::stringgetToType () const
 The type of the 'to' objects in this relation. More...
 
virtual const EVENT::LCObjectVecgetRelatedToObjects (EVENT::LCObject *from) const
 All objects that the given from-object is related to. More...
 
virtual const EVENT::LCObjectVecgetRelatedFromObjects (EVENT::LCObject *to) const
 All from-objects related to the given object ( the inverse relationship). More...
 
virtual const EVENT::FloatVecgetRelatedToWeights (EVENT::LCObject *from) const
 The weights of the relations returned by a call to getRelatedToObjects(from). More...
 
virtual const EVENT::FloatVecgetRelatedFromWeights (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::LCCollectioncreateLCCollection ()
 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
 

Detailed Description

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.

Author
gaede
Version
Id:
LCRelationNavigator.h,v 1.2 2004-09-06 14:35:51 gaede Exp

Definition at line 23 of file LCRelationNavigator.h.

Member Typedef Documentation

Definition at line 25 of file LCRelationNavigator.h.

Constructor & Destructor Documentation

UTIL::LCRelationNavigator::LCRelationNavigator ( const std::string fromType,
const std::string toType 
)
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().

virtual UTIL::LCRelationNavigator::~LCRelationNavigator ( )
inlinevirtual

Destructor.

Definition at line 41 of file LCRelationNavigator.h.

UTIL::LCRelationNavigator::LCRelationNavigator ( )
protected

Member Function Documentation

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.

Definition at line 71 of file LCRelationNavigator.cc.

References _map, _rMap, and addRelation().

Referenced by addRelation(), and initialize().

void UTIL::LCRelationNavigator::addRelation ( EVENT::LCObject from,
EVENT::LCObject to,
float  weight,
RelMap map 
)
protected
EVENT::LCCollection * UTIL::LCRelationNavigator::createLCCollection ( )
virtual
const std::string & UTIL::LCRelationNavigator::getFromType ( ) const
virtual

The type of the 'from' objects in this relation.

Definition at line 46 of file LCRelationNavigator.cc.

References _from.

Referenced by createLCCollection().

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().

Definition at line 56 of file LCRelationNavigator.cc.

References _rMap.

const EVENT::FloatVec & UTIL::LCRelationNavigator::getRelatedFromWeights ( EVENT::LCObject to) const
virtual

The weights of the relations returned by a call to getRelatedFromObjects(to).

See Also
getRelatedFromObjects

Definition at line 66 of file LCRelationNavigator.cc.

References _rMap.

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().

Definition at line 50 of file LCRelationNavigator.cc.

References _map.

const EVENT::FloatVec & UTIL::LCRelationNavigator::getRelatedToWeights ( EVENT::LCObject from) const
virtual

The weights of the relations returned by a call to getRelatedToObjects(from).

See Also
getRelatedToObjects

Definition at line 61 of file LCRelationNavigator.cc.

References _map.

const std::string & UTIL::LCRelationNavigator::getToType ( ) const
virtual

The type of the 'to' objects in this relation.

Definition at line 47 of file LCRelationNavigator.cc.

References _to.

Referenced by createLCCollection().

void UTIL::LCRelationNavigator::initialize ( const EVENT::LCCollection col)
protectedvirtual
void UTIL::LCRelationNavigator::removeRelation ( EVENT::LCObject from,
EVENT::LCObject to 
)
virtual

Remove a given relation.

Definition at line 103 of file LCRelationNavigator.cc.

References _map, and _rMap.

void UTIL::LCRelationNavigator::removeRelation ( EVENT::LCObject from,
EVENT::LCObject to,
RelMap map 
)
protected

Member Data Documentation

std::string UTIL::LCRelationNavigator::_from
protected

Definition at line 96 of file LCRelationNavigator.h.

Referenced by getFromType().

RelMap UTIL::LCRelationNavigator::_map {}
mutableprotected
RelMap UTIL::LCRelationNavigator::_rMap {}
mutableprotected
std::string UTIL::LCRelationNavigator::_to
protected

Definition at line 97 of file LCRelationNavigator.h.

Referenced by getToType().


The documentation for this class was generated from the following files: