Belle II Software development
DirectedNode.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <vector>
11
12namespace Belle2 {
17
30 template<typename EntryType, typename MetaInfoType>
33 template<typename AnyType, typename AnyOtherType> friend class DirectedNodeNetwork;
34
35 protected:
38 explicit DirectedNode(EntryType& entry) :
39 m_entry(entry), m_metaInfo(MetaInfoType()), m_family(-1)
40 {
41 // Reserve some space for the vectors, TODO: can still be fine-tuned
42 m_innerNodes.reserve(10);
43 m_outerNodes.reserve(10);
44 }
45
47 DirectedNode(const DirectedNode& node) = delete;
48
50 DirectedNode& operator=(const DirectedNode& node) = delete;
51
52
56 {
57 m_innerNodes.push_back(&newNode);
58 }
59
60
63 {
64 m_outerNodes.push_back(&newNode);
65 }
66
67
68 public:
71 bool operator == (const DirectedNode& b) const { return (m_entry == b.getConstEntry()); }
72
74 bool operator != (const DirectedNode& b) const { return !(m_entry == b.getConstEntry()); }
75
77 bool operator == (const EntryType& b) const { return (m_entry == b); }
78
80 bool operator != (const EntryType& b) const { return !(m_entry == b); }
81
82
85
86 std::vector<DirectedNode<EntryType, MetaInfoType>*>& getInnerNodes() { return m_innerNodes; }
87
89 std::vector<DirectedNode<EntryType, MetaInfoType>*>& getOuterNodes() { return m_outerNodes; }
90
92 EntryType& getEntry() { return m_entry; }
93
95 const EntryType& getConstEntry() const { return m_entry; }
96
99
101 MetaInfoType& getMetaInfo() { return m_metaInfo; }
102
104 short getFamily() const { return m_family; }
105
107 void setFamily(short family) { m_family = family; }
108
109
112 std::vector<DirectedNode<EntryType, MetaInfoType>*> m_innerNodes;
113
115 std::vector<DirectedNode<EntryType, MetaInfoType>*> m_outerNodes;
116
118 EntryType& m_entry;
119
121 MetaInfoType m_metaInfo;
122
124 short m_family;
125 };
126
127
130 template <class EntryType, class MetaInfoType>
131 bool operator == (const EntryType& a, const DirectedNode<EntryType, MetaInfoType>& b)
132 {
133 return (a == b.getConstEntry());
134 }
135
136}
The Node-Class.
short getFamily() const
Returns identifier of this cell.
DirectedNode(EntryType &entry)
************************* CONSTRUCTORS *************************
DirectedNode< EntryType, MetaInfoType > * getPtr()
Returns Pointer to this node.
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getInnerNodes()
************************* PUBLIC MEMBER FUNCTIONS *************************
MetaInfoType & getMetaInfo()
Returns reference to MetaInfoType attached to this node.
EntryType & getEntry()
Allows access to stored entry.
void setFamily(short family)
Assign a family identifier to this cell.
DirectedNode(const DirectedNode &node)=delete
Forbid copy constructor.
bool operator==(const DirectedNode &b) const
************************* OPERATORS *************************
bool operator!=(const DirectedNode &b) const
!= -operator - compares if two nodes are not identical
const EntryType & getConstEntry() const
Allows const access to stored entry (needed for external operator overload.
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getOuterNodes()
Returns links to all outer nodes attached to this one.
std::vector< DirectedNode< Belle2::Segment< Belle2::TrackNode >, Belle2::CACell > * > m_innerNodes
DirectedNode & operator=(const DirectedNode &node)=delete
Forbid assignment operator.
std::vector< DirectedNode< Belle2::Segment< Belle2::TrackNode >, Belle2::CACell > * > m_outerNodes
void addInnerNode(DirectedNode< EntryType, MetaInfoType > &newNode)
************************* INTERNAL MEMBER FUNCTIONS *************************
void addOuterNode(DirectedNode< EntryType, MetaInfoType > &newNode)
Adds new links to the outward direction.
bool operator==(const DecayNode &node1, const DecayNode &node2)
Compare two Decay Nodes: They are equal if All daughter decay nodes are equal or one of the daughter ...
Definition DecayNode.cc:47
Abstract base class for different kinds of events.