Belle II Software  release-05-01-25
Relation.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <utility>
13 
14 namespace Belle2 {
19  namespace TrackFindingCDC {
20 
22  template <class AFrom, class ATo = AFrom>
23  class Relation : public std::pair<AFrom*, ATo*> {
24 
25  private:
27  using Super = std::pair<AFrom*, ATo*>;
28 
29  public:
31  using From = AFrom;
32 
34  using To = ATo;
35 
36  public:
38  using Super::Super;
39 
41  bool operator<(const Relation<From, To>& rhs) const
42  {
43  return (getFrom() < rhs.getFrom() or
44  (not(rhs.getFrom() < getFrom()) and
45  (getTo() < rhs.getTo())));
46  }
47 
49  friend bool operator<(const From* ptrFrom, const Relation<From, To>& relation)
50  {
51  return ptrFrom < relation.getFrom();
52  }
53 
55  friend bool operator<(const Relation<From, To>& relation, const From* ptrFrom)
56  {
57  return relation.getFrom() < ptrFrom;
58  }
59 
61  From* getFrom() const
62  {
63  return this->first;
64  }
65 
67  To* getTo() const
68  {
69  return this->second;
70  }
71 
74  {
76  }
77  };
78  }
80 }
Belle2::TrackFindingCDC::Relation::getFrom
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:69
Belle2::TrackFindingCDC::Relation
Type for two related objects.
Definition: CDCSegment2D.h:37
Belle2::TrackFindingCDC::Relation::To
ATo To
Type of to which the relation points.
Definition: Relation.h:42
Belle2::TrackFindingCDC::Relation::From
AFrom From
Type of from which the relation originates.
Definition: Relation.h:39
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Relation::reversed
Relation< To, From > reversed() const
Make a relation in the opposite direciton with the same weight.
Definition: Relation.h:81
Belle2::TrackFindingCDC::Relation::Super
std::pair< AFrom *, ATo * > Super
Type of the base class.
Definition: Relation.h:35
Belle2::TrackFindingCDC::Relation::getTo
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:75
Belle2::TrackFindingCDC::Relation::operator<
bool operator<(const Relation< From, To > &rhs) const
Operator for ordering of relations.
Definition: Relation.h:49