Belle II Software development
WeightedRelation< AFrom, ATo > Class Template Reference

Type for two related objects with a weight. More...

#include <WeightedRelation.h>

Inheritance diagram for WeightedRelation< AFrom, ATo >:

Public Types

using From = AFrom
 Type of from which the relation originates.
 
using To = ATo
 Type of to which the relation points.
 

Public Member Functions

 WeightedRelation ()=default
 Default constructor.
 
 WeightedRelation (From *from, Weight weight, To *to)
 Creating a relation with one object on the from side, one on the to side and a weight.
 
bool operator< (const WeightedRelation< From, To > &rhs) const
 Operator for ordering of relations.
 
FromgetFrom () const
 Getter for the pointer to the from side object.
 
Weight getWeight () const
 Getter for the weight.
 
void setWeight (Weight weight)
 Setter for the weight.
 
const std::pair< From *, Weight > & getWeightedFrom () const
 Getter for the pointer to the weighted from side object.
 
TogetTo () const
 Getter for the pointer to the to side object.
 
WeightedRelation< To, Fromreversed () const
 Make a relation in the opposite direction with the same weight.
 

Public Attributes

T1 first_type
 STL member.
 
T2 second_type
 STL member.
 

Private Types

using Super = std::pair<std::pair<AFrom*, Weight>, ATo*>
 Type of the base class.
 

Friends

bool operator< (const std::pair< From *, Weight > &weightedPtr, const WeightedRelation< From, To > &weightedRelation)
 Operator to compare key type weighted item to the relations for associative lookups.
 
bool operator< (const WeightedRelation< From, To > &weightedRelation, const std::pair< From *, Weight > &weightedPtr)
 Operator to compare key type weighted item to the relations for associative lookups.
 
bool operator< (const From *ptrFrom, const WeightedRelation< From, To > &weightedRelation)
 Operator to compare key type item to the relations for associative lookups.
 
bool operator< (const WeightedRelation< From, To > &weightedRelation, const From *ptrFrom)
 Operator to compare key type item to the relations for associative lookups.
 

Detailed Description

template<class AFrom, class ATo = AFrom>
class Belle2::TrackFindingCDC::WeightedRelation< AFrom, ATo >

Type for two related objects with a weight.

Definition at line 26 of file WeightedRelation.h.

Member Typedef Documentation

◆ From

template<class AFrom, class ATo = AFrom>
using From = AFrom

Type of from which the relation originates.

Definition at line 33 of file WeightedRelation.h.

◆ Super

template<class AFrom, class ATo = AFrom>
using Super = std::pair<std::pair<AFrom*, Weight>, ATo*>
private

Type of the base class.

Definition at line 29 of file WeightedRelation.h.

◆ To

template<class AFrom, class ATo = AFrom>
using To = ATo

Type of to which the relation points.

Definition at line 36 of file WeightedRelation.h.

Constructor & Destructor Documentation

◆ WeightedRelation()

template<class AFrom, class ATo = AFrom>
WeightedRelation ( From * from,
Weight weight,
To * to )
inline

Creating a relation with one object on the from side, one on the to side and a weight.

Definition at line 43 of file WeightedRelation.h.

44 : Super({from, weight}, to)
45 {}

Member Function Documentation

◆ getFrom()

template<class AFrom, class ATo = AFrom>
From * getFrom ( ) const
inline

Getter for the pointer to the from side object.

Definition at line 91 of file WeightedRelation.h.

92 {
93 return getWeightedFrom().first;
94 }

◆ getTo()

template<class AFrom, class ATo = AFrom>
To * getTo ( ) const
inline

Getter for the pointer to the to side object.

Definition at line 115 of file WeightedRelation.h.

116 {
117 return this->second;
118 }

◆ getWeight()

template<class AFrom, class ATo = AFrom>
Weight getWeight ( ) const
inline

Getter for the weight.

Definition at line 97 of file WeightedRelation.h.

98 {
99 return getWeightedFrom().second;
100 }

◆ getWeightedFrom()

template<class AFrom, class ATo = AFrom>
const std::pair< From *, Weight > & getWeightedFrom ( ) const
inline

Getter for the pointer to the weighted from side object.

Definition at line 109 of file WeightedRelation.h.

110 {
111 return this->first;
112 }

◆ operator<()

template<class AFrom, class ATo = AFrom>
bool operator< ( const WeightedRelation< From, To > & rhs) const
inline

Operator for ordering of relations.

Definition at line 48 of file WeightedRelation.h.

49 {
50 return (getFrom() < rhs.getFrom() or
51 (not(rhs.getFrom() < getFrom()) and
52 // highest weight first
53 (getWeight() > rhs.getWeight() or
54 (not(rhs.getWeight() > getWeight()) and
55 (getTo() < rhs.getTo())))));
56 }

◆ reversed()

template<class AFrom, class ATo = AFrom>
WeightedRelation< To, From > reversed ( ) const
inline

Make a relation in the opposite direction with the same weight.

Definition at line 121 of file WeightedRelation.h.

122 {
123 //return WeightedRelation<To, From>(getTo(), getWeight(), getFrom());
124 return {getTo(), getWeight(), getFrom()};
125 }

◆ setWeight()

template<class AFrom, class ATo = AFrom>
void setWeight ( Weight weight)
inline

Setter for the weight.

Definition at line 103 of file WeightedRelation.h.

104 {
105 this->first.second = weight;
106 }

Friends And Related Symbol Documentation

◆ operator< [1/4]

template<class AFrom, class ATo = AFrom>
bool operator< ( const From * ptrFrom,
const WeightedRelation< From, To > & weightedRelation )
friend

Operator to compare key type item to the relations for associative lookups.

Definition at line 79 of file WeightedRelation.h.

80 {
81 return ptrFrom < weightedRelation.getFrom();
82 }

◆ operator< [2/4]

template<class AFrom, class ATo = AFrom>
bool operator< ( const std::pair< From *, Weight > & weightedPtr,
const WeightedRelation< From, To > & weightedRelation )
friend

Operator to compare key type weighted item to the relations for associative lookups.

Definition at line 59 of file WeightedRelation.h.

61 {
62 return (weightedPtr.first < weightedRelation.getFrom() or
63 (not(weightedRelation.getFrom() < weightedPtr.first) and
64 // highest weight first
65 (weightedPtr.second > weightedRelation.getWeight())));
66 }

◆ operator< [3/4]

template<class AFrom, class ATo = AFrom>
bool operator< ( const WeightedRelation< From, To > & weightedRelation,
const From * ptrFrom )
friend

Operator to compare key type item to the relations for associative lookups.

Definition at line 85 of file WeightedRelation.h.

86 {
87 return weightedRelation.getFrom() < ptrFrom;
88 }

◆ operator< [4/4]

template<class AFrom, class ATo = AFrom>
bool operator< ( const WeightedRelation< From, To > & weightedRelation,
const std::pair< From *, Weight > & weightedPtr )
friend

Operator to compare key type weighted item to the relations for associative lookups.

Definition at line 69 of file WeightedRelation.h.

71 {
72 return (weightedRelation.getFrom() < weightedPtr.first or
73 (not(weightedPtr.first < weightedRelation.getFrom()) and
74 // highest weight first
75 (weightedRelation.getWeight() > weightedPtr.second)));
76 }

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