Belle II Software  release-05-02-19
DirectedNode.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jakob Lettenbichler *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <vector>
13 
14 namespace Belle2 {
32  template<typename EntryType, typename MetaInfoType>
33  class DirectedNode {
35  template<typename AnyType, typename AnyOtherType> friend class DirectedNodeNetwork;
36 
37  protected:
40  explicit DirectedNode(EntryType& entry) :
41  m_entry(entry), m_metaInfo(MetaInfoType()), m_family(-1)
42  {
43  // Reserve some space for the vectors, TODO: can still be fine-tuned
44  m_innerNodes.reserve(10);
45  m_outerNodes.reserve(10);
46  }
47 
49  DirectedNode(const DirectedNode& node) = delete;
50 
52  DirectedNode& operator=(const DirectedNode& node) = delete;
53 
54 
58  {
59  m_innerNodes.push_back(&newNode);
60  }
61 
62 
64  void addOuterNode(DirectedNode<EntryType, MetaInfoType>& newNode)
65  {
66  m_outerNodes.push_back(&newNode);
67  }
68 
69 
70  public:
73  bool operator == (const DirectedNode& b) const { return (m_entry == b.getConstEntry()); }
74 
76  bool operator != (const DirectedNode& b) const { return !(m_entry == b.getConstEntry()); }
77 
79  bool operator == (const EntryType& b) const { return (m_entry == b); }
80 
82  bool operator != (const EntryType& b) const { return !(m_entry == b); }
83 
84 
86 
88  std::vector<DirectedNode<EntryType, MetaInfoType>*>& getInnerNodes() { return m_innerNodes; }
89 
91  std::vector<DirectedNode<EntryType, MetaInfoType>*>& getOuterNodes() { return m_outerNodes; }
92 
94  EntryType& getEntry() { return m_entry; }
95 
97  const EntryType& getConstEntry() const { return m_entry; }
98 
100  DirectedNode<EntryType, MetaInfoType>* getPtr() { return this; }
101 
103  MetaInfoType& getMetaInfo() { return m_metaInfo; }
104 
106  short getFamily() const { return m_family; }
107 
109  void setFamily(short family) { m_family = family; }
110 
111 
114  EntryType& m_entry;
115 
117  std::vector<DirectedNode<EntryType, MetaInfoType>*> m_innerNodes;
118 
120  std::vector<DirectedNode<EntryType, MetaInfoType>*> m_outerNodes;
121 
123  MetaInfoType m_metaInfo;
124 
126  short m_family;
127  };
128 
129 
132  template <class EntryType, class MetaInfoType>
133  bool operator == (const EntryType& a, const DirectedNode<EntryType, MetaInfoType>& b)
134  {
135  return (a == b.getConstEntry());
136  }
138 }
Belle2::DirectedNode::getInnerNodes
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getInnerNodes()
************************* PUBLIC MEMBER FUNCTIONS *************************
Definition: DirectedNode.h:96
Belle2::DirectedNode::m_entry
EntryType & m_entry
************************* DATA MEMBERS *************************
Definition: DirectedNode.h:122
Belle2::DirectedNode::addOuterNode
void addOuterNode(DirectedNode< EntryType, MetaInfoType > &newNode)
Adds new links to the outward direction.
Definition: DirectedNode.h:72
Belle2::DirectedNode::operator=
DirectedNode & operator=(const DirectedNode &node)=delete
Forbid assignment operator.
Belle2::operator==
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:50
Belle2::DirectedNode::m_metaInfo
MetaInfoType m_metaInfo
Contains a MetaInfo for doing extra-stuff (whatever you need)
Definition: DirectedNode.h:131
Belle2::DirectedNode::DirectedNodeNetwork
friend class DirectedNodeNetwork
Only the DirectedNodeNetwork can create DirectedNodes and link them.
Definition: DirectedNode.h:43
Belle2::DirectedNode::getOuterNodes
std::vector< DirectedNode< EntryType, MetaInfoType > * > & getOuterNodes()
Returns links to all outer nodes attached to this one.
Definition: DirectedNode.h:99
Belle2::DirectedNode::m_innerNodes
std::vector< DirectedNode< EntryType, MetaInfoType > * > m_innerNodes
Carries all links to inner nodes.
Definition: DirectedNode.h:125
Belle2::DirectedNode::DirectedNode
DirectedNode(EntryType &entry)
************************* CONSTRUCTORS *************************
Definition: DirectedNode.h:48
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DirectedNode::getMetaInfo
MetaInfoType & getMetaInfo()
Returns reference to MetaInfoType attached to this node.
Definition: DirectedNode.h:111
Belle2::DirectedNode::getPtr
DirectedNode< EntryType, MetaInfoType > * getPtr()
Returns Pointer to this node.
Definition: DirectedNode.h:108
Belle2::DirectedNode::setFamily
void setFamily(short family)
Assign a family identifier to this cell.
Definition: DirectedNode.h:117
Belle2::DirectedNode::getFamily
short getFamily() const
Returns identifier of this cell.
Definition: DirectedNode.h:114
Belle2::DirectedNode::getConstEntry
const EntryType & getConstEntry() const
Allows const access to stored entry (needed for external operator overload.
Definition: DirectedNode.h:105
Belle2::DirectedNode::operator==
bool operator==(const DirectedNode &b) const
************************* OPERATORS *************************
Definition: DirectedNode.h:81
Belle2::DirectedNode::operator!=
bool operator!=(const DirectedNode &b) const
!= -operator - compares if two nodes are not identical
Definition: DirectedNode.h:84
Belle2::DirectedNode::m_family
short m_family
Identifier for all connected nodes.
Definition: DirectedNode.h:134
Belle2::DirectedNode
The Node-Class.
Definition: DirectedNode.h:41
Belle2::DirectedNode::getEntry
EntryType & getEntry()
Allows access to stored entry.
Definition: DirectedNode.h:102
Belle2::DirectedNode::m_outerNodes
std::vector< DirectedNode< EntryType, MetaInfoType > * > m_outerNodes
Carries all links to outer nodes.
Definition: DirectedNode.h:128
Belle2::DirectedNode::addInnerNode
void addInnerNode(DirectedNode< EntryType, MetaInfoType > &newNode)
************************* INTERNAL MEMBER FUNCTIONS *************************
Definition: DirectedNode.h:65