The Gaudi Framework  master (37c0b60a)
iNode.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <Gaudi/Decays/Nodes.h>
12 #include <Gaudi/Decays/iNode.h>
13 #include <GaudiKernel/StatusCode.h>
14 #include <sstream>
15 #include <typeinfo>
16 
17 namespace Decays = Gaudi::Decays;
18 
26  fillStream( s );
27  return s.str();
28 }
29 
30 bool Decays::iNode::operator!() const { return !( this->valid() ); }
31 
33  if ( typeid( Decays::Node ) == typeid( node ) ) {
34  const Node& _node = dynamic_cast<const Node&>( node );
35  m_node.reset( _node.m_node->clone() );
36  } else {
37  m_node.reset( node.clone() );
38  }
39 }
40 
41 Decays::Node::Node( const Decays::Node& right ) : Decays::iNode( right ), m_node( right.m_node->clone() ) {}
42 
43 bool Decays::Node::operator()( const Gaudi::ParticleID& pid ) const { return node( pid ); }
44 
45 std::ostream& Decays::Node::fillStream( std::ostream& s ) const { return m_node->fillStream( s ); }
46 
47 bool Decays::Node::valid() const { return m_node->valid(); }
48 
50  return m_node->validate( svc );
51 }
52 
54  if ( &right == this ) { return *this; }
55  m_node.reset( right.m_node->clone() );
56  return *this;
57 }
58 
60  if ( &right == this ) { return *this; }
61  Decays::iNode* node = nullptr;
62  if ( typeid( Decays::Node ) == typeid( right ) ) {
63  const Node& _node = dynamic_cast<const Node&>( right );
64  node = _node.m_node->clone();
65  } else {
66  node = right.clone();
67  }
68  m_node.reset( node );
69  return *this;
70 }
71 
72 Decays::Node* Decays::Node::clone() const { return new Decays::Node( *this ); }
73 
74 Decays::Node& Decays::Node::op_and( const Decays::iNode& right ) { return ( *this = ( *m_node && right ) ); }
75 
76 Decays::Node& Decays::Node::op_or( const Decays::iNode& right ) { return ( *this = ( *m_node || right ) ); }
Gaudi::Decays::Node
Definition: iNode.h:74
Gaudi::Decays::iNode::fillStream
virtual std::ostream & fillStream(std::ostream &s) const =0
printout of the stream
std::string
STL class.
Gaudi::Decays::iNode::clone
virtual iNode * clone() const =0
clone method ("virtual constructor")
Gaudi::Decays::Node::clone
Node * clone() const override
MANDATORY: clone method ("virtual constructor")
Definition: iNode.cpp:72
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Decays::Node::fillStream
std::ostream & fillStream(std::ostream &s) const override
MANDATORY: the specific printout.
Definition: iNode.cpp:45
Gaudi::Interfaces::IParticlePropertySvc
Definition: IParticlePropertySvc.h:29
Gaudi::Decays::Node::valid
bool valid() const override
MANDATORY: check the validity of the node.
Definition: iNode.cpp:47
Nodes.h
Gaudi::Decays::Node::op_and
Node & op_and(const iNode &right)
Definition: iNode.cpp:74
GaudiPartProp.Nodes.Node
Node
Definition: Nodes.py:247
Gaudi::Decays::Node::validate
StatusCode validate(const Gaudi::Interfaces::IParticlePropertySvc *svc) const override
MANDATORY: the proper validation of the node.
Definition: iNode.cpp:49
StatusCode.h
StatusCode
Definition: StatusCode.h:65
std::ostream
STL class.
Gaudi::Decays::iNode::toString
virtual std::string toString() const
the string representation of the node
Definition: iNode.cpp:24
Gaudi::Decays::Node::operator=
Node & operator=(const Node &right)
assignment operator:
Definition: iNode.cpp:53
GaudiPartProp.decorators.Decays
Decays
Definition: decorators.py:33
std::ostringstream
STL class.
Gaudi::Decays
Definition: CC.h:17
Gaudi::Decays::valid
bool valid(Iterator begin, Iterator end)
check the validness of the trees or nodes
Definition: Nodes.h:36
Gaudi::Decays::Node::op_or
Node & op_or(const iNode &right)
Definition: iNode.cpp:76
Gaudi::ParticleID
Definition: ParticleID.h:43
iNode.h
Gaudi::Decays::iNode
Definition: iNode.h:35
Gaudi::Decays::Node::operator()
bool operator()(const Gaudi::ParticleID &p) const override
MANDATORY: the only one essential method.
Definition: iNode.cpp:43
Gaudi::Decays::Node::m_node
std::unique_ptr< iNode > m_node
the node itself:
Definition: iNode.h:111
Gaudi::Decays::iNode::operator!
virtual bool operator!() const
invalid node?
Definition: iNode.cpp:30
Gaudi::Decays::Node::Node
Node(const Decays::iNode &node)
constructor from the node
Definition: iNode.cpp:32