Belle II Software  release-08-01-10
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 
12 namespace Belle2 {
30  template<typename EntryType, typename MetaInfoType>
31  class DirectedNode {
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  EntryType& m_entry;
113 
115  std::vector<DirectedNode<EntryType, MetaInfoType>*> m_innerNodes;
116 
118  std::vector<DirectedNode<EntryType, MetaInfoType>*> m_outerNodes;
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  }
136 }
Network of directed nodes of the type EntryType.
The Node-Class.
Definition: DirectedNode.h:31
MetaInfoType m_metaInfo
Contains a MetaInfo for doing extra-stuff (whatever you need)
Definition: DirectedNode.h:121
short getFamily() const
Returns identifier of this cell.
Definition: DirectedNode.h:104
DirectedNode(EntryType &entry)
************************* CONSTRUCTORS *************************
Definition: DirectedNode.h:38
EntryType & m_entry
************************* DATA MEMBERS *************************
Definition: DirectedNode.h:112
short m_family
Identifier for all connected nodes.
Definition: DirectedNode.h:124
MetaInfoType & getMetaInfo()
Returns reference to MetaInfoType attached to this node.
Definition: DirectedNode.h:101
DirectedNode & operator=(const DirectedNode &node)=delete
Forbid assignment operator.
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getOuterNodes()
Returns links to all outer nodes attached to this one.
Definition: DirectedNode.h:89
void setFamily(short family)
Assign a family identifier to this cell.
Definition: DirectedNode.h:107
DirectedNode(const DirectedNode &node)=delete
Forbid copy constructor.
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getInnerNodes()
************************* PUBLIC MEMBER FUNCTIONS *************************
Definition: DirectedNode.h:86
bool operator==(const DirectedNode &b) const
************************* OPERATORS *************************
Definition: DirectedNode.h:71
const EntryType & getConstEntry() const
Allows const access to stored entry (needed for external operator overload.
Definition: DirectedNode.h:95
EntryType & getEntry()
Allows access to stored entry.
Definition: DirectedNode.h:92
bool operator!=(const DirectedNode &b) const
!= -operator - compares if two nodes are not identical
Definition: DirectedNode.h:74
std::vector< DirectedNode< EntryType, MetaInfoType > * > m_innerNodes
Carries all links to inner nodes.
Definition: DirectedNode.h:115
DirectedNode< EntryType, MetaInfoType > * getPtr()
Returns Pointer to this node.
Definition: DirectedNode.h:98
std::vector< DirectedNode< EntryType, MetaInfoType > * > m_outerNodes
Carries all links to outer nodes.
Definition: DirectedNode.h:118
void addInnerNode(DirectedNode< EntryType, MetaInfoType > &newNode)
************************* INTERNAL MEMBER FUNCTIONS *************************
Definition: DirectedNode.h:55
void addOuterNode(DirectedNode< EntryType, MetaInfoType > &newNode)
Adds new links to the outward direction.
Definition: DirectedNode.h:62
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:48
Abstract base class for different kinds of events.